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
a2e2c652
Unverified
Commit
a2e2c652
authored
Sep 13, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix env detection
parent
473156ba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
11 deletions
+44
-11
poetry/utils/env.py
+44
-11
No files found.
poetry/utils/env.py
View file @
a2e2c652
...
@@ -97,16 +97,18 @@ class Env(object):
...
@@ -97,16 +97,18 @@ class Env(object):
if
cwd
and
(
cwd
/
".venv"
)
.
exists
():
if
cwd
and
(
cwd
/
".venv"
)
.
exists
():
venv
=
cwd
/
".venv"
venv
=
cwd
/
".venv"
return
VirtualEnv
(
return
VirtualEnv
(
Path
(
venv
))
Path
(
venv
),
Path
(
getattr
(
sys
,
"base_prefix"
,
sys
.
prefix
))
)
return
SystemEnv
(
Path
(
sys
.
prefix
))
return
SystemEnv
(
Path
(
sys
.
prefix
))
return
VirtualEnv
(
if
os
.
environ
.
get
(
"VIRTUAL_ENV"
)
is
not
None
:
Path
(
getattr
(
sys
,
"real_prefix"
,
sys
.
prefix
)),
prefix
=
Path
(
os
.
environ
[
"VIRTUAL_ENV"
])
Path
(
getattr
(
sys
,
"base_prefix"
,
sys
.
prefix
)),
base_prefix
=
None
)
else
:
prefix
=
sys
.
prefix
base_prefix
=
cls
.
get_base_prefix
()
return
VirtualEnv
(
prefix
,
base_prefix
)
@classmethod
@classmethod
def
create_venv
(
cls
,
io
,
name
=
None
,
cwd
=
None
):
# type: (IO, bool, Path) -> Env
def
create_venv
(
cls
,
io
,
name
=
None
,
cwd
=
None
):
# type: (IO, bool, Path) -> Env
...
@@ -178,11 +180,9 @@ class Env(object):
...
@@ -178,11 +180,9 @@ class Env(object):
p_venv
=
os
.
path
.
normcase
(
str
(
venv
))
p_venv
=
os
.
path
.
normcase
(
str
(
venv
))
if
any
(
p
.
startswith
(
p_venv
)
for
p
in
paths
):
if
any
(
p
.
startswith
(
p_venv
)
for
p
in
paths
):
# Running properly in the virtualenv, don't need to do anything
# Running properly in the virtualenv, don't need to do anything
return
SystemEnv
(
return
SystemEnv
(
Path
(
sys
.
prefix
),
cls
.
get_base_prefix
())
Path
(
sys
.
prefix
),
Path
(
getattr
(
sys
,
"base_prefix"
,
sys
.
prefix
))
)
return
VirtualEnv
(
venv
,
Path
(
getattr
(
sys
,
"base_prefix"
,
sys
.
prefix
))
)
return
VirtualEnv
(
venv
)
@classmethod
@classmethod
def
build_venv
(
cls
,
path
):
def
build_venv
(
cls
,
path
):
...
@@ -199,6 +199,15 @@ class Env(object):
...
@@ -199,6 +199,15 @@ class Env(object):
build
(
path
)
build
(
path
)
def
get_base_prefix
(
self
):
# type: () -> Path
if
hasattr
(
sys
,
"real_prefix"
):
return
sys
.
real_prefix
if
hasattr
(
sys
,
"base_prefix"
):
return
sys
.
base_prefix
return
sys
.
prefix
def
get_version_info
(
self
):
# type: () -> Tuple[int]
def
get_version_info
(
self
):
# type: () -> Tuple[int]
raise
NotImplementedError
()
raise
NotImplementedError
()
...
@@ -284,6 +293,30 @@ class VirtualEnv(Env):
...
@@ -284,6 +293,30 @@ class VirtualEnv(Env):
A virtual Python environment.
A virtual Python environment.
"""
"""
def
__init__
(
self
,
path
,
base
=
None
):
# type: (Path, Optional[Path]) -> None
super
(
VirtualEnv
,
self
)
.
__init__
(
path
,
base
)
# If base is None, it probably means this is
# a virtualenv created from VIRTUAL_ENV.
# In this case we need to get sys.base_prefix
# from inside the virtualenv.
if
base
is
None
:
self
.
_base
=
Path
(
self
.
run
(
"python"
,
"-c"
,
'"import sys; '
"print("
" getattr("
" sys,"
" 'real_prefix', "
" getattr(sys, 'base_prefix', sys.prefix)"
" )"
')"'
,
shell
=
True
,
)
)
def
get_version_info
(
self
):
# type: () -> Tuple[int]
def
get_version_info
(
self
):
# type: () -> Tuple[int]
output
=
self
.
run
(
output
=
self
.
run
(
"python"
,
"python"
,
...
...
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