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

Wrong captured package name when - in name #6127

Closed
fallenwood opened this issue Jan 10, 2019 · 3 comments
Closed

Wrong captured package name when - in name #6127

fallenwood opened this issue Jan 10, 2019 · 3 comments
Labels
auto-locked Outdated issues that have been locked by automation resolution: invalid Invalid issue/PR

Comments

@fallenwood
Copy link

fallenwood commented Jan 10, 2019

Environment

  • pip version: 18.1
  • Python version: 2.7.15
  • OS: ubuntu 16.04

Description

I am building local cassandra-driver packages using dir2pi, getting a tree like this

# tree dist
dist
├── cassandra_driver-3.14.0-cp27-cp27mu-linux_x86_64.whl
├── cassandra-driver-3.14.0.tar.gz
└── simple
    ├── cassandra-driver
    │   ├── cassandra-driver-3.14.0-cp27-cp27mu-linux_x86_64.whl -> ../../cassandra_driver-3.14.0-cp27-cp27mu-linux_x86_64.whl
    │   ├── cassandra-driver-3.14.0.tar.gz -> ../../cassandra-driver-3.14.0.tar.gz
    │   └── index.html
    └── index.html

Then I want to install the local whl files using pip install --find-links, but pip complain that project name is wrong.
I dig a bit into the code to find that when constructing a Wheel, pip using a regex to find the name

    wheel_file_re = re.compile(
        r"""^(?P<namever>(?P<name>.+?)-(?P<ver>.*?))
        ((-(?P<build>\d[^-]*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
        \.whl|\.dist-info)$""",
        re.VERBOSE
    )

It (the group name) matched cassandra-driver's cassadra but driver dropped, so the project name mismatch.
It used to work at pip 8.0 (yeah we are using pip 8.0, I am updating version of pip), with the regexp

    wheel_file_re = re.compile(
        r"""^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))
        ((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
        \.whl|\.dist-info)$""",
        re.VERBOSE
    )

which is slightly different, but it works

here is a demo of what the regex will capture

import re

# from latest master
wheel_file_re_latest = re.compile(
    r"""^(?P<namever>(?P<name>.+?)-(?P<ver>.*?))
    ((-(?P<build>\d[^-]*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
    \.whl|\.dist-info)$""",
    re.VERBOSE
)

# from tag 8.0.3
wheel_file_re = re.compile(
    r"""^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))
    ((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
    \.whl|\.dist-info)$""",
    re.VERBOSE
)

filename = "cassandra-driver-3.14.0-cp27-cp27mu-linux_x86_64.whl"

print(wheel_file_re_latest.match(filename).group('name'))  # cassandra
print(wheel_file_re.match(filename).group('name'))         # cassandra-driver

Found a related commit 283cf2ca78a70f7ff646b8ed173710888bd3dc5f

Expected behavior

The package is installed using local whl files

How to Reproduce

See description above

Output
See description above

@xavfernandez
Copy link
Member

Hello and thanks for your issue and careful investigation.

However distribution names in wheel filename should not contain -, cf https://www.python.org/dev/peps/pep-0427/#escaping-and-unicode and thus cassandra-driver-3.14.0-cp27-cp27mu-linux_x86_64.whl is not a valid wheel filename.

Whatever produced it should instead have named it cassandra_driver-3.14.0-cp27-cp27mu-linux_x86_64.whl and should report this issue with them (dir2pi ?).

@xavfernandez xavfernandez added the resolution: invalid Invalid issue/PR label Jan 10, 2019
@fallenwood
Copy link
Author

Thank you, I found a related issue under pip2pi

@lock
Copy link

lock bot commented May 30, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 30, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation resolution: invalid Invalid issue/PR
Projects
None yet
Development

No branches or pull requests

2 participants