-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Make __file__ an absolute path in setuptools.build_meta #3795
Conversation
This is a difference between pip's legacy wheel build (or direct invocations of setup.py) and the PEP 517 build. While setup.py scripts that rely on this are fragile, it was quite painful to debug! Since Python 3.4, `__file__` is usually an absolute path, so this change might result in fewer surprises.
Hi @hauntsaninja, thank you very much for working on this. Would it be possible to have a separated test, instead of adding to the parameterised ones? |
Thanks for the quick review; updated |
Thank you very much @hauntsaninja, I think this looks good to me. |
Yeah, abspath works fine if the file doesn't exist |
Hmm, I guess it calls os.getcwd, which can fail if the cwd has been deleted. But I think that's still okay? Or at least, I see plenty of abspath and os.getcwd in the setuptools source |
That should be fine because CWD should contain the package code. Yep, that is what the spec says:
|
If the other maintainers have no reservations, I will include this change in the next release. |
Summary of changes
This is a difference between pip's legacy wheel build (or direct invocations of setup.py) and the PEP 517 build.
While setup.py scripts that rely on this are fragile, it was quite painful to debug! Since Python 3.4,
__file__
is usually an absolute path, so this change might result in fewer surprises.