Commit 6646afe8 by Sébastien Eustace

Update README

parent 248b84ed
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
- Added support for specifying the `platform` for dependencies. - Added support for specifying the `platform` for dependencies.
- 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.
### Changed ### Changed
......
...@@ -10,6 +10,7 @@ class InstallCommand(VenvCommand): ...@@ -10,6 +10,7 @@ class InstallCommand(VenvCommand):
{ --dry-run : Outputs the operations but will not execute anything { --dry-run : Outputs the operations but will not execute anything
(implicitly enables --verbose). } (implicitly enables --verbose). }
{ --E|extras=* : Extra sets of dependencies to install. } { --E|extras=* : Extra sets of dependencies to install. }
{ --develop=* : Install given packages in development mode. }
""" """
help = """The <info>install</info> command reads the <comment>pyproject.toml</> file from help = """The <info>install</info> command reads the <comment>pyproject.toml</> file from
...@@ -37,6 +38,7 @@ exist it will look for <comment>pyproject.toml</> and do the same. ...@@ -37,6 +38,7 @@ exist it will look for <comment>pyproject.toml</> and do the same.
installer.extras(self.option('extras')) installer.extras(self.option('extras'))
installer.dev_mode(not self.option('no-dev')) installer.dev_mode(not self.option('no-dev'))
installer.develop(self.option('develop'))
installer.dry_run(self.option('dry-run')) installer.dry_run(self.option('dry-run'))
installer.verbose(self.option('verbose')) installer.verbose(self.option('verbose'))
......
...@@ -44,6 +44,7 @@ class Installer: ...@@ -44,6 +44,7 @@ class Installer:
self._verbose = False self._verbose = False
self._write_lock = True self._write_lock = True
self._dev_mode = True self._dev_mode = True
self._develop = []
self._execute_operations = True self._execute_operations = True
self._whitelist = {} self._whitelist = {}
...@@ -99,6 +100,11 @@ class Installer: ...@@ -99,6 +100,11 @@ class Installer:
def is_dev_mode(self): # type: () -> bool def is_dev_mode(self): # type: () -> bool
return self._dev_mode return self._dev_mode
def develop(self, packages): # type: (dict) -> Installer
self._develop = [canonicalize_name(p) for p in packages]
return self
def update(self, update=True): # type: (bool) -> Installer def update(self, update=True): # type: (bool) -> Installer
self._update = update self._update = update
...@@ -404,13 +410,16 @@ class Installer: ...@@ -404,13 +410,16 @@ class Installer:
installed, locked installed, locked
)) ))
if not is_installed: # If it's optional and not in required extras
# If it's optional and not in required extras # we do not install
# we do not install if locked.optional and locked.name not in extra_packages:
if locked.optional and locked.name not in extra_packages: continue
continue
op = Install(locked)
if is_installed:
op.skip('Already installed')
ops.append(Install(locked)) ops.append(op)
return ops return ops
...@@ -429,6 +438,11 @@ class Installer: ...@@ -429,6 +438,11 @@ class Installer:
if op.job_type == 'uninstall': if op.job_type == 'uninstall':
continue continue
if package.name in self._develop and package.source_type == 'directory':
package.develop = True
if op.skipped:
op.unskip()
python = Version.parse('.'.join([str(i) for i in self._venv.version_info[:3]])) python = Version.parse('.'.join([str(i) for i in self._venv.version_info[:3]]))
if 'python' in package.requirements: if 'python' in package.requirements:
python_constraint = parse_constraint( python_constraint = parse_constraint(
......
...@@ -39,7 +39,11 @@ class PipInstaller(BaseInstaller): ...@@ -39,7 +39,11 @@ class PipInstaller(BaseInstaller):
finally: finally:
os.unlink(req) os.unlink(req)
else: else:
args.append(self.requirement(package)) req = self.requirement(package)
if not isinstance(req, list):
args.append(req)
else:
args += req
self.run(*args) self.run(*args)
...@@ -69,7 +73,15 @@ class PipInstaller(BaseInstaller): ...@@ -69,7 +73,15 @@ class PipInstaller(BaseInstaller):
return req return req
if package.source_type in ['file', 'directory']: if package.source_type in ['file', 'directory']:
return os.path.realpath(package.source_reference) if package.root_dir:
req = os.path.join(package.root_dir, package.source_url)
else:
req = os.path.realpath(package.source_url)
if package.develop:
req = ['-e', req]
return req
if package.source_type == 'git': if package.source_type == 'git':
return 'git+{}@{}#egg={}'.format( return 'git+{}@{}#egg={}'.format(
......
...@@ -307,6 +307,10 @@ ...@@ -307,6 +307,10 @@
"items": { "items": {
"type": "string" "type": "string"
} }
},
"develop": {
"type": "boolean",
"description": "Whether to install the dependency in development mode."
} }
} }
}, },
......
...@@ -34,6 +34,7 @@ class DirectoryDependency(Dependency): ...@@ -34,6 +34,7 @@ class DirectoryDependency(Dependency):
develop=False # type: bool develop=False # type: bool
): ):
from . import dependency_from_pep_508 from . import dependency_from_pep_508
from .package import Package
self._path = path self._path = path
self._base = base self._base = base
...@@ -79,9 +80,13 @@ class DirectoryDependency(Dependency): ...@@ -79,9 +80,13 @@ class DirectoryDependency(Dependency):
with setup.open('w') as f: with setup.open('w') as f:
f.write(decode(builder.build_setup())) f.write(decode(builder.build_setup()))
self._package = poetry.package package = poetry.package
self._package = Package(package.pretty_name, package.version)
self._package.requires += package.requires
self._package.dev_requires += package.dev_requires
self._package.python_versions = package.python_versions
self._package.platform = package.platform
else: else:
from poetry.packages import Package
# Execute egg_info # Execute egg_info
current_dir = os.getcwd() current_dir = os.getcwd()
os.chdir(str(self._full_path)) os.chdir(str(self._full_path))
...@@ -129,7 +134,7 @@ class DirectoryDependency(Dependency): ...@@ -129,7 +134,7 @@ class DirectoryDependency(Dependency):
self._package = package self._package = package
self._package.source_type = 'directory' self._package.source_type = 'directory'
self._package.source_reference = str(self._path) self._package.source_url = str(self._path)
super(DirectoryDependency, self).__init__( super(DirectoryDependency, self).__init__(
self._package.name, self._package.name,
......
...@@ -94,6 +94,8 @@ class Package(object): ...@@ -94,6 +94,8 @@ class Package(object):
self.root_dir = None self.root_dir = None
self.develop = False
@property @property
def name(self): def name(self):
return self._name return self._name
......
...@@ -35,3 +35,9 @@ class Operation(object): ...@@ -35,3 +35,9 @@ class Operation(object):
self._skip_reason = reason self._skip_reason = reason
return self return self
def unskip(self): # type: () -> Operation
self._skipped = False
self._skip_reason = None
return self
...@@ -238,7 +238,7 @@ class Provider: ...@@ -238,7 +238,7 @@ class Provider:
): # type: (FileDependency) -> List[Package] ): # type: (FileDependency) -> List[Package]
package = Package(dependency.name, dependency.pretty_constraint) package = Package(dependency.name, dependency.pretty_constraint)
package.source_type = 'file' package.source_type = 'file'
package.source_reference = str(dependency.path) package.source_url = str(dependency.path)
package.description = dependency.metadata.summary package.description = dependency.metadata.summary
for req in dependency.metadata.requires_dist: for req in dependency.metadata.requires_dist:
......
...@@ -18,8 +18,8 @@ platform = "*" ...@@ -18,8 +18,8 @@ platform = "*"
[package.source] [package.source]
type = "directory" type = "directory"
reference = "tests/fixtures/project_with_setup" reference = ""
url = "" url = "tests/fixtures/project_with_setup"
[package.dependencies] [package.dependencies]
cachy = ">=0.2.0" cachy = ">=0.2.0"
......
...@@ -9,8 +9,8 @@ platform = "*" ...@@ -9,8 +9,8 @@ platform = "*"
[package.source] [package.source]
type = "file" type = "file"
reference = "tests/fixtures/distributions/demo-0.1.0-py2.py3-none-any.whl" reference = ""
url = "" url = "tests/fixtures/distributions/demo-0.1.0-py2.py3-none-any.whl"
[package.dependencies] [package.dependencies]
pendulum = ">=1.4.0.0,<2.0.0.0" pendulum = ">=1.4.0.0,<2.0.0.0"
......
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