python-poetry / python-poetry/poetry

fix inconsistent behavior: poetry install wheel with "malformed" filename fails from remote url, but works locally

Open
#8,889 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/feature status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the FAQ and general documentation and believe that my question is not already covered.

Feature Request

I need to install a third-party wheel from a http url which has a "malformed" package filename. Critically, among other missing things, it does not contain a numerical package version number. Let's assume the filename is the following, where I've anonymized the actual package name except for the part in bold: packagename-any-py3-none-any.whl

In the pyproject.toml I added this line:

packagename = {url = "https://somewebsite.com/some/path/packagename-any-py3-none-any.whl"}

The installation fails because, despite the wheel is downloaded properly in the local poetry cache directory, before actual installation there is a filename validity check here that returns None and prevents the wheel from being installed.
At the time of writing, the filename validation regex is as follows:

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

Notice there is a mandatory version capture group (?P<ver>\d.*?) that requires a number to appear in the package name.

On the other hand, the installation works perfectly fine if I install the wheel from a manually downloaded file which is put in the same directory as the pyproject.toml. The following configuration works as expected, because the filename validity check, for some reason, is not performed when installing from a local file:

packagename = {file = "./packagename-any-py3-none-any.whl"}

My feature request is to allow the installation to succeed not only for the local installation, but also for the remote url case. I'm not sure how this would be impacting the necessity for the filename validation.

On a minor side note, the "invalid filename" exception that is internally raised during installation is completely silent, so I had to spend quite some time debugging poetry code to understand what was the reason. I think that, if the filename check has to stay in place, it would be helpful to let the user know the particular reason why the installation failed, i.e., the filename was malformed because missing the numeric version.

Contributor guide

Open the contributing guide

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 the filename check in src/poetry/utils/cache.py and the wheel_file_re regex in src/poetry/utils/patterns.py, using the linked locations in the issue. Compare remote URL installation with local file installation. Done means the requested malformed wheel behavior is addressed and the issue's concern about explaining invalid filenames is considered.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
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.