Commit aba6d170 by Sébastien Eustace

Add a new settings.virtualenvs.in-project setting

parent d99cb602
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
- Added a new, more efficient dependency resolver. - Added a new, more efficient dependency resolver.
- Added a new `init` command to generate a `pyproject.toml` file in existing projects. - Added a new `init` command to generate a `pyproject.toml` file in existing projects.
- Added a new setting `settings.virtualenvs.in-project` to make `poetry` create the project's virtualenv inside the project's directory.
- Added the `--extras` and `--python` options to `debug:resolve` to help debug dependency resolution. - Added the `--extras` and `--python` options to `debug:resolve` to help debug dependency resolution.
### Changed ### Changed
......
...@@ -101,6 +101,7 @@ To remove a repository (repo is a short alias for repositories): ...@@ -101,6 +101,7 @@ To remove a repository (repo is a short alias for repositories):
unique_config_values = { unique_config_values = {
'settings.virtualenvs.create': (boolean_validator, boolean_normalizer), 'settings.virtualenvs.create': (boolean_validator, boolean_normalizer),
'settings.virtualenvs.in-project': (boolean_validator, boolean_normalizer),
'settings.pypi.fallback': (boolean_validator, boolean_normalizer), 'settings.pypi.fallback': (boolean_validator, boolean_normalizer),
} }
......
...@@ -60,9 +60,15 @@ class Venv(object): ...@@ -60,9 +60,15 @@ class Venv(object):
config = Config.create('config.toml') config = Config.create('config.toml')
create_venv = config.setting('settings.virtualenvs.create') create_venv = config.setting('settings.virtualenvs.create')
root_venv = config.setting('settings.virtualenvs.in-project')
venv_path = config.setting('settings.virtualenvs.path') venv_path = config.setting('settings.virtualenvs.path')
if venv_path is None: if root_venv:
if not cwd:
raise RuntimeError('Unbale to determine the project\'s directory')
venv_path = (cwd / '.venv')
elif venv_path is None:
venv_path = Path(CACHE_DIR) / 'virtualenvs' venv_path = Path(CACHE_DIR) / 'virtualenvs'
else: else:
venv_path = Path(venv_path) venv_path = Path(venv_path)
...@@ -74,7 +80,11 @@ class Venv(object): ...@@ -74,7 +80,11 @@ class Venv(object):
name, '.'.join([str(v) for v in sys.version_info[:2]]) name, '.'.join([str(v) for v in sys.version_info[:2]])
) )
if root_venv:
venv = venv_path
else:
venv = venv_path / name venv = venv_path / name
if not venv.exists(): if not venv.exists():
if create_venv is False: if create_venv is False:
io.writeln( io.writeln(
......
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