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
c349357b
Unverified
Commit
c349357b
authored
Dec 06, 2019
by
Sébastien Eustace
Committed by
GitHub
Dec 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix an error in env use if the virtualenvs.in-project setting is activated (#1682)
parent
c78503e5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
poetry/utils/env.py
+18
-0
tests/utils/test_env.py
+35
-0
No files found.
poetry/utils/env.py
View file @
c349357b
...
...
@@ -208,6 +208,24 @@ class EnvManager(object):
patch
=
python_version
.
text
create
=
False
is_root_venv
=
self
.
_poetry
.
config
.
get
(
"virtualenvs.in-project"
)
# If we are required to create the virtual environment in the root folder,
# create or recreate it if needed
if
is_root_venv
:
create
=
False
venv
=
self
.
_poetry
.
file
.
parent
/
".venv"
if
venv
.
exists
():
# We need to check if the patch version is correct
_venv
=
VirtualEnv
(
venv
)
current_patch
=
"."
.
join
(
str
(
v
)
for
v
in
_venv
.
version_info
[:
3
])
if
patch
!=
current_patch
:
create
=
True
self
.
create_venv
(
io
,
executable
=
python
,
force
=
create
)
return
self
.
get
(
reload
=
True
)
envs
=
tomlkit
.
document
()
base_env_name
=
self
.
generate_env_name
(
self
.
_poetry
.
package
.
name
,
str
(
cwd
))
if
envs_file
.
exists
():
...
...
tests/utils/test_env.py
View file @
c349357b
...
...
@@ -661,3 +661,38 @@ def test_create_venv_does_not_try_to_find_compatible_versions_with_executable(
assert
expected_message
==
str
(
e
.
value
)
assert
0
==
m
.
call_count
def
test_activate_with_in_project_setting_does_not_fail_if_no_venvs_dir
(
manager
,
poetry
,
config
,
tmp_dir
,
mocker
):
if
"VIRTUAL_ENV"
in
os
.
environ
:
del
os
.
environ
[
"VIRTUAL_ENV"
]
config
.
merge
(
{
"virtualenvs"
:
{
"path"
:
str
(
Path
(
tmp_dir
)
/
"virtualenvs"
),
"in-project"
:
True
,
}
}
)
mocker
.
patch
(
"poetry.utils._compat.subprocess.check_output"
,
side_effect
=
check_output_wrapper
(),
)
mocker
.
patch
(
"poetry.utils._compat.subprocess.Popen.communicate"
,
side_effect
=
[(
"/prefix"
,
None
),
(
"/prefix"
,
None
)],
)
m
=
mocker
.
patch
(
"poetry.utils.env.EnvManager.build_venv"
)
manager
.
activate
(
"python3.7"
,
NullIO
())
m
.
assert_called_with
(
os
.
path
.
join
(
str
(
poetry
.
file
.
parent
),
".venv"
),
executable
=
"python3.7"
)
envs_file
=
TomlFile
(
Path
(
tmp_dir
)
/
"virtualenvs"
/
"envs.toml"
)
assert
not
envs_file
.
exists
()
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