Add --no-lock flag to 'pipenv requirements' command#6496
Merged
Conversation
Adds a new --no-lock flag that generates requirements using version specifiers from the Pipfile instead of locked versions from Pipfile.lock. This is useful for Python libraries that need flexible version constraints (like '>=1.0', '*') rather than strictly pinned versions (like '==1.2.3') for their install_requires. Examples: # Pipfile has: requests = ">=2.0" pipenv requirements --no-lock # Output: requests>=2.0 # Pipfile has: flask = "*" pipenv requirements --no-lock # Output: flask The --no-lock flag implies --from-pipfile since only direct dependencies make sense without the lockfile. Fixes #5482
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
--no-lockflag to thepipenv requirementscommand that generates requirements using version specifiers from the Pipfile instead of locked versions from Pipfile.lock.Motivation
This addresses issue #5482 where users requested the ability to generate requirements.txt with flexible version constraints suitable for Python libraries.
Python libraries typically need looser version constraints (like
>=1.0,*) in theirinstall_requiresrather than strictly pinned versions (like==1.2.3) that come from the lockfile. Strictly pinned dependencies can cause conflicts when the library is installed alongside other packages.Usage
Examples
Given a Pipfile:
With
--no-lock:Without
--no-lock(current behavior):Implementation Details
--no-lockflag implies--from-pipfilesince only direct dependencies make sense without the lockfilepackage[extra1,extra2])sys_platform == 'win32')--no-lock(they require locked versions)Files Changed
pipenv/cli/command.py- Added--no-lockoptionpipenv/routines/requirements.py- Added Pipfile-based generation logicpipenv/utils/requirements.py- Addedrequirements_from_pipfile()functionFixes #5482
Pull Request opened by Augment Code with guidance from the PR author