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

_contains_egg_info gives false positive for file:// URL with dash in directory name #13093

Open
1 task done
Luthaf opened this issue Nov 27, 2024 · 0 comments
Open
1 task done
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior

Comments

@Luthaf
Copy link

Luthaf commented Nov 27, 2024

Description

The regex used for _contains_egg_info (

_egg_info_re = re.compile(r"([a-z0-9_.]+)-([a-z0-9_.!+-]+)", re.IGNORECASE)
BuildResult = Tuple[List[InstallRequirement], List[InstallRequirement]]
def _contains_egg_info(s: str) -> bool:
"""Determine whether the string looks like an egg_info.
:param s: The string to parse. E.g. foo-2.1
"""
return bool(_egg_info_re.search(s))
) will match a when the package is stored in a directory named foo-bar but will not match foo or foo_bar (regardless of the the distribution/package name). This means that dependencies on foo-bar @ file://some/path/to/foo-bar will cache the built wheel, while foo-bar @ file://some/path/to/foo_bar will not.

In my case this happens with extra_requires = {"bar": ["foo-bar @ file://some/path/to/foo-bar"]}, and then pip install ./path/to/foo[bar]. With dash in the directory name, the built wheel is cached, and without dash the wheel is not cached.

Expected behavior

Wheels caching should not depend on the name of a local directory, and ideally there should not be any caching here. It is my understanding that pip does not cache wheels built from local path.

pip version

24.3.1

Python version

3.12

OS

macOS

How to Reproduce

There is a reproducing example here: https://github.com/Luthaf/pip-cache-issue. You can reproduce with

git clone https://github.com/Luthaf/pip-cache-issue
cd pip-cache-issue

pip cache remove "foo*"

pip install ./foo[bar] # builds everything
pip install ./foo[bar] # does not build foo-bar, instead "Using cached foo_bar-0.1.0-py3-none-any.whl"

pip install ./foo[bar-no-dash] # builds everything
pip install ./foo[bar-no-dash] # re-build everything

Output

$ pip install ./foo[bar]
Processing ./foo
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Processing ./foo-bar (from foo==0.1.0)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: foo, foo-bar
  Building wheel for foo (pyproject.toml) ... done
  Created wheel for foo: filename=foo-0.1.0-py3-none-any.whl size=1153 sha256=d0b175de9812038f738384b35b86e37e1e989bdbabb5cdead5c15d2a896a6d32
  Stored in directory: /private/var/folders/nz/mgmqnhrj4mzfjlnqbgn02t780000gn/T/pip-ephem-wheel-cache-vmo7ldg3/wheels/54/bf/48/2fa3e36c4631e60a4a62bde8645871dbcd33f22b1b374c1699
  Building wheel for foo-bar (pyproject.toml) ... done
  Created wheel for foo-bar: filename=foo_bar-0.1.0-py3-none-any.whl size=1098 sha256=1becfd6b42433584756e1c41a4b1d91c2aa8dbb0674a9d0dedd712950a1d112a
  Stored in directory: ~/Library/Caches/pip/wheels/ac/ec/45/468b133fc5265f5319d909bf1584e35abda80b130c3b0d933c
Successfully built foo foo-bar
Installing collected packages: foo-bar, foo
  Attempting uninstall: foo-bar
    Found existing installation: foo-bar 0.1.0
    Uninstalling foo-bar-0.1.0:
      Successfully uninstalled foo-bar-0.1.0
  Attempting uninstall: foo
    Found existing installation: foo 0.1.0
    Uninstalling foo-0.1.0:
      Successfully uninstalled foo-0.1.0
Successfully installed foo-0.1.0 foo-bar-0.1.0
$ pip install ./foo[bar]
Processing ./foo
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting foo-bar@ file://~/code/tests/pip-cache-issue/foo-bar (from foo==0.1.0)
  Using cached foo_bar-0.1.0-py3-none-any.whl
Building wheels for collected packages: foo
  Building wheel for foo (pyproject.toml) ... done
  Created wheel for foo: filename=foo-0.1.0-py3-none-any.whl size=1153 sha256=2c4a5f787f48c63f2195ec0e0cbd56beed7855dfc6a0234f3ccb14ef6b6b7e2a
  Stored in directory: /private/var/folders/nz/mgmqnhrj4mzfjlnqbgn02t780000gn/T/pip-ephem-wheel-cache-b_p8an8n/wheels/54/bf/48/2fa3e36c4631e60a4a62bde8645871dbcd33f22b1b374c1699
