pipenv
pipenv copied to clipboard
Use case of --ignore-pipfile
AVOID POSTING ISSUES UNDER THIS CATEGORY.
If Pipenv is not functioning as you would like it to, consider filing either a bug report, or a feature request instead.
Please refer to StackOverflow tag for more information.
Please run $ pipenv --support, and paste the results here. Don't put backticks (`) around it! The output already contains Markdown formatting.
$ pipenv --support
Pipenv version: '2024.0.1'
Pipenv location: '/home/wenzexu/.pyenv/versions/3.12.4/lib/python3.12/site-packages/pipenv'
Python location: '/home/wenzexu/.pyenv/versions/3.12.4/bin/python3.12'
OS Name: 'posix'
User pip version: '24.0'
user Python installations found:
PEP 508 Information:
{'implementation_name': 'cpython',
'implementation_version': '3.12.4',
'os_name': 'posix',
'platform_machine': 'x86_64',
'platform_python_implementation': 'CPython',
'platform_release': '6.9.7-200.fc40.x86_64',
'platform_system': 'Linux',
'platform_version': '#1 SMP PREEMPT_DYNAMIC Thu Jun 27 18:11:45 UTC 2024',
'python_full_version': '3.12.4',
'python_version': '3.12',
'sys_platform': 'linux'}
System environment variables:
SHELLSESSION_MANAGERPYENV_HOOK_PATHCOLORTERMPYENV_SHELLNVM_INCHISTCONTROLXDG_MENU_PREFIXTERM_PROGRAM_VERSIONCONDA_EXE_CE_MHOSTNAMEHISTSIZEDOTNET_ROOTSSH_AUTH_SOCKWARP_USE_SSH_WRAPPERMEMORY_PRESSURE_WRITEXMODIFIERSDESKTOP_SESSIONEDITORPYENV_VERSIONPWDXDG_SESSION_DESKTOPLOGNAMEXDG_SESSION_TYPESYSTEMD_EXEC_PIDXAUTHORITYGJS_DEBUG_TOPICSGDM_LANGHOMEUSERNAMELANGLS_COLORSXDG_CURRENT_DESKTOPMEMORY_PRESSURE_WATCHWAYLAND_DISPLAYWARP_HONOR_PS1WARP_COMBINED_PROMPT_COMMAND_GRIDSSH_SOCKET_DIRINVOCATION_IDMANAGERPIDDOTNET_BUNDLE_EXTRACT_BASE_DIRPYENV_DIRGJS_DEBUG_OUTPUTNVM_DIRGNOME_SETUP_DISPLAYXDG_SESSION_CLASSTERM_CE_CONDALESSOPENUSERCONDA_SHLVLDISPLAYSHLVLNVM_CD_FLAGSQT_IM_MODULECONDA_PYTHON_EXEXDG_RUNTIME_DIRPYENV_ROOTDEBUGINFOD_URLSWARP_IS_LOCAL_SHELL_SESSIONJOURNAL_STREAMXDG_DATA_DIRSPATHGDMSESSIONDBUS_SESSION_BUS_ADDRESSNVM_BINMAILGIO_LAUNCHED_DESKTOP_FILE_PIDGIO_LAUNCHED_DESKTOP_FILEOLDPWDTERM_PROGRAMPIP_DISABLE_PIP_VERSION_CHECKPYTHONDONTWRITEBYTECODEPYTHONFINDER_IGNORE_UNSUPPORTED
Pipenv–specific environment variables:
Debug–specific environment variables:
PATH:/home/wenzexu/.pyenv/versions/3.6.15/bin:/home/wenzexu/.pyenv/versions/3.9.19/bin:/home/wenzexu/.pyenv/versions/3.12.4/bin:/home/wenzexu/.pyenv/versions/3.8.19/bin:/home/wenzexu/.pyenv/versions/3.7.17/bin:/home/wenzexu/.pyenv/versions/3.12.4/bin:/home/wenzexu/.pyenv/libexec:/home/wenzexu/.pyenv/plugins/python-build/bin:/home/wenzexu/.pyenv/plugins/pyenv-virtualenv/bin:/home/wenzexu/.pyenv/plugins/pyenv-update/bin:/home/wenzexu/.pyenv/plugins/pyenv-doctor/bin:/home/wenzexu/.pyenv/shims:/home/wenzexu/.pyenv/bin:/home/wenzexu/.nvm/versions/node/v20.15.0/bin:/home/wenzexu/miniconda3/condabin:/home/wenzexu/.local/bin:/home/wenzexu/bin:/home/wenzexu/.pyenv/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/wenzexu/.dotnet/tools:/home/wenzexu/.cargo/bin:/usr/local/bin:/home/wenzexu/.local/share/JetBrains/Toolbox/scripts:/home/wenzexu/.cargo/bin:/usr/local/bin:/home/wenzexu/.local/share/JetBrains/Toolbox/scriptsSHELL:/bin/bashEDITOR:/usr/bin/nanoLANG:zh_CN.UTF-8PWD:/home/wenzexu
My question is what is the use case of pipenv install --ignore-pipfile, to me, there is no difference between pipenv install and pipenv install --ignore-pipfile.
For example:
# Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
"requests" = "==2.11.0"
[dev-packages]
[requires]
python_version = "3.12"
# Pipfile.lock
{
"_meta": {
"hash": {
"sha256": "7f1be087f2e6adbe8ec64f71bfaaed8b6bb1595f3769488039b14c9d2e555dca"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.12"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"requests": {
"hashes": [
"sha256:09bc1b5f3a56cd8c48d433213a8cba51a67d12936568f73b5f1793fcb0c0979e",
"sha256:63f1815788157130cee16a933b2ee184038e975f0017306d723ac326b5525b54"
],
"index": "pypi",
"markers": "python_version >= '3.8'",
"version": "==2.10.0"
}
},
"develop": {}
}
If I run pipenv install:
$ pipenv install
Pipfile.lock (555dca) out of date: run `pipfile lock` to update to (14165b)...
Running $ pipenv lock then $ pipenv sync.
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success!
Locking [dev-packages] dependencies...
Updated Pipfile.lock (793cf11c853344d4cc8f42ede41e771eb6afaccce2510f7daf1efb578d14165b)!
Installing dependencies from Pipfile.lock (14165b)...
All dependencies are now up-to-date!
Installing dependencies from Pipfile.lock (14165b)...
If I run pipenv install --ignore-pipfile:
$ pipenv install --ignore-pipfile
Pipfile.lock (555dca) out of date: run `pipfile lock` to update to (14165b)...
Running $ pipenv lock then $ pipenv sync.
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success!
Locking [dev-packages] dependencies...
Updated Pipfile.lock (793cf11c853344d4cc8f42ede41e771eb6afaccce2510f7daf1efb578d14165b)!
Installing dependencies from Pipfile.lock (14165b)...
All dependencies are now up-to-date!
Installing dependencies from Pipfile.lock (14165b)...
No difference at all.
If I want to install from Pipfile.lock and really ignore the Pipfile I can run pipenv sync:
$ pipenv sync
Installing dependencies from Pipfile.lock (555dca)...
All dependencies are now up-to-date!
Analysis of Issue #6191:
1. Problem Summary
The user is questioning the use case of the --ignore-pipfile flag in the pipenv install command. Their experiments show no difference in behavior between using the flag and omitting it, as both scenarios seem to prioritize Pipfile.lock for installation.
They also point out that the pipenv sync command already provides the functionality of installing directly from Pipfile.lock.
2. Comment Discussion Analysis
There are no comments on this issue, indicating a lack of community engagement or a clear understanding of the intended use of the --ignore-pipfile flag.
3. Proposed Resolution
The issue highlights a potential redundancy or misunderstanding regarding the --ignore-pipfile flag. It seems the flag's intended behavior might not align with its actual implementation, as it doesn't appear to genuinely ignore Pipfile during installation.
Possible solutions:
- Deprecate and Remove: If the flag is truly redundant, consider deprecating and eventually removing it from
pipenv install. This simplifies the command interface and eliminates confusion. - Clarify Functionality: If the flag has a specific use case beyond
pipenv sync, then its functionality needs to be clarified. Update the documentation to explain its purpose and the scenarios where it differs frompipenv installwithout the flag. This ensures users understand when and how to use it effectively. - Re-implement Functionality: If the intention was for
--ignore-pipfileto install packages only fromPipfile.lockwithout even consideringPipfile, then the code needs to be adjusted to achieve this behavior.
4. Potential Code Changes
If opting to re-implement the functionality:
Modify pipenv/routines/install.py inside the do_install function:
if not packages and not editable_packages:
# ... existing code ...
else:
if skip_lock:
# ... existing code ...
elif ignore_pipfile:
# Install only from Pipfile.lock, ignoring Pipfile completely.
for category in categories:
lockfile_category = get_lockfile_section_using_pipfile_category(category)
for package_name, package_info in lockfile[lockfile_category].items():
# Construct pip installation command for each package in lockfile
pip_line = requirement_from_lockfile(
package_name, package_info, include_hashes=True, include_markers=True
)
# ... append pip_line to a list for installation ...
else:
# ... existing code ...
This modification directly constructs installation commands from Pipfile.lock, bypassing any Pipfile checks or updates if --ignore-pipfile is provided.
5. Additional Steps/Investigations
- Review Existing Tests: Analyze existing tests for
pipenv installto identify any test cases covering the--ignore-pipfileflag. If no such tests exist, create new ones to validate the intended behavior after implementing any changes. - Community Feedback: Engage with the community (perhaps through a discussion on the issue) to understand user expectations and use cases for the
--ignore-pipfileflag. This can help determine the most appropriate course of action.
By either removing, clarifying, or re-implementing the functionality of the --ignore-pipfile flag, Pipenv can maintain a consistent and predictable command interface, aligning with user expectations and avoiding unnecessary confusion.