pypa / pypa/setuptools

[BUG] Distribution.precedence has wrong value for wheels

Open
#2,702 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Needs Triage
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

setuptools version

setuptools==57

Python version

Python 3.7.10

OS

MacOS Big Sur

Additional environment information

No response

Description

I installed a package via pip and looked it the precedence attribute of its Distribution object to find out which way the package was installed. (In my project development installations have to be handled differently than other means of installation.)

Expected behavior

I looked at the possible values: https://github.com/pypa/setuptools/blob/2234e88b7b820c40f29d7ddadc182b0f130eaa1d/pkg_resources/__init__.py#L322-L326

I expected the precedence value to be bigger than -1.
I know there is no value for a wheel here but DEVELOP_DIST feels wrong.

When using easy_install to install the package I get a precedence value of 3 which feels much better.

Is precedence deprecated?

How to Reproduce
python3.7 -m venv precedence
cd precedence
bin/pip install -U pip setuptools wheel
bin/pip install coverage
bin/python -c "import pkg_resources; print(pkg_resources.require('coverage')[0].precedence)"
Output
Looking in indexes: https://pypi.org/simple, ...
Collecting pip
  Using cached pip-21.1.2-py3-none-any.whl (1.5 MB)
Collecting setuptools
  Using cached setuptools-57.0.0-py3-none-any.whl (821 kB)
Collecting wheel
  Using cached wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: pip, setuptools, wheel
  Attempting uninstall: pip
    Found existing installation: pip 20.1.1
    Uninstalling pip-20.1.1:
      Successfully uninstalled pip-20.1.1
  Attempting uninstall: setuptools
    Found existing installation: setuptools 47.1.0
    Uninstalling setuptools-47.1.0:
      Successfully uninstalled setuptools-47.1.0
Successfully installed pip-21.1.2 setuptools-57.0.0 wheel-0.36.2
Looking in indexes: https://pypi.org/simple, ...
Collecting coverage
  Using cached .../coverage-5.5-cp37-cp37m-macosx_10_9_x86_64.whl (207 kB)
Installing collected packages: coverage
Successfully installed coverage-5.5
-1

Note: I had to remove some output pointing to a private PyPI mirror. But I do not think that it is part of the problem.

Code of Conduct
  • I agree to follow the PSF Code of Conduct

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with pkg_resources/init.py at the referenced precedence definitions and reproduce the reported value using the Python 3.7 virtual-environment commands in the issue. Trace how a wheel-installed Distribution is assigned precedence, then determine the intended value or deprecation behavior and add coverage for the reproduced case before running the relevant test suite.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.