Successfully built foo
Installing collected packages: foo-bar, foo
  Attempting uninstall: foo-bar
    Found existing installation: foo-bar 0.1.0
    Uninstalling foo-bar-0.1.0:
      Successfully uninstalled foo-bar-0.1.0
  Attempting uninstall: foo
    Found existing installation: foo 0.1.0
    Uninstalling foo-0.1.0:
      Successfully uninstalled foo-0.1.0
Successfully installed foo-0.1.0 foo-bar-0.1.0
$ pip install ./foo[bar-no-dash]
Processing ./foo
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Processing ./foo_bar (from foo==0.1.0)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: foo, foo-bar
  Building wheel for foo (pyproject.toml) ... done
  Created wheel for foo: filename=foo-0.1.0-py3-none-any.whl size=1157 sha256=7761e2b4714b6be1ad23eb8ad71de5f916544abd534196be3602ede5624bed98
  Stored in directory: /private/var/folders/nz/mgmqnhrj4mzfjlnqbgn02t780000gn/T/pip-ephem-wheel-cache-_xun31gu/wheels/54/bf/48/2fa3e36c4631e60a4a62bde8645871dbcd33f22b1b374c1699
  Building wheel for foo-bar (pyproject.toml) ... done
  Created wheel for foo-bar: filename=foo_bar-0.1.0-py3-none-any.whl size=1098 sha256=d82594da99402a47177688d9393a1509c1dd28cbf282845dc72d2b78c8fac7b3
  Stored in directory: /private/var/folders/nz/mgmqnhrj4mzfjlnqbgn02t780000gn/T/pip-ephem-wheel-cache-_xun31gu/wheels/b2/e1/c6/c92ff1704974f1b2eacce523d69b269ef1271a9028d3d7f952
Successfully built foo foo-bar
Installing collected packages: foo-bar, foo
  Attempting uninstall: foo-bar
    Found existing installation: foo-bar 0.1.0
    Uninstalling foo-bar-0.1.0:
      Successfully uninstalled foo-bar-0.1.0
  Attempting uninstall: foo
    Found existing installation: foo 0.1.0
    Uninstalling foo-0.1.0:
      Successfully uninstalled foo-0.1.0
Successfully installed foo-0.1.0 foo-bar-0.1.0
$ pip install ./foo[bar-no-dash]
Processing ./foo
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Processing ./foo_bar (from foo==0.1.0)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: foo, foo-bar
  Building wheel for foo (pyproject.toml) ... done
  Created wheel for foo: filename=foo-0.1.0-py3-none-any.whl size=1157 sha256=24c92ae6f2f7a040c56189852dffb3a21cff8c77373cbf6c78c84716a6271eda
  Stored in directory: /private/var/folders/nz/mgmqnhrj4mzfjlnqbgn02t780000gn/T/pip-ephem-wheel-cache-3bm311ue/wheels/54/bf/48/2fa3e36c4631e60a4a62bde8645871dbcd33f22b1b374c1699
  Building wheel for foo-bar (pyproject.toml) ... done
  Created wheel for foo-bar: filename=foo_bar-0.1.0-py3-none-any.whl size=1098 sha256=b2bc016db66ea77a64237f38e4b878665890bead0058321fb1a5c494b6f187f0
  Stored in directory: /private/var/folders/nz/mgmqnhrj4mzfjlnqbgn02t780000gn/T/pip-ephem-wheel-cache-3bm311ue/wheels/b2/e1/c6/c92ff1704974f1b2eacce523d69b269ef1271a9028d3d7f952
Successfully built foo foo-bar
Installing collected packages: foo-bar, foo
  Attempting uninstall: foo-bar
    Found existing installation: foo-bar 0.1.0
    Uninstalling foo-bar-0.1.0:
      Successfully uninstalled foo-bar-0.1.0
  Attempting uninstall: foo
    Found existing installation: foo 0.1.0
    Uninstalling foo-0.1.0:
      Successfully uninstalled foo-0.1.0
Successfully installed foo-0.1.0 foo-bar-0.1.0

Code of Conduct

@Luthaf Luthaf added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Nov 27, 2024
Luthaf added a commit to Luthaf/featomic that referenced this issue Nov 27, 2024
Luthaf added a commit to Luthaf/featomic that referenced this issue Nov 27, 2024
Luthaf added a commit to Luthaf/featomic that referenced this issue Nov 27, 2024
Luthaf added a commit to Luthaf/featomic that referenced this issue Nov 28, 2024
Luthaf added a commit to Luthaf/featomic that referenced this issue Nov 28, 2024
Luthaf added a commit to metatensor/featomic that referenced this issue Dec 4, 2024
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

1 participant