thoth-station / micropipenv

A lightweight wrapper for pip to support requirements.txt, Pipenv and Poetry lock files or converting them to pip-tools compatible output. Designed for containerized Python applications but not limited to them.
https://pypi.org/project/micropipenv/
GNU Lesser General Public License v3.0
231 stars 25 forks source link

added env override for default index URL #286

Closed djcass44 closed 7 months ago

djcass44 commented 10 months ago

Related Issues and Dependencies

This introduces a breaking change

This Pull Request implements

Updates the _DEFAULT_INDEX_URLS so that it can be set from an environment variable rather than being hardcoded.

Description

Context: I am attempting to use Micropipenv in an environment behind a corporate firewall where I cannot access pypi.org. To make things more complex, I need to build the application in two different environments which do not have a consistent Pip registry available, meaning I cannot put the registry URL in the package manager configuration file.

This change adds the MICROPIPENV_DEFAULT_INDEX_URLS environment variable which allows a consumer to override the default registry that Micropipenv uses if it cannot find one in the package manager config.

This change is implemented in a way that is not breaking. If the environment variable is not set it will behave identically to how it did before.

op1st-prow[bot] commented 10 months ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please assign frenzymadness for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/thoth-station/micropipenv/blob/master/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
op1st-prow[bot] commented 10 months ago

Hi @djcass44. Thanks for your PR.

I'm waiting for a thoth-station member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
djcass44 commented 10 months ago

@fridex thanks for the quick response!

I've added some documentation to the README to explain how to use the environment variable. I think it would be great idea to add it to the CLI however it would be a much more involved change than a simple environment variable. If it's okay I'd prefer to merge this to get the functionality through

fridex commented 10 months ago

Thank you, let's see what maintainers will say :)

goern commented 8 months ago

@frenzymadness wdyt?

frenzymadness commented 8 months ago

I like this change and I'm open to merging and releasing it. However, it'd be nice to have some tests for it. Do you think you can add some?

djcass44 commented 8 months ago

@frenzymadness done! I've also improved the handling of whitespace

djcass44 commented 8 months ago

@frenzymadness thanks for the feedback! I believe I've addressed it all

frenzymadness commented 7 months ago

I fixed a code a little bit to improve readability and to make mypy and pydocstyle tests pass. For some reason, I'm not able to push it to your fork (probably because you opened this PR from the master branch, but I'm not sure).

Could you please check #290 where all your commits and my changes are squashed together and ready to be merged?