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
6987aaa8
Unverified
Commit
6987aaa8
authored
Dec 14, 2019
by
Sébastien Eustace
Committed by
GitHub
Dec 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the python patch version retrieval when passing an executable (#1736)
Fixes #1735
parent
a7792f6a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
3 deletions
+43
-3
poetry/utils/env.py
+4
-3
tests/utils/test_env.py
+39
-0
No files found.
poetry/utils/env.py
View file @
6987aaa8
...
@@ -494,18 +494,19 @@ class EnvManager(object):
...
@@ -494,18 +494,19 @@ class EnvManager(object):
python_patch
=
"."
.
join
([
str
(
v
)
for
v
in
sys
.
version_info
[:
3
]])
python_patch
=
"."
.
join
([
str
(
v
)
for
v
in
sys
.
version_info
[:
3
]])
python_minor
=
"."
.
join
([
str
(
v
)
for
v
in
sys
.
version_info
[:
2
]])
python_minor
=
"."
.
join
([
str
(
v
)
for
v
in
sys
.
version_info
[:
2
]])
if
executable
:
if
executable
:
python_
minor
=
decode
(
python_
patch
=
decode
(
subprocess
.
check_output
(
subprocess
.
check_output
(
" "
.
join
(
" "
.
join
(
[
[
executable
,
executable
,
"-c"
,
"-c"
,
"
\"
import sys; print('.'.join([str(s) for s in sys.version_info[:
2
]]))
\"
"
,
"
\"
import sys; print('.'.join([str(s) for s in sys.version_info[:
3
]]))
\"
"
,
]
]
),
),
shell
=
True
,
shell
=
True
,
)
.
strip
()
)
.
strip
()
)
)
python_minor
=
"."
.
join
(
python_patch
.
split
(
"."
)[:
2
])
supported_python
=
self
.
_poetry
.
package
.
python_constraint
supported_python
=
self
.
_poetry
.
package
.
python_constraint
if
not
supported_python
.
allows
(
Version
.
parse
(
python_patch
)):
if
not
supported_python
.
allows
(
Version
.
parse
(
python_patch
)):
...
@@ -517,7 +518,7 @@ class EnvManager(object):
...
@@ -517,7 +518,7 @@ class EnvManager(object):
# Otherwise, we try to find a compatible Python version.
# Otherwise, we try to find a compatible Python version.
if
executable
:
if
executable
:
raise
NoCompatiblePythonVersionFound
(
raise
NoCompatiblePythonVersionFound
(
self
.
_poetry
.
package
.
python_versions
,
python_
minor
self
.
_poetry
.
package
.
python_versions
,
python_
patch
)
)
io
.
write_line
(
io
.
write_line
(
...
...
tests/utils/test_env.py
View file @
6987aaa8
...
@@ -700,6 +700,45 @@ def test_create_venv_uses_patch_version_to_detect_compatibility(
...
@@ -700,6 +700,45 @@ def test_create_venv_uses_patch_version_to_detect_compatibility(
)
)
def
test_create_venv_uses_patch_version_to_detect_compatibility_with_executable
(
manager
,
poetry
,
config
,
mocker
):
if
"VIRTUAL_ENV"
in
os
.
environ
:
del
os
.
environ
[
"VIRTUAL_ENV"
]
version
=
Version
.
parse
(
"."
.
join
(
str
(
c
)
for
c
in
sys
.
version_info
[:
3
]))
poetry
.
package
.
python_versions
=
"~{}"
.
format
(
"."
.
join
(
str
(
c
)
for
c
in
(
version
.
major
,
version
.
minor
-
1
,
0
))
)
venv_name
=
manager
.
generate_env_name
(
"simple-project"
,
str
(
poetry
.
file
.
parent
))
check_output
=
mocker
.
patch
(
"poetry.utils._compat.subprocess.check_output"
,
side_effect
=
check_output_wrapper
(
Version
.
parse
(
"{}.{}.0"
.
format
(
version
.
major
,
version
.
minor
-
1
))
),
)
m
=
mocker
.
patch
(
"poetry.utils.env.EnvManager.build_venv"
,
side_effect
=
lambda
*
args
,
**
kwargs
:
""
)
manager
.
create_venv
(
NullIO
(),
executable
=
"python{}.{}"
.
format
(
version
.
major
,
version
.
minor
-
1
)
)
assert
check_output
.
called
m
.
assert_called_with
(
str
(
Path
(
"/foo/virtualenvs/{}-py{}.{}"
.
format
(
venv_name
,
version
.
major
,
version
.
minor
-
1
)
)
),
executable
=
"python{}.{}"
.
format
(
version
.
major
,
version
.
minor
-
1
),
)
def
test_activate_with_in_project_setting_does_not_fail_if_no_venvs_dir
(
def
test_activate_with_in_project_setting_does_not_fail_if_no_venvs_dir
(
manager
,
poetry
,
config
,
tmp_dir
,
mocker
manager
,
poetry
,
config
,
tmp_dir
,
mocker
):
):
...
...
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