Commit 1cabc09f by Sébastien Eustace

Add a --src option to new

parent 669b78c7
......@@ -8,6 +8,7 @@
- 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 a `--src` option to new to create an `src` layout.
### Changed
......
......@@ -8,6 +8,7 @@ class NewCommand(Command):
new
{ path : The path to create the project at. }
{ --name : Set the resulting package name. }
{ --src : Use the src layout for the project. }
"""
def handle(self):
......@@ -15,7 +16,10 @@ class NewCommand(Command):
from poetry.utils._compat import Path
from poetry.vcs.git import GitConfig
layout_ = layout('standard')
if self.option('src'):
layout_ = layout('src')
else:
layout_ = layout('standard')
path = Path.cwd() / Path(self.argument('path'))
name = self.option('name')
......
from typing import Type
from .layout import Layout
from .src import SrcLayout
from .standard import StandardLayout
_LAYOUTS = {
'standard': StandardLayout
'src': SrcLayout,
'standard': StandardLayout,
}
......
# -*- coding: utf-8 -*-
from .layout import Layout
DEFAULT = u"""__version__ = '{version}'
"""
class SrcLayout(Layout):
def _create_default(self, path):
package_path = path / 'src' / self._package_name
package_init = package_path / '__init__.py'
package_path.mkdir(parents=True)
with package_init.open('w') as f:
f.write(DEFAULT.format(version=self._version))
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