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

Add compatibility with pip 24 #65

Merged
merged 2 commits into from
Dec 11, 2024
Merged

Conversation

dpvDuncan
Copy link
Contributor

Currently, when using Pur directly from Python as per the documentation:
>>> from pur import update_requirements
>>> print([x[0]['message'] for x in update_requirements(input_file='requirements.txt').values()])

there is an error with pip version 24, and maybe 23 too:

Traceback (most recent call last):
File "C:\Users\me\requirements_update.py", line 73, in
for x in update_requirements(
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\AppData\Local\Programs\Python\Python312\Lib\site-packages\pur_init_.py", line 201, in update_requirements
update_requirements(
File "C:\Users\me\AppData\Local\Programs\Python\Python312\Lib\site-packages\pur_init
.py", line 267, in update_requirements
for line, req, spec_ver, latest_ver in requirements:
File "C:\Users\me\AppData\Local\Programs\Python\Python312\Lib\site-packages\pur_init
.py", line 387, in get_requirements_and_latest
for parsed_req, orig_line in requirements:
File "C:\Users\me\AppData\Local\Programs\Python\Python312\Lib\site-packages\pur_init
.py", line 434, in _parse_requirements
for parsed_line, orig_line in parser.parse(filename, constraint):
File "C:\Users\me\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip_internal\req\req_file.py", line 332, in parse
yield from self._parse_and_recurse(
^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: PatchedRequirementsFileParser._parse_and_recurse() takes 3 positional arguments but 4 were given

It seems that pip._internal.req.req_file._parse_and_recurse, which is overridden in pur (in class PatchedRequirementsFileParser) evolved, and it no requires 4 inputs instead of 3 (parsed_files_stack seems to have been added)

This PR aims to quickly make the overriding method compatible with Pip, no matter the version.

Copy link
Owner

@alanhamlett alanhamlett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@alanhamlett alanhamlett merged commit ccd1ae4 into alanhamlett:master Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants