peterbe / hashin

Helping you write hashed entries for packages in your requirements.txt
https://www.peterbe.com/plog/hashin
MIT License
107 stars 28 forks source link

Running hashin with Python versions >= 3.10 raises PackageError('No releases can be found....') #184

Closed vishnuwazoku closed 1 month ago

vishnuwazoku commented 2 months ago

The issue seems to stem from this piece of code.

def expand_python_version(version):
    if not re.match(r"^\d\.\d$", version):
        return [version]

The above regular expression assumes the minor version number can have only a single digit. Therefore the result will be incorrect for Python versions >= 3.10.

We probably want to change it to

    if not re.match(r"^\d\.\d*\d$", version)
hartwork commented 2 months ago

For a reproducer:

FROM python:3.10
RUN pip3 install hashin \
        && \
    touch requirements.txt \
        && \
    hashin -r requirements.txt -p 3.10 hashin

It takes: