Commit 48ed586b by Sébastien Eustace

Make install installs the current project in editable mode

develop is now deprecated
parent c2d9a6b8
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
- Improved virtualenv detection and management. - Improved virtualenv detection and management.
- Wildcard `python` dependencies are now equivalent to `~2.7 || ^3.4`. - Wildcard `python` dependencies are now equivalent to `~2.7 || ^3.4`.
- Changed behavior of the resolver for conditional dependencies. - Changed behavior of the resolver for conditional dependencies.
- The `install` command will now install the current project in editable mode.
- The `develop` command is now deprecated in favor of `install`.
- Improved the `check` command. - Improved the `check` command.
### Fixed ### Fixed
......
import os
from .env_command import EnvCommand from .env_command import EnvCommand
class DevelopCommand(EnvCommand): class DevelopCommand(EnvCommand):
""" """
Installs the current project in development mode. Installs the current project in development mode. (<error>Deprecated</error>)
develop develop
""" """
help = """\ help = """\
The <info>develop</info> command installs the current project in development mode. The <info>develop</> command is deprecated. Please use <info>install</info> instead.
""" """
def handle(self): def handle(self):
from poetry.masonry.builders import SdistBuilder self.line("<warning>develop is deprecated use install instead.</warning>")
from poetry.io import NullIO self.line("")
from poetry.utils._compat import decode
from poetry.utils.env import NullEnv
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, NullEnv(), 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( return self.call("install")
"Installing <info>{}</info> (<comment>{}</comment>)".format(
self.poetry.package.pretty_name, self.poetry.package.pretty_version
)
)
self.env.run("pip", "install", "-e", str(setup.parent), "--no-deps")
import os
from .env_command import EnvCommand from .env_command import EnvCommand
...@@ -25,6 +27,10 @@ exist it will look for <comment>pyproject.toml</> and do the same. ...@@ -25,6 +27,10 @@ exist it will look for <comment>pyproject.toml</> and do the same.
def handle(self): def handle(self):
from poetry.installation import Installer from poetry.installation import Installer
from poetry.io import NullIO
from poetry.masonry.builders import SdistBuilder
from poetry.utils._compat import decode
from poetry.utils.env import NullEnv
installer = Installer( installer = Installer(
self.output, self.output,
...@@ -47,4 +53,29 @@ exist it will look for <comment>pyproject.toml</> and do the same. ...@@ -47,4 +53,29 @@ exist it will look for <comment>pyproject.toml</> and do the same.
installer.dry_run(self.option("dry-run")) installer.dry_run(self.option("dry-run"))
installer.verbose(self.option("verbose")) installer.verbose(self.option("verbose"))
return installer.run() return_code = installer.run()
if return_code != 0:
return return_code
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, NullEnv(), NullIO())
with setup.open("w") as f:
f.write(decode(builder.build_setup()))
self.line(
"Installing <info>{}</info> (<comment>{}</comment>)".format(
self.poetry.package.pretty_name, self.poetry.package.pretty_version
)
)
try:
self.env.run("pip", "install", "-e", str(setup.parent), "--no-deps")
finally:
if not has_setup:
os.remove(str(setup))
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