Commit 1cabc09f by Sébastien Eustace

Add a --src option to new

parent 669b78c7
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
- 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 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.
- Added a `--src` option to new to create an `src` layout.
### Changed ### Changed
......
...@@ -8,6 +8,7 @@ class NewCommand(Command): ...@@ -8,6 +8,7 @@ class NewCommand(Command):
new new
{ path : The path to create the project at. } { path : The path to create the project at. }
{ --name : Set the resulting package name. } { --name : Set the resulting package name. }
{ --src : Use the src layout for the project. }
""" """
def handle(self): def handle(self):
...@@ -15,6 +16,9 @@ class NewCommand(Command): ...@@ -15,6 +16,9 @@ class NewCommand(Command):
from poetry.utils._compat import Path from poetry.utils._compat import Path
from poetry.vcs.git import GitConfig from poetry.vcs.git import GitConfig
if self.option('src'):
layout_ = layout('src')
else:
layout_ = layout('standard') layout_ = layout('standard')
path = Path.cwd() / Path(self.argument('path')) path = Path.cwd() / Path(self.argument('path'))
......
from typing import Type from typing import Type
from .layout import Layout from .layout import Layout
from .src import SrcLayout
from .standard import StandardLayout from .standard import StandardLayout
_LAYOUTS = { _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