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
06fcff08
Commit
06fcff08
authored
Jan 22, 2022
by
finswimmer
Committed by
Bjorn Neergaard
Jan 23, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get fullpath of given python executable when activating env
parent
b70d2602
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
15 deletions
+29
-15
src/poetry/utils/env.py
+18
-8
tests/console/commands/env/helpers.py
+2
-0
tests/console/commands/env/test_use.py
+1
-1
tests/utils/test_env.py
+8
-6
No files found.
src/poetry/utils/env.py
View file @
06fcff08
...
@@ -465,6 +465,21 @@ class EnvManager:
...
@@ -465,6 +465,21 @@ class EnvManager:
def
__init__
(
self
,
poetry
:
"Poetry"
)
->
None
:
def
__init__
(
self
,
poetry
:
"Poetry"
)
->
None
:
self
.
_poetry
=
poetry
self
.
_poetry
=
poetry
def
_full_python_path
(
self
,
python
:
str
)
->
str
:
try
:
executable
=
decode
(
subprocess
.
check_output
(
list_to_shell_command
(
[
python
,
"-c"
,
'"import sys; print(sys.executable)"'
]
),
shell
=
True
,
)
.
strip
()
)
except
CalledProcessError
as
e
:
raise
EnvCommandError
(
e
)
return
executable
def
_detect_active_python
(
self
,
io
:
"IO"
)
->
str
:
def
_detect_active_python
(
self
,
io
:
"IO"
)
->
str
:
executable
=
None
executable
=
None
...
@@ -474,14 +489,7 @@ class EnvManager:
...
@@ -474,14 +489,7 @@ class EnvManager:
" config."
,
" config."
,
verbosity
=
Verbosity
.
VERBOSE
,
verbosity
=
Verbosity
.
VERBOSE
,
)
)
executable
=
decode
(
executable
=
self
.
_full_python_path
(
"python"
)
subprocess
.
check_output
(
list_to_shell_command
(
[
"python"
,
"-c"
,
'"import sys; print(sys.executable)"'
]
),
shell
=
True
,
)
.
strip
()
)
io
.
write_line
(
f
"Found: {executable}"
,
verbosity
=
Verbosity
.
VERBOSE
)
io
.
write_line
(
f
"Found: {executable}"
,
verbosity
=
Verbosity
.
VERBOSE
)
except
CalledProcessError
:
except
CalledProcessError
:
io
.
write_line
(
io
.
write_line
(
...
@@ -511,6 +519,8 @@ class EnvManager:
...
@@ -511,6 +519,8 @@ class EnvManager:
# Executable in PATH or full executable path
# Executable in PATH or full executable path
pass
pass
python
=
self
.
_full_python_path
(
python
)
try
:
try
:
python_version
=
decode
(
python_version
=
decode
(
subprocess
.
check_output
(
subprocess
.
check_output
(
...
...
tests/console/commands/env/helpers.py
View file @
06fcff08
...
@@ -25,6 +25,8 @@ def check_output_wrapper(
...
@@ -25,6 +25,8 @@ def check_output_wrapper(
return
version
.
text
return
version
.
text
elif
"sys.version_info[:2]"
in
cmd
:
elif
"sys.version_info[:2]"
in
cmd
:
return
f
"{version.major}.{version.minor}"
return
f
"{version.major}.{version.minor}"
elif
'-c "import sys; print(sys.executable)"'
in
cmd
:
return
f
"/usr/bin/{cmd.split()[0]}"
else
:
else
:
return
str
(
Path
(
"/prefix"
))
return
str
(
Path
(
"/prefix"
))
...
...
tests/console/commands/env/test_use.py
View file @
06fcff08
...
@@ -69,7 +69,7 @@ def test_activate_activates_non_existing_virtualenv_no_envs_file(
...
@@ -69,7 +69,7 @@ def test_activate_activates_non_existing_virtualenv_no_envs_file(
venv_py37
=
venv_cache
/
f
"{venv_name}-py3.7"
venv_py37
=
venv_cache
/
f
"{venv_name}-py3.7"
mock_build_env
.
assert_called_with
(
mock_build_env
.
assert_called_with
(
venv_py37
,
venv_py37
,
executable
=
"python3.7"
,
executable
=
"
/usr/bin/
python3.7"
,
flags
=
{
"always-copy"
:
False
,
"system-site-packages"
:
False
},
flags
=
{
"always-copy"
:
False
,
"system-site-packages"
:
False
},
with_pip
=
True
,
with_pip
=
True
,
with_setuptools
=
True
,
with_setuptools
=
True
,
...
...
tests/utils/test_env.py
View file @
06fcff08
...
@@ -154,12 +154,14 @@ VERSION_3_7_1 = Version.parse("3.7.1")
...
@@ -154,12 +154,14 @@ VERSION_3_7_1 = Version.parse("3.7.1")
def
check_output_wrapper
(
def
check_output_wrapper
(
version
:
Version
=
VERSION_3_7_1
,
version
:
Version
=
VERSION_3_7_1
,
)
->
Callable
[[
List
[
str
]
,
Any
,
Any
],
str
]:
)
->
Callable
[[
str
,
Any
,
Any
],
str
]:
def
check_output
(
cmd
:
List
[
str
]
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
str
:
def
check_output
(
cmd
:
str
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
str
:
if
"sys.version_info[:3]"
in
cmd
:
if
"sys.version_info[:3]"
in
cmd
:
return
version
.
text
return
version
.
text
elif
"sys.version_info[:2]"
in
cmd
:
elif
"sys.version_info[:2]"
in
cmd
:
return
f
"{version.major}.{version.minor}"
return
f
"{version.major}.{version.minor}"
elif
'-c "import sys; print(sys.executable)"'
in
cmd
:
return
f
"/usr/bin/{cmd.split()[0]}"
else
:
else
:
return
str
(
Path
(
"/prefix"
))
return
str
(
Path
(
"/prefix"
))
...
@@ -193,7 +195,7 @@ def test_activate_activates_non_existing_virtualenv_no_envs_file(
...
@@ -193,7 +195,7 @@ def test_activate_activates_non_existing_virtualenv_no_envs_file(
m
.
assert_called_with
(
m
.
assert_called_with
(
Path
(
tmp_dir
)
/
f
"{venv_name}-py3.7"
,
Path
(
tmp_dir
)
/
f
"{venv_name}-py3.7"
,
executable
=
"python3.7"
,
executable
=
"
/usr/bin/
python3.7"
,
flags
=
{
"always-copy"
:
False
,
"system-site-packages"
:
False
},
flags
=
{
"always-copy"
:
False
,
"system-site-packages"
:
False
},
with_pip
=
True
,
with_pip
=
True
,
with_setuptools
=
True
,
with_setuptools
=
True
,
...
@@ -328,7 +330,7 @@ def test_activate_activates_different_virtualenv_with_envs_file(
...
@@ -328,7 +330,7 @@ def test_activate_activates_different_virtualenv_with_envs_file(
m
.
assert_called_with
(
m
.
assert_called_with
(
Path
(
tmp_dir
)
/
f
"{venv_name}-py3.6"
,
Path
(
tmp_dir
)
/
f
"{venv_name}-py3.6"
,
executable
=
"python3.6"
,
executable
=
"
/usr/bin/
python3.6"
,
flags
=
{
"always-copy"
:
False
,
"system-site-packages"
:
False
},
flags
=
{
"always-copy"
:
False
,
"system-site-packages"
:
False
},
with_pip
=
True
,
with_pip
=
True
,
with_setuptools
=
True
,
with_setuptools
=
True
,
...
@@ -389,7 +391,7 @@ def test_activate_activates_recreates_for_different_patch(
...
@@ -389,7 +391,7 @@ def test_activate_activates_recreates_for_different_patch(
build_venv_m
.
assert_called_with
(
build_venv_m
.
assert_called_with
(
Path
(
tmp_dir
)
/
f
"{venv_name}-py3.7"
,
Path
(
tmp_dir
)
/
f
"{venv_name}-py3.7"
,
executable
=
"python3.7"
,
executable
=
"
/usr/bin/
python3.7"
,
flags
=
{
"always-copy"
:
False
,
"system-site-packages"
:
False
},
flags
=
{
"always-copy"
:
False
,
"system-site-packages"
:
False
},
with_pip
=
True
,
with_pip
=
True
,
with_setuptools
=
True
,
with_setuptools
=
True
,
...
@@ -1022,7 +1024,7 @@ def test_activate_with_in_project_setting_does_not_fail_if_no_venvs_dir(
...
@@ -1022,7 +1024,7 @@ def test_activate_with_in_project_setting_does_not_fail_if_no_venvs_dir(
m
.
assert_called_with
(
m
.
assert_called_with
(
poetry
.
file
.
parent
/
".venv"
,
poetry
.
file
.
parent
/
".venv"
,
executable
=
"python3.7"
,
executable
=
"
/usr/bin/
python3.7"
,
flags
=
{
"always-copy"
:
False
,
"system-site-packages"
:
False
},
flags
=
{
"always-copy"
:
False
,
"system-site-packages"
:
False
},
with_pip
=
True
,
with_pip
=
True
,
with_setuptools
=
True
,
with_setuptools
=
True
,
...
...
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