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
bpo-40854: Allow overriding sys.platlibdir via PYTHONPLATLIBDIR env-var #20605
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! |
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 |
e9d39a2
to
1eb849f
Compare
|
@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. |
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. |
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. |
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 (pythonGH-20605) (cherry picked from commit 8f023a2)
…ch-2 * 'patch-2' of https://github.com/vegerot/cpython: (1585 commits) bpo-35019: Add tests for IPAddress in asyncio Remove usesless function from csv module (pythonGH-20762) bpo-40684: Fix make install for platlibdir=lib64 (pythonGH-20736) Remove reference to 3.7 and 3.8 backports. (pythonGH-20754) Minor improvement to the namedtuple implementation (pythonGH-20741) bpo-24914: mention Python supports multiple paradigms in the FAQ (python#20658) bpo-40854: PYTHONPLATLIBDIR env var added to 3.9 (pythonGH-20735) Add multicore support to deccheck.py. (pythonGH-20731) Remove deleted libmpdec header from the Visual Studio build machinery. (pythonGH-20730) bpo-40861: Enable optimizations when building liblzma (pythonGH-20724) bpo-40910: Export Py_GetArgcArgv() function (pythonGH-20721) bpo-40854: Allow overriding sys.platlibdir via PYTHONPLATLIBDIR env-var (pythonGH-20605) bpo-29882: Add _Py_popcount32() function (pythonGH-20518) bpo-33187: Document 3.9 changes to xml.etree.ElementInclude.include (pythonGH-20438) allow macOS installer builds to package pre-built html docs (pythonGH-20715) Deny eval() direct access to builtins (pythonGH-20713) bpo-22021: Update root_dir and base_dir documentation in shutil (pythonGH-10367) bpo-40741: Update macOS installer to use SQLite 3.32.2. (pythonGH-20705) bpo-40903: Handle multiple '=' in invalid assignment rules in the PEG parser (pythonGH-20697) bpo-39791 native hooks for importlib.resources.files (pythonGH-20576) ...


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