Skip to content
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

Poor interaction between isolated mode and --python-executable #2117

Open
ncoghlan opened this issue Jul 25, 2024 · 2 comments
Open

Poor interaction between isolated mode and --python-executable #2117

ncoghlan opened this issue Jul 25, 2024 · 2 comments
Labels
cli Related to command line interface things docs Documentation related sync

Comments

@ncoghlan
Copy link

ncoghlan commented Jul 25, 2024

Running pip-sync with --python-executable, I was baffled as to why it was attempting to remove items from the local directory (any environment) and the user site directory (python-build-standalone environments with no virtual env present).

I eventually realised it was due to the following problem: even though pip-sync was being executed from a Python runtime configured to use isolated mode (no implied sys.path[0], no user site directory), the same was not true when pip-sync invoked the given Python executable to check the value of sys.path.

This means actually performing the sync in an isolated environment requires setting the relevant Python environment variables rather relying than solely on the -I command line flag:

PYTHONNOUSERSITE=1
PYTHONSAFEPATH=1
@ncoghlan
Copy link
Author

I'm not sure what, if anything, pip-sync should change here. It may make the most sense to just document the status quo more clearly.

Alternatively, pip-sync could accepts its own -I option to indicate that python_executable should be invoked with the -I option.

@chrysle chrysle added docs Documentation related cli Related to command line interface things sync labels Jul 26, 2024
@chrysle
Copy link
Contributor

chrysle commented Jul 26, 2024

+1 on at least documenting this. I'm also fine with adding a specific option, but it'd require someone to step up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to command line interface things docs Documentation related sync
Projects
None yet
Development

No branches or pull requests

2 participants