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

Conversation

mattip
Copy link
Member

@mattip mattip commented Dec 12, 2018

Fixes #12530 where having build artifacts on different drives prevents use of os.path.relpath

@mattip
Copy link
Member Author

mattip commented Dec 12, 2018

Hmm. 32 bit builds are failing. Should they be using C:\tools\mingw64\bin\gfortran.exe ?

2018-12-12T09:39:01.2324286Z error: Command "C:\tools\mingw64\bin\gfortran.exe -Wall -g -Wall -g -shared -Wl,--whole-archive C:\hostedtoolcache\windows\Python\3.6.4\x86\lib\openblas.a -Wl,--no-whole-archive -LC:\tools\mingw64\lib\gcc\x86_64-w64-mingw32\5.3.0 -LC:\hostedtoolcache\windows\Python\3.6.4\x86\libs -LC:\hostedtoolcache\windows\Python\3.6.4\x86\PCbuild\win32 -Lbuild\temp.win32-3.6 -o build\temp.win32-3.6\Release\.libs\libopenblas.JKAMQ5EVHIVCPXP2XZJB2RQPIN47S32M.gfortran-win32.dll -Wl,--allow-multiple-definition -Wl,--output-def,build\temp.win32-3.6\Release\libopenblas.JKAMQ5EVHIVCPXP2XZJB2RQPIN47S32M.gfortran-win32.def -Wl,--export-all-symbols -Wl,--enable-auto-import -static -mlong-double-64" failed with exit status 1

Copy link
Contributor

@tylerjereddy tylerjereddy left a comment

Choose a reason for hiding this comment

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

If this works, I'll be curious to see if the build info related Azure warning disappears from Windows jobs. I bet removing the -n will do the trick, but not sure.

@tylerjereddy
Copy link
Contributor

The 2->1 warnings thing appears to be happening on other recent PRs now too -- perhaps on Microsoft's end then for that matter.

# 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

@mattip
Copy link
Member Author

mattip commented Dec 14, 2018

I do not see this line being hit in tests on linux64. @tylerjereddy which test or build step hit this issue?

@tylerjereddy
Copy link
Contributor

I don't think we ever really have much expectation that distutils code paths are covered by tests; the only scenario where this has been an issue is on Azure pipelines windows jobs when runtests.py is invoked without the -n flag (so that it actually builds).

For whatever reason the pip build / wheel installs are not prone to the drive path issue.

I'm not sure what the best course of action is--I think it is becoming increasingly common to recommend usage of pip for installs on Windows. I originally thought this matter was perhaps higher priority because of the build-related Warnings on Windows builds, but we've now heard back from Microsoft that this is likely something on their end and not anything to do with runtests.py

@mattip
Copy link
Member Author

mattip commented Dec 15, 2018

Closing this since I cannot verify that the new code path is correct

@mattip mattip closed this Dec 15, 2018
@mattip mattip deleted the windows-abspath branch May 20, 2019 13:40
@pv
Copy link
Member

pv commented May 1, 2020

The only platform where this matters is on Windows, so it's sufficient to test on Windows.
I doubt there's necessarily a clear rationale for the use of relpath.

@tylerjereddy
Copy link
Contributor

tylerjereddy commented May 1, 2020

It sounds like we may want to revisit this, using Eric's try/except approach to be conservative. I guess we can't auto-reopen the PR because the branch was deleted.

@eric-wieser
Copy link
Member

I'd probably vote against my suggestion above - chance are it either always works on absolute paths, or it never does. We've a greater chance of someone telling us how we got it wrong if we just use them always.

@mattip
Copy link
Member Author

mattip commented May 2, 2020

subst can be used to create a drive mapping alias on windows for a test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BLD: distutils does not gracefully handle separate Windows Drive Paths
4 participants