pypa / pipenv

Python Development Workflow for Humans.
https://pipenv.pypa.io
MIT License
24.86k stars 1.86k forks source link

Pipenv preconditions/bootstrap scripts #4705

Open klausmyrseth opened 3 years ago

klausmyrseth commented 3 years ago

Be sure to check the existing issues (both open and closed!), and make sure you are running the latest version of Pipenv.

Check the diagnose documentation for common issues and the PEEP list before posting! We may close your issue if it is very similar to one of them. Please be considerate and follow the PEEP process, or be on your way.

*Checked

Is your feature request related to a problem? Please describe.

Defining a new pipenv fails hard when we use google artifact repository because we cant define a precondition. The precondition/bootstrap to run before the first pipenv update -d or sync -d is to install two packages into the environment, not being able to do so remove some of the strength of having a complete build system and we need to start having custom scripts and routines to setup every repository for developement. As long as I manually run pip install keyrings.google-artifactregistry-auth before I use pipenv everything is working as intended, so I need to be able to define this as a setup criteria for the Pipfile, ref precondition to run when initializing the venv.

Describe the solution you'd like

I would like to be able to define a precondition in the Pipfile for instance: [dev-packages] keyring = {version="", index="pypi", precondition=True} "keyrings.google-artifactregistry-auth" = {version="", index="pypi"}, precondition=True}

or: [init-packages] keyring = {version="", index="pypi"} "keyrings.google-artifactregistry-auth" = {version="", index="pypi"}}

or: preferably define a precondition/bootstrap script all together where we can run pip install keyrings.google-artifactregistry-auth and other bootstrap things when venv is setup by pipenv to have all defined in the project config. This is probably the best solution as other script stuff can be attached here as well for other scenarios or things that has to be readied for a dev repo :) [bootstrap] type = script url = "file:///${PROJECT_ROOT}/bootstrap.sh

Then these packages are defined to get installed before anything gets run in the repository com to sync, update, install and so on. This will then ready the active venv with the authentication to run against the artifact registry in this case. I am sure many other similar scenarios are out there, but at least for google artifact registry its a pain having to use extra init scripts outside which makes normal pip requirements file a more logical choice to use.

Describe alternatives you've considered

repo scripts and pip requirements with venv since we need to use scripts anyhow.

Additional context

