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
74614a45
Unverified
Commit
74614a45
authored
May 02, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for .venv virtualenvs
parent
c154fc24
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
33 deletions
+43
-33
CHANGELOG.md
+1
-0
poetry/console/commands/venv_command.py
+4
-1
poetry/utils/venv.py
+38
-32
No files found.
CHANGELOG.md
View file @
74614a45
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
-
Added support for
`git`
dependencies in the
`add`
command.
-
Added support for
`git`
dependencies in the
`add`
command.
-
Added support for
`file`
dependencies in the
`add`
command.
-
Added support for
`file`
dependencies in the
`add`
command.
-
Added support for
`src/`
layout for packages.
-
Added support for
`src/`
layout for packages.
-
Added automatic detection of
`.venv`
virtualenvs.
### Changed
### Changed
...
...
poetry/console/commands/venv_command.py
View file @
74614a45
...
@@ -13,7 +13,10 @@ class VenvCommand(Command):
...
@@ -13,7 +13,10 @@ class VenvCommand(Command):
super
(
VenvCommand
,
self
)
.
initialize
(
i
,
o
)
super
(
VenvCommand
,
self
)
.
initialize
(
i
,
o
)
self
.
_venv
=
Venv
.
create
(
o
,
self
.
poetry
.
package
.
name
)
self
.
_venv
=
Venv
.
create
(
o
,
self
.
poetry
.
package
.
name
,
cwd
=
self
.
poetry
.
file
.
parent
)
if
self
.
_venv
.
is_venv
()
and
o
.
is_verbose
():
if
self
.
_venv
.
is_venv
()
and
o
.
is_verbose
():
o
.
writeln
(
o
.
writeln
(
...
...
poetry/utils/venv.py
View file @
74614a45
...
@@ -47,52 +47,58 @@ class Venv(object):
...
@@ -47,52 +47,58 @@ class Venv(object):
self
.
_python_implementation
=
None
self
.
_python_implementation
=
None
@classmethod
@classmethod
def
create
(
cls
,
io
,
name
=
None
):
# type: (...) -> Venv
def
create
(
cls
,
io
,
name
=
None
,
cwd
=
None
):
# type: (...) -> Venv
if
'VIRTUAL_ENV'
not
in
os
.
environ
:
if
'VIRTUAL_ENV'
not
in
os
.
environ
:
# Not in a virtualenv
# Not in a virtualenv
# Checking if we need to create one
# Checking if we need to create one
config
=
Config
.
create
(
'config.toml'
)
create_venv
=
config
.
setting
(
'settings.virtualenvs.create'
)
# First we check if there is a .venv
# at the root of the project.
venv_path
=
config
.
setting
(
'settings.virtualenvs.path'
)
if
cwd
and
(
cwd
/
'.venv'
)
.
exists
():
if
venv_path
is
None
:
venv
=
cwd
/
'.venv'
venv_path
=
Path
(
CACHE_DIR
)
/
'virtualenvs'
else
:
else
:
venv_path
=
Path
(
venv_path
)
config
=
Config
.
create
(
'config.toml'
)
if
not
name
:
create_venv
=
config
.
setting
(
'settings.virtualenvs.create'
)
name
=
Path
.
cwd
()
.
name
name
=
'{}-py{}'
.
format
(
venv_path
=
config
.
setting
(
'settings.virtualenvs.path'
)
name
,
'.'
.
join
([
str
(
v
)
for
v
in
sys
.
version_info
[:
2
]])
if
venv_path
is
None
:
)
venv_path
=
Path
(
CACHE_DIR
)
/
'virtualenvs'
else
:
venv_path
=
Path
(
venv_path
)
venv
=
venv_path
/
name
if
not
name
:
if
not
venv
.
exists
():
name
=
Path
.
cwd
()
.
name
if
create_venv
is
False
:
io
.
writeln
(
'<fg=black;bg=yellow>'
'Skipping virtualenv creation, '
'as specified in config file.'
'</>'
)
return
cls
()
name
=
'{}-py{}'
.
format
(
name
,
'.'
.
join
([
str
(
v
)
for
v
in
sys
.
version_info
[:
2
]])
io
.
writeln
(
'Creating virtualenv <info>{}</> in {}'
.
format
(
name
,
str
(
venv_path
)
)
)
)
cls
.
build
(
str
(
venv
))
venv
=
venv_path
/
name
else
:
if
not
venv
.
exists
():
if
io
.
is_very_verbose
():
if
create_venv
is
False
:
io
.
writeln
(
'<fg=black;bg=yellow>'
'Skipping virtualenv creation, '
'as specified in config file.'
'</>'
)
return
cls
()
io
.
writeln
(
io
.
writeln
(
'Virtualenv <info>{}</> already exists.'
.
format
(
name
)
'Creating virtualenv <info>{}</> in {}'
.
format
(
name
,
str
(
venv_path
)
)
)
)
cls
.
build
(
str
(
venv
))
else
:
if
io
.
is_very_verbose
():
io
.
writeln
(
'Virtualenv <info>{}</> already exists.'
.
format
(
name
)
)
os
.
environ
[
'VIRTUAL_ENV'
]
=
str
(
venv
)
os
.
environ
[
'VIRTUAL_ENV'
]
=
str
(
venv
)
# venv detection:
# venv detection:
...
...
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