-
Notifications
You must be signed in to change notification settings - Fork 309
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
python-setup: Handle poetry virtualenvs.options.no-pip = true
#1431
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
259993b
python-setup: Handle poetry `virtualenvs.options.no-pip = true`
RasmusWL 932b6a9
python-setup: Fix path for tests
RasmusWL ebf1b8f
Fix prettier problem
RasmusWL b810730
python-setup: Fix for python2
RasmusWL 2649b66
python-setup: Fix site-packages selection without pip for Windows
RasmusWL 2f6d174
python-setup: Make debug printing more obvious
RasmusWL 4bd9723
`npm run build`
RasmusWL 5ed1e98
python-setup: Fix site-package selection for unix
RasmusWL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Print the path to the site-packages directory for the current Python environment. | ||
""" | ||
from __future__ import print_function | ||
|
||
try: | ||
import pip | ||
import os | ||
print(os.path.dirname(os.path.dirname(pip.__file__))) | ||
except ImportError: | ||
import sys | ||
print("DEBUG: could not import pip", file=sys.stderr) | ||
# if you use poetry with `virtualenvs.options.no-pip = true` you might end up with a | ||
# virtualenv without pip, so the above trick doesn't actually work. See | ||
# https://python-poetry.org/docs/configuration/#virtualenvsoptionsno-pip | ||
# | ||
# A possible option is to install `pip` into the virtualenv created by poetry | ||
# (`poetry add pip`), but it turns out that doesn't always work :( for the test | ||
# poetry/requests-3, I was not allowed to install pip! So I did not pursue this | ||
# option further. | ||
# | ||
# Instead, testing `site.getsitepackages()` contains has the right path, whereas | ||
# `site.getusersitepackages()` is about the system python (very confusing). | ||
# | ||
# We can't use the environment variable POETRY_VIRTUALENVS_OPTIONS_NO_PIP because it | ||
# does not work, see https://github.com/python-poetry/poetry/issues/5906 | ||
import site | ||
|
||
if sys.platform.startswith("win32"): | ||
# On windows, the last entry of `site.getsitepackages()` has the right path | ||
print(site.getsitepackages()[-1]) | ||
else: | ||
# on unix, the first entry of `site.getsitepackages()` has the right path | ||
print(site.getsitepackages()[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
[virtualenvs] | ||
in-project = true | ||
|
||
[virtualenvs.options] | ||
no-pip = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You will need to rebuild the javascript files in order to get this to pass.
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.
npm run build
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 <3