Commit 74614a45 by Sébastien Eustace

Add support for .venv virtualenvs

parent c154fc24
...@@ -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
......
...@@ -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(
......
...@@ -47,10 +47,16 @@ class Venv(object): ...@@ -47,10 +47,16 @@ 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
# First we check if there is a .venv
# at the root of the project.
if cwd and (cwd / '.venv').exists():
venv = cwd / '.venv'
else:
config = Config.create('config.toml') config = Config.create('config.toml')
create_venv = config.setting('settings.virtualenvs.create') create_venv = config.setting('settings.virtualenvs.create')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment