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

Allow support for overriding the default PyPI index url #26

Merged
merged 5 commits into from
Dec 20, 2019
Merged

Allow support for overriding the default PyPI index url #26

merged 5 commits into from
Dec 20, 2019

Conversation

davegallant
Copy link
Contributor

Allow support for overriding the default PyPI index URL to use URLs pointed at a mirror.

Why
Corporate environments often require developers to use a repository mirror and the mirror is not always explicitly defined in the requirements.txt file.

Example use case:

 pur --index-url https://test.pypi.org/simple

Issue:
#25

@coveralls
Copy link

coveralls commented Dec 18, 2019

Coverage Status

Coverage increased (+0.006%) to 98.148% when pulling 0440082 on davegallant:master into 5e050fd on alanhamlett:master.

@davegallant davegallant marked this pull request as ready for review December 18, 2019 02:35
pur/__init__.py Outdated
@@ -68,6 +68,8 @@
help='Prevents updating nested requirements files.')
@click.option('-s', '--skip', type=click.STRING, help='Comma separated list ' +
'of packages to skip updating.')
@click.option('--index-url', type=click.STRING, help='Comma separated list ' +
Copy link
Owner

Choose a reason for hiding this comment

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

Let's allow --index-url to be passed multiple times with each argument added to a list. Then we can have urls that include commas.

pur/__init__.py Outdated
@@ -311,7 +318,7 @@ def patched_parse_requirements(*args, **kwargs):
req_file.parse_requirements = patched_parse_requirements


def _get_requirements_and_latest(filename, force=False, minor=[], patch=[],
def _get_requirements_and_latest(filename, index_url, force=False, minor=[], patch=[],
Copy link
Owner

Choose a reason for hiding this comment

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

This should be optional, like index_urls=[].

pur/__init__.py Outdated
@@ -330,7 +337,7 @@ def _get_requirements_and_latest(filename, force=False, minor=[], patch=[],
"""
session = PipSession()
finder = PackageFinder(
session=session, find_links=[], index_urls=[PyPI.simple_url])
session=session, find_links=[], index_urls=index_url)
Copy link
Owner

@alanhamlett alanhamlett Dec 20, 2019

Choose a reason for hiding this comment

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

Need to use PyPI.simple_url when index_urls list is empty.

pur/__init__.py Outdated
@@ -201,7 +207,7 @@ def _internal_update_requirements(obuffer, updates, input_file=None,
try:
requirements = _get_requirements_and_latest(input_file, force=force,
minor=minor, patch=patch,
pre=pre)
pre=pre, index_url=index_url)
Copy link
Owner

Choose a reason for hiding this comment

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

s/index_url/index_urls/

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.

Todo:

  • default to using PyPI.simple_url when no index urls defined
  • allow multiple --index-url that roll into a list named index_urls

@alanhamlett alanhamlett merged commit 9cb1c12 into alanhamlett:master Dec 20, 2019
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.

3 participants