Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install_requires parsing different between install methods #11777

Open
1 task done
thekickartist opened this issue Feb 3, 2023 · 2 comments
Open
1 task done

install_requires parsing different between install methods #11777

thekickartist opened this issue Feb 3, 2023 · 2 comments
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior

Comments

@thekickartist
Copy link

Description

When parsing the install_requires parameter of a setup.py file in a local install pip is incorrectly parsing the requirements and failing to remark on a syntax error.

Expected behavior

When running the command pip install -e . on a local package with the following setup file

import os
import setuptools

THIS_DIR = os.path.dirname(__file__)

# Get the relevant setup parameters from the package
parameters = {}
# Get the long description from the README file
with open(os.path.join(THIS_DIR, 'docs-test', '__about__.py'), 'r') as f:
    exec(f.read(), parameters)

setuptools.setup(name='docs-test',
                 version=parameters['__version__'],
                 description=parameters['__description__'],
                 install_requires=['pytest>7<7.2.1'], #Place package dependencies here
                 packages=setuptools.find_packages(exclude=('*test*',)),
                 zip_safe=False,
                 )

The command should fail as the line install_requires=['pytest>7<7.2.1'], #Place package dependencies here is missing comma separators between version constraints

pip version

23.0

Python version

3.10.9

OS

ubuntu

How to Reproduce

  1. In a package's setup.py file specify requirements without comma separators
  2. Run pip install -e .
  3. Note that packages are installed, no error was thrown and versions may be incorrect

Output

Specify requirements without comma separators

(docs-test) user@laptop:~/git_repos/dev/docs_test$ cat setup.py 
import os
import setuptools

THIS_DIR = os.path.dirname(__file__)

# Get the relevant setup parameters from the package
parameters = {}
# Get the long description from the README file
with open(os.path.join(THIS_DIR, 'docs-test', '__about__.py'), 'r') as f:
    exec(f.read(), parameters)

setuptools.setup(name='docs-test',
                 version=parameters['__version__'],
                 description=parameters['__description__'],
                 install_requires=['pytest>7<7.2.1'], #Place package dependencies here
                 packages=setuptools.find_packages(exclude=('*test*',)),
                 zip_safe=False,
                 )

Run pip install -e .

(docs-test) user@laptop:~/git_repos/dev/docs_test$ pip install -e .
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://builder:****@nexus.ursaspace.com:8443/repository/pypi-releases/simple
Obtaining file:///home/warren/git_repos/dev/docs_test
  Preparing metadata (setup.py) ... done
Collecting pytest>7<7.2.1
  Using cached https://nexus.ursaspace.com:8443/repository/pypi-releases/packages/cc/02/8f59bf194c9a1ceac6330850715e9ec11e21e2408a30a596c65d54cf4d2a/pytest-7.2.1-py3-none-any.whl (317 kB)
Requirement already satisfied: attrs>=19.2.0 in /home/warren/.local/lib/python3.10/site-packages (from pytest>7<7.2.1->docs-test==1.0.0) (22.1.0)
Requirement already satisfied: pluggy<2.0,>=0.12 in /home/warren/.local/lib/python3.10/site-packages (from pytest>7<7.2.1->docs-test==1.0.0) (1.0.0)
Requirement already satisfied: iniconfig in /home/warren/.local/lib/python3.10/site-packages (from pytest>7<7.2.1->docs-test==1.0.0) (1.1.1)
Requirement already satisfied: tomli>=1.0.0 in /home/warren/.local/lib/python3.10/site-packages (from pytest>7<7.2.1->docs-test==1.0.0) (2.0.1)
Requirement already satisfied: packaging in /home/warren/.local/lib/python3.10/site-packages (from pytest>7<7.2.1->docs-test==1.0.0) (21.3)
Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /home/warren/.local/lib/python3.10/site-packages (from pytest>7<7.2.1->docs-test==1.0.0) (1.0.4)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /home/warren/.local/lib/python3.10/site-packages (from packaging->pytest>7<7.2.1->docs-test==1.0.0) (3.0.9)
Installing collected packages: pytest, docs-test
  Running setup.py develop for docs-test
Successfully installed docs-test-1.0.0 pytest-7.2.1

Note package installation and incorrect version

(docs-test) user@laptop:~/git_repos/dev/docs_test$ pip list | grep pytest
pytest                       7.2.1

Code of Conduct

@thekickartist thekickartist added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Feb 3, 2023
@pradyunsg
Copy link
Member

Consolidating into #11715

@uranusjr
Copy link
Member

uranusjr commented Feb 5, 2023

This looks like a bug in setuptools instead? The package should not install, and setuptools should have emitted an error. This example does not contain a pyproject.toml, so pip install -e . is doing a legacy editable installation, and the install_requires is thus parsed by setuptools, not pip. In thet case the main issue is not #11715.

(Reopening for visibility.)

@uranusjr uranusjr reopened this Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants