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
d02c71cf
Commit
d02c71cf
authored
Nov 06, 2022
by
finswimmer
Committed by
Bjorn Neergaard
Nov 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: take `virtualenvs.prefer-active-python` into account when getting current environment
parent
78b3b551
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletions
+22
-1
src/poetry/utils/env.py
+22
-1
No files found.
src/poetry/utils/env.py
View file @
d02c71cf
...
@@ -20,6 +20,7 @@ from pathlib import Path
...
@@ -20,6 +20,7 @@ from pathlib import Path
from
subprocess
import
CalledProcessError
from
subprocess
import
CalledProcessError
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
typing
import
Any
from
typing
import
Any
from
typing
import
cast
import
packaging.tags
import
packaging.tags
import
tomlkit
import
tomlkit
...
@@ -556,6 +557,26 @@ class EnvManager:
...
@@ -556,6 +557,26 @@ class EnvManager:
)
)
return
executable
return
executable
def
_get_python_version
(
self
)
->
tuple
[
int
,
int
,
int
]:
version_info
=
tuple
(
sys
.
version_info
[:
3
])
if
self
.
_poetry
.
config
.
get
(
"virtualenvs.prefer-active-python"
):
executable
=
self
.
_detect_active_python
()
if
executable
:
python_patch
=
decode
(
subprocess
.
check_output
(
list_to_shell_command
(
[
executable
,
"-c"
,
GET_PYTHON_VERSION_ONELINER
]
),
shell
=
True
,
)
.
strip
()
)
version_info
=
tuple
(
int
(
v
)
for
v
in
python_patch
.
split
(
"."
)[:
3
])
return
cast
(
"tuple[int, int, int]"
,
version_info
)
def
activate
(
self
,
python
:
str
)
->
Env
:
def
activate
(
self
,
python
:
str
)
->
Env
:
venv_path
=
self
.
_poetry
.
config
.
virtualenvs_path
venv_path
=
self
.
_poetry
.
config
.
virtualenvs_path
cwd
=
self
.
_poetry
.
file
.
parent
cwd
=
self
.
_poetry
.
file
.
parent
...
@@ -667,7 +688,7 @@ class EnvManager:
...
@@ -667,7 +688,7 @@ class EnvManager:
if
self
.
_env
is
not
None
and
not
reload
:
if
self
.
_env
is
not
None
and
not
reload
:
return
self
.
_env
return
self
.
_env
python_minor
=
"."
.
join
([
str
(
v
)
for
v
in
s
ys
.
version_info
[:
2
]])
python_minor
=
"."
.
join
([
str
(
v
)
for
v
in
s
elf
.
_get_python_version
()
[:
2
]])
venv_path
=
self
.
_poetry
.
config
.
virtualenvs_path
venv_path
=
self
.
_poetry
.
config
.
virtualenvs_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