PUR can't handle wildcard * in requirements.txt
evetion opened this issue · 6 comments
Hi there,
When I put wildcards in the requirements.txt like this:
Django==1.8.*
PUR raises and InvalidVersion:
pip._vendor.packaging.version.InvalidVersion: Invalid version: '1.8.*'
Wildcards are supported by pip and PEP 508
https://pip.pypa.io/en/stable/reference/pip_install/#example-requirements-file
https://www.python.org/dev/peps/pep-0508/#grammar
I'll upgrade pip to support wildcards. When finding wildcards, I'm assuming everyone wants the non-wildcard parts of the package version spec upgraded, with the wildcard left in place?
Fixed in v4.0.1, however it doesn't upgrade the package instead skips it.
Thanks for the quick fix! I think the skip is indeed the best action.
I agree that the default behaviour would be to skip.
But could be an option to force the non-wildcard parts of the package version spec upgraded? I'm asking before opening an issue.
Sure, we could do that here:
683ea72#diff-c8f2dfc160ea901f520fa3f134e40df6R273
Not sure at the moment how that would be implemented, but we'll probably have to re-parse the Version after removing the wildcard part then add it back if upgraded.
That's what I do currently by means of a script:
# Change * to 0
for line in fileinput.input(temp_updated, inplace=True, backup='.orig'):
print(line.rstrip().replace('*', '0'))
# Check upgrade changes
pur_file = open(f'{temp_root}.pur.txt', 'w')
subprocess.run(['pur', '-r', temp_updated], check=True, stdout=pur_file)
# Change patch to *
for line in fileinput.input(temp_updated, inplace=True):
line = re.sub(r'(==\d+\.\d+\.)(\d+)', r'\1*', line.rstrip())
print(line)