-vvv option).src/example/__init__.py next to pyproject.toml for full repro)Hi there! I'm having some trouble with the dependency specifiers generated for setup.py files when I use a version inequality in the pyproject.toml file. For example, I want to exclude torch = "!=1.1.0.post2" from being chosen as a concrete requirement, since it was never released on Linux (there's probably a better way to do this, but for discussion's sake ๐
). Adding this to pyproject.toml, everything initially works fine:
โฏ poetry update torch
Creating virtualenv example-py3.7 in /Users/.../project/.venv
Updating dependencies
Resolving dependencies... (1.8s)
Writing lock file
Package operations: 3 installs, 0 updates, 0 removals
- Installing future (0.18.1)
- Installing numpy (1.17.3)
- Installing torch (1.3.0)
However, after I add code to the project, I get the following error:
โฏ mkdir -p src/example
โฏ touch src/example/__init__.py
โฏ poetry -vvv install
Using virtualenv: /Users/.../project/.venv
Installing dependencies from lock file
Nothing to install or update
- Skipping future (0.18.1) Already installed
- Skipping numpy (1.17.3) Already installed
- Skipping torch (1.3.0) Already installed
- Installing example (0.1.0)
[EnvCommandError]
Command ['/Users/.../project/.venv/bin/python', '-m', 'pip', 'install', '-e', '
/Users/.../project'] errored with the following return code 1, and output:
Obtaining file:///Users/.../project
Collecting torch<1.1.0.post2,>1.1.0.post2 (from example==0.1.0)
Could not find a version that satisfies the requirement torch<1.1.0.post2,>1.1.0.post2 (from example==0.1.0)
(from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 0.4.1, 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.1.0.post2, 1.2.0, 1
.3.0)
No matching distribution found for torch<1.1.0.post2,>1.1.0.post2 (from example==0.1.0)
You are using pip version 19.0.3, however version 19.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Exception trace:
/Users/connor/.poetry/lib/poetry/_vendor/py3.7/cleo/application.py in run() at line 94
status_code = self.do_run(input_, output_)
/Users/connor/.poetry/lib/poetry/console/application.py in do_run() at line 88
return super(Application, self).do_run(i, o)
/Users/connor/.poetry/lib/poetry/_vendor/py3.7/cleo/application.py in do_run() at line 197
status_code = command.run(input_, output_)
/Users/connor/.poetry/lib/poetry/console/commands/command.py in run() at line 77
return super(BaseCommand, self).run(i, o)
/Users/connor/.poetry/lib/poetry/_vendor/py3.7/cleo/commands/base_command.py in run() at line 146
status_code = self.execute(input_, output_)
/Users/connor/.poetry/lib/poetry/_vendor/py3.7/cleo/commands/command.py in execute() at line 107
return self.handle()
/Users/connor/.poetry/lib/poetry/console/commands/install.py in handle() at line 77
builder.build()
/Users/connor/.poetry/lib/poetry/masonry/builders/editable.py in build() at line 17
return self._setup_build()
/Users/connor/.poetry/lib/poetry/masonry/builders/editable.py in _setup_build() at line 42
"python", "-m", "pip", "install", "-e", str(self._path)
/Users/connor/.poetry/lib/poetry/utils/env.py in run() at line 539
return super(VirtualEnv, self).run(bin, *args, **kwargs)
/Users/connor/.poetry/lib/poetry/utils/env.py in run() at line 388
raise EnvCommandError(e, input=input_)
install [--no-dev] [--dry-run] [-E|--extras EXTRAS] [--develop DEVELOP]
I verified that Dependency.to_pep_508() returns a good version string (I think):
In [1]: from poetry.packages.dependency import Dependency
In [2]: dep = Dependency('torch', '!=1.1.0.post2')
In [3]: dep.to_pep_508()
Out[3]: 'torch (<1.1.0.post2,>1.1.0.post2)'
But it seems like along the path to setup.py, it gets turned into:
install_requires = \
[...
'torch<1.1.0.post2,>1.1.0.post2',
...]
I think the issue has to do with this part of the SDist builder, which I think ends up removing the parentheses around the version specifier. I don't totally understand the pip/install_requires syntax though, so I could be totally off ๐
Any advice on how to get inequality specifiers to work would be greatly appreciated ๐
FWIW I'm having a somewhat similar issue with tensorflow = "^1.14,!=1.15.0", which may or may not be relevant. The difference is I'm using dephell to generate setup.py, which seems to go through correctly (I end up with 'tensorflow!=1.15.0,==1.*,>=1.14.0' in setup.py), but then somewhere during a subsequent pip install that specifier is getting translated to tensorflow>=1.14,<1.15.0,>1.15.0,<2, which obviously doesn't work.
OK, I think our issues are the same. Unless I'm missing something, in PEP440 there's no way to specify a union (disjunction) of version ranges -- according to PEP440, the comma always means "and" [1].
Assuming that's correct, the to_pep_508 of a !=x specifier should not be <x,>x, it should simply remain as !=x.
I have a similar problem โ poetry can not parse a version with inequality specifier trafaret>=0.9,<2.0,!=1.1.0 and fails to install a package with:
[SolverProblemError]
Because my-package (0.1.0) depends on both trafaret (<empty>) and trafaret (<empty>), my-package is forbidden.
Looks like this was just fixed nine hours ago and released in version 1.0.0b3! ๐ I tested with the example I gave in my original post and was able to successfully install a package with an exact inequality requirement:
โฏ poetry --version
Poetry version 1.0.0b3
โฏ poetry install
Installing dependencies from lock file
Nothing to install or update
- Installing example (0.1.0)
โฏ
I'm going to close this issue since my original problem has been resolved. @charmasaur @kleschenko Hopefully installing 1.0.0b3 solves your problems too! ๐
Most helpful comment
Looks like this was just fixed nine hours ago and released in version 1.0.0b3! ๐ I tested with the example I gave in my original post and was able to successfully install a package with an exact inequality requirement:
I'm going to close this issue since my original problem has been resolved. @charmasaur @kleschenko Hopefully installing 1.0.0b3 solves your problems too! ๐