Were using pipenv in all our 30+ projects and would like to continue with that, we just hope after we moved over to google artifact repository to find a proper solution to use it through pipenv and a central Pipfile for the project.

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: `'2020.8.13'` Pipenv location: `'/home/xXx/.local/lib/python3.8/site-packages/pipenv'` Python location: `'/usr/bin/python3'` Python installations found: - `3.9.0`: `/home/xXx/.local/share/virtualenvs/applied_domain-ZX84L1hI/bin/python3.9` - `3.9.0`: `/home/xXx/.local/share/virtualenvs/applied_domain-ZX84L1hI/bin/python3` - `3.9.0`: `/home/xXx/.local/share/virtualenvs/applied_domain-ZX84L1hI/bin/python3.9` - `3.9.0`: `/home/xXx/.local/share/virtualenvs/applied_domain-ZX84L1hI/bin/python3` - `3.9.0`: `/usr/bin/python3.9` - `3.9.0`: `/bin/python3.9` - `3.8.5`: `/usr/bin/python3.8` - `3.8.5`: `/usr/bin/python3` - `3.8.5`: `/bin/python3.8` - `3.8.5`: `/bin/python3` - `2.7.18`: `/usr/bin/python2` - `2.7.18`: `/usr/bin/python2.7` - `2.7.18`: `/bin/python2` - `2.7.18`: `/bin/python2.7` PEP 508 Information: ``` {'implementation_name': 'cpython', 'implementation_version': '3.8.5', 'os_name': 'posix', 'platform_machine': 'x86_64', 'platform_python_implementation': 'CPython', 'platform_release': '5.4.0-73-generic', 'platform_system': 'Linux', 'platform_version': '#82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021', 'python_full_version': '3.8.5', 'python_version': '3.8', 'sys_platform': 'linux'} ``` System environment variables: - `GJS_DEBUG_TOPICS` - `SSH_AUTH_SOCK` - `SESSION_MANAGER` - `GNOME_TERMINAL_SCREEN` - `SSH_AGENT_PID` - `XDG_CURRENT_DESKTOP` - `LANG` - `LC_IDENTIFICATION` - `DEFAULTS_PATH` - `XDG_SESSION_CLASS` - `COLORTERM` - `LIBVIRT_DEFAULT_URI` - `GPG_AGENT_INFO` - `DESKTOP_SESSION` - `GJS_DEBUG_OUTPUT` - `XDG_MENU_PREFIX` - `USER` - `QT_IM_MODULE` - `LC_MEASUREMENT` - `VTE_VERSION` - `DBUS_SESSION_BUS_ADDRESS` - `PWD` - `LC_NUMERIC` - `GTK_MODULES` - `_` - `WINDOWPATH` - `XDG_SESSION_DESKTOP` - `JOURNAL_STREAM` - `QT_ACCESSIBILITY` - `HOME` - `GNOME_DESKTOP_SESSION_ID` - `MANAGERPID` - `LC_TIME` - `XDG_DATA_DIRS` - `GNOME_TERMINAL_SERVICE` - `LC_PAPER` - `LOGNAME` - `MANDATORY_PATH` - `XDG_RUNTIME_DIR` - `XDG_CONFIG_DIRS` - `XDG_SESSION_TYPE` - `XMODIFIERS` - `PATH` - `LC_TELEPHONE` - `LC_MONETARY` - `SHELL` - `GNOME_SHELL_SESSION_MODE` - `USERNAME` - `INVOCATION_ID` - `SHLVL` - `XAUTHORITY` - `LC_NAME` - `IM_CONFIG_PHASE` - `TERM` - `LC_ADDRESS` - `DISPLAY` - `GDMSESSION` - `OLDPWD` - `ZSH` - `PAGER` - `LESS` - `LSCOLORS` - `LS_COLORS` - `CLOUDSDK_HOME` - `APPLIED_SCRIPT_HOME` - `GOOGLE_APPLICATION_CREDENTIALS` - `GOOGLE_ACCOUNT_SERVICE_FILE` - `_PYPI_PWD` - `_PYPI_USER` - `_BACKEND_DEV_KEY` - `NVM_DIR` - `NVM_CD_FLAGS` - `NVM_BIN` - `NVM_INC` - `pipfile_dir` - `PIP_DISABLE_PIP_VERSION_CHECK` - `PYTHONDONTWRITEBYTECODE` - `PIP_PYTHON_PATH` - `PYTHONFINDER_IGNORE_UNSUPPORTED` - `PIPENV_ACTIVE` - `VIRTUAL_ENV` - `PS1` - `PIP_SHIMS_BASE_MODULE` Pipenv–specific environment variables: - `PIPENV_ACTIVE`: `1` Debug–specific environment variables: - `PATH`: `/home/xXx/.local/share/virtualenvs/applied_domain-ZX84L1hI/bin:/home/xXx/bin:/opt/ghc/bin:/home/xXx/.nvm/versions/node/v15.1.0/bin:/home/xXx/bin:/opt/ghc/bin:/home/xXx/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin` - `SHELL`: `/usr/bin/zsh` - `LANG`: `en_US.UTF-8` - `PWD`: `/home/xXx/src/applied_domain` - `VIRTUAL_ENV`: `/home/xXx/.local/share/virtualenvs/applied_domain-ZX84L1hI` --------------------------- Snipped pipfile as it contains secret repo info.
matteius commented 1 year ago

@klausmyrseth I believe the support added last Fall for named package categories basically suites this use case you describe.