forked from python-poetry/poetry
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug/Poetry Runtime: Elide USERBASE with poetry internal deps (#31)
* Ensure that poetry doesn't break if PYTHONUSERBASE packages conflict with poetry internal deps The problem we were facing was that html5lib===1.0b8 was a dependency of redberry, which relied on python <=3.7. ~/ReplWorkspace$ poetry add redberry cannot import name 'Mapping' from 'collections' (/nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/collections/__init__.py) We need to preserve the full PYTHONPATH because poetry executes pip to uninstall packages, and if PYTHONPATH does not contain the PYTHONUSERBASE then it will silently not uninstall packages. * Bumping python version
- Loading branch information
1 parent
21024b8
commit 0a3947d
Showing
4 changed files
with
34 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "poetry" | ||
version = "1.5.3" | ||
version = "1.5.4" | ||
description = "Python dependency management and packaging made easy." | ||
authors = ["Sébastien Eustace <[email protected]>"] | ||
maintainers = [ | ||
|
@@ -93,8 +93,7 @@ optional = true | |
pytest-github-actions-annotate-failures = "^0.1.7" | ||
|
||
[tool.poetry.scripts] | ||
poetry = "poetry.console.application:main" | ||
|
||
poetry = "poetry.replit:main" | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.5.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
from __future__ import annotations | ||
|
||
import sys | ||
|
||
import os | ||
|
||
if __name__ == "__main__": | ||
# Explicitly remove PYTHONUSERBASE from sys.path without touching PYTHONPATH. | ||
# We may need additional libraries supplied by the environment, but we should | ||
# do our best to insulate ourselves from the user's site-packages. | ||
# | ||
# Unfortunately, `poetry remove` delegates to `pip uninstall`, so simply | ||
# removing PYTHONUSERBASE from PYTHONPATH will prevent anything from | ||
# being uninstalled. | ||
userbase = os.getenv('PYTHONUSERBASE') | ||
if userbase: | ||
sys.path = [x for x in sys.path if not x.startswith(userbase)] | ||
|
||
from poetry.console.application import main | ||
|
||
sys.exit(main()) |
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 |
---|---|---|
|
@@ -16,4 +16,4 @@ | |
try: | ||
__version__ = version("poetry") | ||
except: | ||
__version__ = "1.5.3" | ||
__version__ = "1.5.4" |
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,19 @@ | ||
from __future__ import annotations | ||
|
||
import sys | ||
import os | ||
|
||
# Explicitly remove PYTHONUSERBASE from sys.path without touching PYTHONPATH. | ||
# We may need additional libraries supplied by the environment, but we should | ||
# do our best to insulate ourselves from the user's site-packages. | ||
# | ||
# Unfortunately, `poetry remove` delegates to `pip uninstall`, so simply | ||
# removing PYTHONUSERBASE from PYTHONPATH will prevent anything from | ||
# being uninstalled. | ||
userbase = os.getenv('PYTHONUSERBASE') | ||
if userbase: | ||
sys.path = [x for x in sys.path if not x.startswith(userbase)] | ||
|
||
# Re-export main in a way that Pyright doesn't complain about | ||
import poetry.console.application | ||
main = poetry.console.application.main |