Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
f5158013
Unverified
Commit
f5158013
authored
May 18, 2021
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure we don't pick up Poetry's virtualenv as the system env
parent
9591e884
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
5 deletions
+37
-5
poetry/console/commands/plugin/add.py
+1
-1
poetry/console/commands/plugin/remove.py
+1
-1
poetry/console/commands/plugin/show.py
+1
-1
poetry/locations.py
+9
-0
poetry/utils/env.py
+25
-2
No files found.
poetry/console/commands/plugin/add.py
View file @
f5158013
...
@@ -72,7 +72,7 @@ You can specify a package in the following forms:
...
@@ -72,7 +72,7 @@ You can specify a package in the following forms:
plugins
=
self
.
argument
(
"plugins"
)
plugins
=
self
.
argument
(
"plugins"
)
# Plugins should be installed in the system env to be globally available
# Plugins should be installed in the system env to be globally available
system_env
=
EnvManager
.
get_system_env
()
system_env
=
EnvManager
.
get_system_env
(
naive
=
True
)
env_dir
=
Path
(
env_dir
=
Path
(
os
.
getenv
(
"POETRY_HOME"
)
if
os
.
getenv
(
"POETRY_HOME"
)
else
system_env
.
path
os
.
getenv
(
"POETRY_HOME"
)
if
os
.
getenv
(
"POETRY_HOME"
)
else
system_env
.
path
...
...
poetry/console/commands/plugin/remove.py
View file @
f5158013
...
@@ -43,7 +43,7 @@ class PluginRemoveCommand(Command):
...
@@ -43,7 +43,7 @@ class PluginRemoveCommand(Command):
plugins
=
self
.
argument
(
"plugins"
)
plugins
=
self
.
argument
(
"plugins"
)
system_env
=
EnvManager
.
get_system_env
()
system_env
=
EnvManager
.
get_system_env
(
naive
=
True
)
env_dir
=
Path
(
env_dir
=
Path
(
os
.
getenv
(
"POETRY_HOME"
)
if
os
.
getenv
(
"POETRY_HOME"
)
else
system_env
.
path
os
.
getenv
(
"POETRY_HOME"
)
if
os
.
getenv
(
"POETRY_HOME"
)
else
system_env
.
path
)
)
...
...
poetry/console/commands/plugin/show.py
View file @
f5158013
...
@@ -38,7 +38,7 @@ class PluginShowCommand(Command):
...
@@ -38,7 +38,7 @@ class PluginShowCommand(Command):
+
PluginManager
(
"plugin"
)
.
get_plugin_entry_points
()
+
PluginManager
(
"plugin"
)
.
get_plugin_entry_points
()
)
)
system_env
=
EnvManager
.
get_system_env
()
system_env
=
EnvManager
.
get_system_env
(
naive
=
True
)
installed_repository
=
InstalledRepository
.
load
(
installed_repository
=
InstalledRepository
.
load
(
system_env
,
with_dependencies
=
True
system_env
,
with_dependencies
=
True
)
)
...
...
poetry/locations.py
View file @
f5158013
import
os
from
pathlib
import
Path
from
pathlib
import
Path
from
.utils.appdirs
import
user_cache_dir
from
.utils.appdirs
import
user_cache_dir
...
@@ -10,3 +12,10 @@ DATA_DIR = user_data_dir("pypoetry")
...
@@ -10,3 +12,10 @@ DATA_DIR = user_data_dir("pypoetry")
CONFIG_DIR
=
user_config_dir
(
"pypoetry"
)
CONFIG_DIR
=
user_config_dir
(
"pypoetry"
)
REPOSITORY_CACHE_DIR
=
Path
(
CACHE_DIR
)
/
"cache"
/
"repositories"
REPOSITORY_CACHE_DIR
=
Path
(
CACHE_DIR
)
/
"cache"
/
"repositories"
def
data_dir
()
->
Path
:
if
os
.
getenv
(
"POETRY_HOME"
):
return
Path
(
os
.
getenv
(
"POETRY_HOME"
))
.
expanduser
()
return
Path
(
user_data_dir
(
"pypoetry"
,
roaming
=
True
))
poetry/utils/env.py
View file @
f5158013
...
@@ -996,8 +996,31 @@ class EnvManager:
...
@@ -996,8 +996,31 @@ class EnvManager:
shutil
.
rmtree
(
str
(
file_path
))
shutil
.
rmtree
(
str
(
file_path
))
@classmethod
@classmethod
def
get_system_env
(
cls
)
->
"SystemEnv"
:
def
get_system_env
(
cls
,
naive
:
bool
=
False
)
->
"SystemEnv"
:
return
SystemEnv
(
Path
(
sys
.
prefix
),
cls
.
get_base_prefix
())
"""
Retrieve the current Python environment.
This can be the base Python environment or an activated virtual environment.
This method also workaround the issue that the virtual environment
used by Poetry internally (when installed via the custom installer)
is incorrectly detected as the system environment. Note that this workaround
happens only when `naive` is False since there are times where we actually
want to retrieve Poetry's custom virtual environment
(e.g. plugin installation or self update).
"""
prefix
,
base_prefix
=
Path
(
sys
.
prefix
),
cls
.
get_base_prefix
()
if
naive
is
False
:
from
poetry.locations
import
data_dir
try
:
prefix
.
relative_to
(
data_dir
())
except
ValueError
:
pass
else
:
prefix
=
base_prefix
return
SystemEnv
(
prefix
,
base_prefix
)
@classmethod
@classmethod
def
get_base_prefix
(
cls
)
->
Path
:
def
get_base_prefix
(
cls
)
->
Path
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment