Commit 2045fb41 by Sébastien Eustace

Add a develop command

parent 9b7e594d
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
- Added the `--python` option to the `add` command. - Added the `--python` option to the `add` command.
- Added the `--platform` option to the `add` command. - Added the `--platform` option to the `add` command.
- Added a `--develop` option to the install command to install path dependencies in development/editable mode. - Added a `--develop` option to the install command to install path dependencies in development/editable mode.
- Added a `develop` command to install the current project in development mode.
### Changed ### Changed
......
...@@ -18,6 +18,7 @@ from .commands import AddCommand ...@@ -18,6 +18,7 @@ from .commands import AddCommand
from .commands import BuildCommand from .commands import BuildCommand
from .commands import CheckCommand from .commands import CheckCommand
from .commands import ConfigCommand from .commands import ConfigCommand
from .commands import DevelopCommand
from .commands import InitCommand from .commands import InitCommand
from .commands import InstallCommand from .commands import InstallCommand
from .commands import LockCommand from .commands import LockCommand
...@@ -107,6 +108,7 @@ class Application(BaseApplication): ...@@ -107,6 +108,7 @@ class Application(BaseApplication):
BuildCommand(), BuildCommand(),
CheckCommand(), CheckCommand(),
ConfigCommand(), ConfigCommand(),
DevelopCommand(),
InitCommand(), InitCommand(),
InstallCommand(), InstallCommand(),
LockCommand(), LockCommand(),
......
...@@ -3,6 +3,7 @@ from .add import AddCommand ...@@ -3,6 +3,7 @@ from .add import AddCommand
from .build import BuildCommand from .build import BuildCommand
from .check import CheckCommand from .check import CheckCommand
from .config import ConfigCommand from .config import ConfigCommand
from .develop import DevelopCommand
from .init import InitCommand from .init import InitCommand
from .install import InstallCommand from .install import InstallCommand
from .lock import LockCommand from .lock import LockCommand
......
import os
from .venv_command import VenvCommand
class DevelopCommand(VenvCommand):
"""
Installs the current project in development mode.
develop
"""
help = """\
The <info>develop</info> command installs the current project in development mode.
"""
def handle(self):
from poetry.masonry.builders import SdistBuilder
from poetry.io import NullIO
from poetry.utils._compat import decode
from poetry.utils.venv import NullVenv
setup = self.poetry.file.parent / 'setup.py'
has_setup = setup.exists()
if has_setup:
self.line('<warning>A setup.py file already exists. Using it.</warning>')
else:
builder = SdistBuilder(self.poetry, NullVenv(), NullIO())
with setup.open('w') as f:
f.write(decode(builder.build_setup()))
try:
self._install(setup)
finally:
if not has_setup:
os.remove(str(setup))
def _install(self, setup):
self.call('install')
self.line(
'Installing <info>{}</info> (<comment>{}</comment>)'.format(
self.poetry.package.pretty_name,
self.poetry.package.pretty_version
)
)
self.venv.run('pip', 'install', '-e', str(setup.parent), '--no-deps')
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