-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
modules: python: better handling of the Python paths for Debian #9288
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9288 +/- ##
==========================================
+ Coverage 66.85% 66.87% +0.02%
==========================================
Files 386 388 +2
Lines 85062 85247 +185
Branches 17551 17515 -36
==========================================
+ Hits 56869 57011 +142
- Misses 23401 23494 +93
+ Partials 4792 4742 -50
Continue to review full report at Codecov.
|
8cee5a7
to
33755fd
Compare
Gave this a try on my Windows machine too:
|
OOC, that's the plan with distutils upstream? They could remove the module completely, so we should guard the import behind try/except and fallback to sysconfig? Also, other than deb_system, are there any other case where sysconfig is not enough? |
Yes, 1sec. I will push my code to handle all that. |
I'm also wondering if we should actually allow installing python modules outside of Meson's prefix. Thinking about Windows where they should go into |
33755fd
to
e204313
Compare
563923d
to
faed5be
Compare
mesonbuild/modules/python.py
Outdated
raise ModuleNotFoundError('Unable to import distutils, please install python3-distutils') | ||
debian_distutils = 'deb_system' in distutils.command.install.INSTALL_SCHEMES | ||
except ModuleNotFoundError: | ||
debian_distutils = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a try inside a try, import distutils
should always work on all platforms, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not after 3.12.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless someone is naughty enough to create a Python package that provides the same module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case we'll need to fix links_against_libpython() too, let's cross that bridge when/if we get there? OTOH, this is getting petty nitpicking I admit ;P
OOC, how confident are we that it's going to be removed in 3.12? It has been formally announced already? When that happens, what's the likely outcome for Debian, they'll patch sysconfig instead?
Sorry again for all my questions, I wasn't familiar with this topic, so I like to learned it a bit :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case we'll need to fix links_against_libpython() too, let's cross that bridge when/if we get there? OTOH, this is getting petty nitpicking I admit ;P
I'd prefer doing in a different PR as it is not actually an issue right now, while this is. We can fix the current handling of the Debian install paths and then explore how to fase out distutils entirely.
OOC, how confident are we that it's going to be removed in 3.12?
Very.
It has been formally announced already? When that happens, what's the likely outcome for Debian, they'll patch sysconfig instead?
Yes, my best guess is either PEP 668 or that, or both.
Also related: https://bugs.python.org/issue43976 (maybe skip down to the latest discussion)
Sorry again for all my questions, I wasn't familiar with this topic, so I like to learned it a bit :)
No worries, I have been dealing with these issues for a little while and still struggle to keep track of everything.
faed5be
to
40c058a
Compare
40c058a
to
df44630
Compare
@xclaesse can you have a look? I think this is essentially ready. |
df44630
to
18ddc57
Compare
I pushed a fix hopefully dealing with the failing tests due to old Python versions. @eli-schwartz I will submit the improvements to the message in a different pull request, if that's alright with you, as we probably want to have a different discussion and review for that. Hopefully, we can merge this ASAP. |
18ddc57
to
bb27cbd
Compare
Sorry for the delay, I have been busy. I removed the try .. except block for the Debian stuff from this PR, I'll see if I have time to open a new PR next week. |
Hardcoding the name is fragile, and enabling it based on the existence of /etc/debian_version (as the is_debianlike helper does) will result in incorrect paths if the Python binary is not provided by Debian. Using the deb_system distuils scheme instead makes sure we use the install path from the current interpreter, which Debian could change between releases, and gives us the correct value on Python installations that are not provided by Debian (eg. deadsnakes, Github Action Python, etc.) Do notice, though, that there is still no guarantee that these are the correct paths, as they assume all schemes paths have the install prefix as a base, see mesonbuild#9284. Signed-off-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@riseup.net>
bb27cbd
to
83be616
Compare
Looks good to me, thanks! |
Thanks! Indeed this looks good to me too. |
Hardcoding the name is fragile, and enabling it based on the existence of
/etc/debian_version (as the is_debianlike helper does) will result in
incorrect paths if the Python binary is not provided by Debian.
Using the deb_system distutils scheme instead makes sure we use the
install path from the current interpreter, which Debian could change
between releases, and gives us the correct value on Python installations
that are not provided by Debian (eg. deadsnakes, Github Action Python,
etc.)
Do notice, though, that there is still no guarantee that these are the
correct paths, as they assume all schemes paths have the install prefix
as a base, see #9284.
Signed-off-by: Filipe Laíns lains@riseup.net