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

Workaround the changes to pip internals #2

Merged
merged 1 commit into from
Jul 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
except ImportError:
# It is quick hack to support pip 10 that has changed its internal
# structure of the modules.
from pip._internal.download import PipSession
# Further hack - seems like pip 20 and later does not support
# pip._internal.download anymore. It appears as though
# parse_requirements (used below) does not need a valid PipSession.
# Any value seems to work. So hack this even more.
try:
from pip._internal.download import PipSession
except ImportError:
PipSession = object
from pip._internal.req.req_file import parse_requirements


Expand All @@ -22,9 +29,12 @@ def get_requirements(source):
"""

install_reqs = parse_requirements(filename=source, session=PipSession())

return [str(ir.req) for ir in install_reqs]

# pip 20 changed ParsedRequirement.req to ParsedRequirement.requirement.
try:
requirements = [str(ir.req) for ir in install_reqs]
except AttributeError:
requirements = [str(ir.requirement) for ir in install_reqs]
return requirements

setup(
packages=find_packages(),
Expand Down