-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Implements requirements command as per #4959 #5013
Conversation
@ImreC Could you merge latest main branch into your branch so the CI should pass again? |
@matteius is the news file correct? I have never worked with this before |
It should be name |
pipenv/cli/command.py
Outdated
lockfile = state.project.lockfile_content | ||
for i, package_index in enumerate(lockfile['_meta']['sources']): | ||
prefix = '-i' if i == 0 else '--extra-index-url' | ||
echo(crayons.normal(' '.join([prefix, package_index['url']]))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should output the index verbatim as specified in the Pipfile, without expanding variables. It is fairly common to specify credentials for a private PyPI this way, and writing those into the resulting requirements.txt file is counter-productive.
I'm not sure whether your existing code is already doing this or not, just wanted to mention this need.
@ImreC thank you for the latest changes! really good to see this, just a small change still, and I think this can be merged. |
@oz123 I have one small question. I have been looking at the env var substitution (or rather lack thereof) as suggested by @rittneje and added a test for this, but something is going wrong on the shell/python intersection. The env var gets substituted in stdout where python checks, but I don't think it gets substituted anywhere else which is why the test fails. I expect this to not get substituted, but difficult to test in this way. I see possible paths forward:
|
For now I have changed the test back so it passes. All checks that I have performed indicates that this works as expected (the literal index URL including env var keys gets outputted with no expansion) |
@matteius but this could also explain the test failing. What my code does is that it takes the literal string in the package index and echoes that. I think that should work right? Another question that I have after looking at this is whether the code should support the case where a package index is linked to a package directly (as in |
@ImreC I think it does explain your test failing and unless @rittneje has some inputs on this one, we may have to defer the environment variable in the pip indexes as a separate issue/enhancement. For your second question, I am of the view that we should try to figure out how to support pinned indexes such as |
Ok so
|
@matteius I don't think adding a package index per line in requirements.txt is supported by pip, so I think this is impossible to achieve. The only way forward that I can see is to generate a requirements.txt file per package index, but this seems to deviate pretty far from the original gist of the feature: to be a simple way to generate a requirements.txt. Maybe we can just add a caveat to the readme and leave this as is? Potentially we can add this as an enhancement later, but I am also thinking that in the way it is implemented right now it would work for the majority of people. Thoughts? |
@ImreC Yeah I agree with everything you have discovered and said about this. That was kind of my assumption too that pip did not support such a thing. Let's not make it a blocker to the fantastic work you've done on this to get it this far. I do have one last thing for you to consider, and it doesn't have to be part of this PR -- but what do you think about the current option |
I would definitely leave it in for now as the behavior is different than |
@ImreC Looks like your build is failing on the new linting checks I added recently. Can you run |
@matteius should be fixed |
@matteius suppression expansion of variables is already merged into pip and I believe also into pipenv. So this should not happen here. Also, as @ImreC already mentioned index url are not part of
can be resolved with:
See also: https://stackoverflow.com/a/41926975 |
@ImreC you might want to change your author email. It seems currently wrong. If you are fine with the current email, I can merge it like this. |
@oz123 I changed my email address mid-PR so I think it is fine. Just for my understanding. Where is this visible? |
@oz123 I think this case will work fine. The only problem that I can see is where you have packages with clashing names, f.e. you have a private package index with a package called |
@ImreC Actually this shouldn't be a big issue anymore, please see: #5029 TLDR: Basically all packages have to be pinned now to an index, and by default the first index in the |
This implements a feature according to #4959.