Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DEV: use abspath on windows #12535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion numpy/distutils/command/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,11 @@ def _process_unlinkable_fobjects(self, objects, libraries,

# Wrap unlinkable objects to a linkable one
if unlinkable_fobjects:
fobjects = [os.path.relpath(obj) for obj in unlinkable_fobjects]
if os.name == 'nt':
# relpath fails if we are on a different drive
fobjects = [os.path.abspath(obj) for obj in unlinkable_fobjects]
else:
fobjects = [os.path.relpath(obj) for obj in unlinkable_fobjects]
Copy link
Member

@eric-wieser eric-wieser Dec 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively - do we want to define:

def relpath_safe(p):
    try:
        return os.path.relpath(p)
    except ValueError:
        # on windows, caused by different drive letter
        return os.path.abspath(p)

That means that in cases where it's safe, we can continue to use relative paths

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't actually test the alternate drive scenario since we are using -n, so I am hesitant to put in more complicated untested logic. At some point Python could decide to change the exception to a different error and we would never know. Perhaps we should just always use abspath?

Copy link
Member

@eric-wieser eric-wieser Dec 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should just always use abspath?

It's hard to say without knowing the original rationale for the relative paths.

I think it's incredibly unlikely that python changes the exception type in future, and if they do, I'd hope they'd just create a subclass of ValueError, like they did when they changed IOError

wrapped = fcompiler.wrap_unlinkable_objects(
fobjects, output_dir=self.build_temp,
extra_dll_dir=self.extra_dll_dir)
Expand Down