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

Allow pipx run --pypackages to function again. #636

Merged
merged 7 commits into from
Feb 24, 2021

Conversation

itsayellow
Copy link
Contributor

  • I have added an entry to docs/changelog.md

Summary of changes

Closes #623 .

Due to a regression with PR #252 in order to fix Issue #233, using pipx with pythonloc (using the local __pypackages__ folder) stopped working.

To use packages in the local __pypackages__ folder with pipx run --pypackages, pipx adds the appropriate folders to PYTHONPATH. Unfortunately the code from the previous PR removes PYTHONPATH before running it, nullifying the effect of pipx's own code.

This PR selectively allows only the two paths added by the pypackages code in pipx to PYTHONPATH to remain, removing PYTHONPATH or other directories in PYTHONPATH otherwise.

The code got a little less clean, but we should support operation of our own features (!)

Test plan

Tested by running

From report in Issue #623:

pipx install piploc
piploc install flask
pipx run --pypackages flask

pipx 0.16.0.0 shows error, this PR runs as expected.

@uranusjr
Copy link
Member

The repeated PYTHONPATH string manipulation makes me nervous. Would it be better for exec_app to accept an additional extra_sys_path: list[str] and perform the PYTHONPATH addition only once, right before the app is executed?

@itsayellow
Copy link
Contributor Author

The repeated PYTHONPATH string manipulation makes me nervous. Would it be better for exec_app to accept an additional extra_sys_path: list[str] and perform the PYTHONPATH addition only once, right before the app is executed?

Sure, that sounds cleaner to me.

@itsayellow
Copy link
Contributor Author

@uranusjr how does it look now? I left in the code that accommodates an intact PYTHONPATH in case we ever change our code and stop completely deleting it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Libraries from the local folder are not imported
2 participants