-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-40854: Allow overriding sys.platlibdir via PYTHONPLATLIBDIR env-var #20605
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
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). Recognized GitHub usernameWe couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames: This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
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.
See https://pythondev.readthedocs.io/pyconfig.html#add-an-environment-variable for the different steps to add a new environment variables:
- Update usage_xxx to document the new env var
- Doc/using/cmdline.rst: Document the new env var
- Misc/python.man: Document the new env var
- You may also mention it at https://docs.python.org/dev/library/sys.html#sys.platlibdir
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
@vstinner Thanks for your prompt feedback, I've reworked the PR |
@manisandro Could you please copy paste and use the phrase as suggested by the bot? It will label this PR accordingly. |
I have made the requested changes; please review again |
Thanks for making the requested changes! @vstinner: please review the changes made to this pull request. |
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.
Thanks, the update PR is much better! New review.
Please document also the new PyConfig field in https://docs.python.org/dev/c-api/init_config.html#c.PyConfig documentation with a ".. versionadded:: 3.10" markup.
Misc/NEWS.d/next/Core and Builtins/2020-06-03-13-53-24.bpo-40854.O6vfQU.rst
Outdated
Show resolved
Hide resolved
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I have made the requested changes; please review again |
Thanks for making the requested changes! @vstinner: please review the changes made to this pull request. |
It seems possible to test a custom PYTHONPATHLIBDIR in test_embed. At least, the following patch worked for me:
|
Thanks, added to PR. |
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.
Ok, the PR now looks complete: all documentations are updated, thanks!
I didn't expect the new sys.platlibdir to land into PyConfig, but I think that I understood the rationale in https://bugs.python.org/issue40854
Overriding PYTHONHOME is uncommon. If you do that, I'm not surprised that you fall into corner cases. So having the ability to override platlibdir sounds reasonable.
Hum. It seems like PyConfig.platlibdir is a parameter which affects the "Path Configuration". So please add it to "Path configuration inputs" at:
https://docs.python.org/dev/c-api/init_config.html#path-configuration
Doc/c-api/init_config.rst
Outdated
@@ -436,6 +436,14 @@ PyConfig | |||
|
|||
:data:`sys.base_prefix`. | |||
|
|||
.. c:member:: wchar_t* platlibdir | |||
|
|||
:data:`sys.platlibdir`: platform library dir name, set at configure time |
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.
:data:`sys.platlibdir`: platform library dir name, set at configure time | |
:data:`sys.platlibdir`: platform library directory name, set at configure time |
Misc/python.man
Outdated
Override the python platform libdir name from the value set by | ||
--with-platlibdir when the Python build was configured. |
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.
Override sys.platlibdir.
PyConfig_Clear(&config); | ||
Py_ExitStatusException(status); | ||
} | ||
|
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.
nitpick: one empty line is enough :-)
Thanks, I've updated the PR accordingly. |
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.
Oh, one last request, sorry!
When you update a PR, please add a new commit rather than always rebase/squash your commits. New commits help to see what has been modified since my latest review.
@@ -1731,6 +1743,14 @@ config_read(PyConfig *config) | |||
} | |||
} | |||
|
|||
if(config->platlibdir == NULL) { | |||
status = CONFIG_SET_BYTES_STR(config, &config->platlibdir, PLATLIBDIR, | |||
"PLATLIBDIR macro"); |
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.
Oh, I didn't notice the Makefile change to define PLATLIBDIR macro. Please add an explicit check to ensure that it's defined. See Modules/getpath.c. I sugges to add at the top of this file, after includes (on Windows, it's defined by PC/pyconfig.h which is included by Python.h):
#ifndef PLATLIBDIR
# error "PLATLIBDIR macro must be defined"
#endif
No problem, pushed as new commit. |
Thanks, I merged your PR. |
Thank you for merging and for the review! |
…ar (GH-20605) (GH-20725) (cherry picked from commit 8f023a2) Co-authored-by: Sandro Mani <[email protected]>
You can currently point the python interpreter to a different install say via
With the newly added platlibdir [1], if python was configured with platlibdir=lib64, this will break because i.e. the site-packages dir as returned by
sysconfig.get_paths()
will use lib64 and not lib as the other install may be using.This PR adds the possibility to override the platlibdir via environment variable.
Full rationale: [2].
[1] #8068
[2] https://src.fedoraproject.org/rpms/python3.9/pull-request/10
https://bugs.python.org/issue40854