Reputation: 582
I am trying to restrict the range of acceptable versions of the ipykernel
package when installing a project that has a pyproject.toml
file requiring "setuptools>=45"
, and a setup.cfg
file, which has the following as the install_requires
option:
install_requires =
nexusformat >= 0.7.5
numpy
scipy
h5py >= 2.9
qtpy
qtconsole
ipython
ipykernel <= 6.8.0, >= 6.15.2
This triggers the following error message:
$ pip install -e .
Obtaining file:///Users/rosborn/Documents/Computing/Repositories/nexpy
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Preparing editable metadata (pyproject.toml) ... done
Requirement already satisfied: matplotlib in /Users/rosborn/opt/miniconda3/envs/py38/lib/python3.8/site-packages (from NeXpy==0.14.6.dev6+g9996d70.d20220829) (3.6.0rc1)
ERROR: Could not find a version that satisfies the requirement ipykernel<=6.8.0,>=6.15.2 (from nexpy)
(from versions: 4.0.1, 4.0.2, 4.0.3, 4.1.0, 4.1.1, 4.2.0, 4.2.1, 4.2.2,
4.3.0, 4.3.1, 4.4.0, 4.4.1, 4.5.0, 4.5.1, 4.5.2, 4.6.0, 4.6.1, 4.7.0,
4.8.0, 4.8.1, 4.8.2, 4.9.0, 4.10.0, 4.10.1, 5.0.0b1, 5.0.0, 5.1.0,
5.1.1, 5.1.2, 5.1.3, 5.1.4, 5.2.0, 5.2.1, 5.3.0, 5.3.1, 5.3.2, 5.3.3,
5.3.4, 5.4.0, 5.4.1, 5.4.2, 5.4.3, 5.5.0, 5.5.3, 5.5.4, 5.5.5, 5.5.6,
6.0.0a0, 6.0.0a1, 6.0.0a2, 6.0.0a3, 6.0.0a4, 6.0.0a5, 6.0.0a6, 6.0.0b0,
6.0.0rc0, 6.0.0rc1, 6.0.0rc2, 6.0.0, 6.0.1, 6.0.2, 6.0.3, 6.1.0, 6.2.0,
6.3.0, 6.3.1, 6.4.0, 6.4.1, 6.4.2, 6.5.0, 6.5.1, 6.6.0, 6.6.1, 6.7.0,
6.8.0, 6.9.0, 6.9.1, 6.9.2, 6.10.0, 6.11.0, 6.12.0, 6.12.1, 6.13.0,
6.13.1, 6.14.0, 6.15.0, 6.15.1, 6.15.2)
ERROR: No matching distribution found for ipykernel<=6.8.0,>=6.15.2
In other words, the error message lists the versions that it claims it cannot match. It even happens when either ipykernel v6.8.0
or ipykernel v6.15.2
are already installed.
I have seen similar StackOverflow issues (e.g., here) but I don't see the same setuptools error even with verbose output. Is there a problem with setting discontiguous ranges? Or another syntax error? Any suggestions welcome.
I am running setuptools v65.3.0
and pip 22.2.2
in Python 3.8.
Upvotes: 0
Views: 621
Reputation: 80031
Unfortunately, what you're trying to achieve doesn't work with using the range specifiers because the use of < <= > >=
(in pip
, setuptools
, etc.) are done with logical AND
-ing rather than logical OR
-ing. Efforts to improve this aspect have stagnated.
So for your needs:
I need to exclude versions between
6.9
and6.15.1
,
You'd have to instead exclude the versions you don't want, using the version exclusion specifier !=
.
This line would suffice and excludes all releases of ipykernel
between 6.9.*
and 6.15.1
.
ipykernel != 6.9.*, != 6.10.*, != 6.11.*, != 6.12.*, != 6.13.*, != 6.14.*, != 6.15.0, != 6.15.1
And you'll see that this works with installation under your circumstances...
# Done with fresh Python env, installs latest
> pip install "ipykernel != 6.9.*, != 6.10.*, != 6.11.*, != 6.12.*, != 6.13.*, != 6.14.*, != 6.15.0, != 6.15.1"
Collecting ipykernel!=6.10.*,!=6.11.*,!=6.12.*,!=6.13.*,!=6.14.*,!=6.15.0,!=6.15.1,!=6.9.*
Collecting ipykernel-6.15.2-py3-none-any.whl
Downloading ipykernel-6.15.2-py3-none-any.whl (132 kB)
... etc ...
Installing collected packages: wcwidth, pure-eval, ptyprocess, pickleshare, executing, backcall, appnope, traitlets, tornado, six, pyzmq, pyparsing, pygments, psutil, prompt-toolkit, pexpect, parso, nest-asyncio, entrypoints, decorator, debugpy, python-dateutil, packaging, matplotlib-inline, jupyter-core, jedi, asttokens, stack-data, jupyter-client, ipython, ipykernel
Successfully installed appnope-0.1.3 asttokens-2.0.8 backcall-0.2.0 debugpy-1.6.3 decorator-5.1.1 entrypoints-0.4 executing-1.0.0 ipykernel-6.15.2 ipython-8.4.0 jedi-0.18.1 jupyter-client-7.3.5 jupyter-core-4.11.1 matplotlib-inline-0.1.6 nest-asyncio-1.5.5 packaging-21.3 parso-0.8.3 pexpect-4.8.0 pickleshare-0.7.5 prompt-toolkit-3.0.30 psutil-5.9.1 ptyprocess-0.7.0 pure-eval-0.2.2 pygments-2.13.0 pyparsing-3.0.9 python-dateutil-2.8.2 pyzmq-23.2.1 six-1.16.0 stack-data-0.5.0 tornado-6.2 traitlets-5.3.0 wcwidth-0.2.5
And try it with having an older ipykernel
installed
# Let's try with installing an older ipykernel and then trying our new specifiers
> pip install ipykernel==6.7.0
Collecting ipykernel==6.7.0
# stuff
Successfully installed appnope-0.1.3 asttokens-2.0.8 backcall-0.2.0 debugpy-1.6.3 decorator-5.1.1 entrypoints-0.4 executing-1.0.0 ipykernel-6.7.0
> pip install "ipykernel != 6.9.*, != 6.10.*, != 6.11.*, != 6.12.*, != 6.13.*, != 6.14.*, != 6.15.0, != 6.15.1"
Requirement already satisfied: ipykernel!=6.10.*,!=6.11.*,!=6.12.*,!=6.13.*,!=6.14.*,!=6.15.0,!=6.15.1,!=6.9.*
in ./.venv/lib/python3.10/site-packages (6.7.0)
Upvotes: 1