Modernizes the build process by consolidating all of ``setuptools`` metadata within ``pyproject.toml`` and removing deprecated ``setup.cfg`` and ``setup.py``. `#5837 <https://github.com/pypa/pipenv/issues/5837>`_
Bug Fixes
---------
- Restore the ignore compatibility finder pip patch to resolve issues collecting hashes from google artifact registry (and possibly others). `#5887 <https://github.com/pypa/pipenv/issues/5887>`_
- Handle case better where setup.py name is referencing a variable that is a string while encouraging folks to migrate their projects to pyproject.toml `#5905 <https://github.com/pypa/pipenv/issues/5905>`_
- Better handling of local file install edge cases; handle local file extras. `#5919 <https://github.com/pypa/pipenv/issues/5919>`_
- Include the Pipfile markers in the install phase when using ``--skip-lock``. `#5920 <https://github.com/pypa/pipenv/issues/5920>`_
- Fallback to default vcs ref when no ref is supplied.
More proactively determine package name from the pip line where possible, fallback to the existing file scanning logics when unable to determine name. `#5921 <https://github.com/pypa/pipenv/issues/5921>`_
Modernizes the build process by consolidating all of ``setuptools`` metadata within ``pyproject.toml`` and removing deprecated ``setup.cfg`` and ``setup.py``.
Pipenv uses a set of commands to manage your Project\(aqs dependencies and custom scripts.
It replaces the use of \fBMakefile\fP, direct calls to \fBpip\fP and \fBpython \-m venv\fP or \fBvirtualenv\fP\&.
to create virtual environments and install packages in them.
Pipenv uses two files to do this: \fBPipfile\fP and \fBPipfile.lock\fP (which will look familiar if you
are used to packages manager like \fByarn\fP or \fBnpm\fP).
.sp
The main commands are:
\fBNOTE:\fP
.INDENT0.0
.IP\(bu2
\fBinstall\fP\-
.INDENT3.5
This guide is written for Python 3.7+
.UNINDENT
.UNINDENT
.SHMAKESUREYOUHAVEPYTHONANDPIP
.sp
Will create a virtual env and install dependencies (if it does not exist already)
The dependencies will be installed inside.
.IP\(bu2
\fBinstall package==0.2\fP\-
Before you go any further, make sure you have Python and that it’s available
from your command line. You can check this by simply running
.INDENT0.0
.INDENT3.5
.sp
Will add the package in version 0.2 to the virtual environment and
to \fBPipfile\fP and \fBPipfile.lock\fP
.IP\(bu2
\fBuninstall\fP\- Will remove the dependency
.IP\(bu2
\fBlock\fP\- Regenerate \fBPipfile.lock\fP and updates the dependencies inside it.
.nf
.ftC
$ python \-\-version
.ftP
.fi
.UNINDENT
.UNINDENT
.sp
These are intended to replace \fB$ pip install\fP usage, as well as manual virtualenv management.
You should get some output like \fB3.10.8\fP\&. If you do not have Python, please
install the latest 3.x version from \fI\%python.org\fP
.sp
Additionally, make sure you have \fI\%pip\fP available.
Check this by running
.INDENT0.0
.INDENT3.5
.sp
.nf
.ftC
$ pip \-\-version
pip 22.3.1
.ftP
.fi
.UNINDENT
.UNINDENT
.sp
If you installed Python from source, with an installer from \fI\%python.org\fP or via \fI\%Homebrew\fP, you likely already have pip.
If you’re on Linux and installed using your OS package manager, you may have to \fI\%install pip\fP manually.
.SHINSTALLINGPIPENV
.SSPreferredInstallationofPipenv
.sp
It is recommended that users on most platforms install pipenv from \fI\%pypi.org\fP using
.INDENT0.0
.INDENT3.5
.sp
.nf
.ftC
$ pip install pipenv \-\-user
.ftP
.fi
.UNINDENT
.UNINDENT
.sp
\fBNOTE:\fP
.INDENT0.0
.INDENT3.5
pip \fI\%user installations\fP allow for installation into your home directory to prevent breaking any system\-wide packages.
Due to interaction between dependencies, you should limit tools installed in this way to basic building blocks for a Python workflow such as virtualenv, pipenv, tox, and similar software.
.UNINDENT
.UNINDENT
.sp
If \fBpipenv\fP isn’t available in your shell after installation,
you’ll need to add the user site\-packages binary directory to your \fBPATH\fP\&.
.sp
On Linux and macOS you can find the \fI\%user base\fP binary directory by running
\fBpython \-m site \-\-user\-base\fP and appending \fBbin\fP to the end. For example,
this will typically print \fB~/.local\fP (with \fB~\fP expanded to the
absolute path to your home directory), so you’ll need to add
\fB~/.local/bin\fP to your \fBPATH\fP\&. You can set your \fBPATH\fP permanently by
\fI\%modifying ~/.profile\fP\&.
.sp
On Windows you can find the user base binary directory by running
\fBpython \-m site \-\-user\-site\fP and replacing \fBsite\-packages\fP with
\fBScripts\fP\&. For example, this could return
\fBC:\eUsers\eUsername\eAppData\eRoaming\ePython37\esite\-packages\fP, so you would
need to set your \fBPATH\fP to include
\fBC:\eUsers\eUsername\eAppData\eRoaming\ePython37\eScripts\fP\&. You can set your
user \fBPATH\fP permanently in the \fI\%Control Panel\fP\&.
.sp
You may need to log out for the \fBPATH\fP changes to take effect.
.sp
To upgrade pipenv at any time:
.INDENT0.0
.INDENT3.5
.sp
.nf
.ftC
$ pip install \-\-user \-\-upgrade pipenv
.ftP
.fi
.UNINDENT
.UNINDENT
.SSHomebrewInstallationofPipenv
.INDENT0.0
.IP\(bu2
\fBgraph\fP will show you a dependency graph of your installed dependencies.
\fI\%Homebrew\fP is a popular open\-source package management system for macOS (or Linux).
.UNINDENT
.sp
Once you have installed Homebrew simply run
.INDENT0.0
.INDENT3.5
.sp
.nf
.ftC
$ brew install pipenv
.ftP
.fi
.UNINDENT
.UNINDENT
.sp
To upgrade pipenv at any time:
.INDENT0.0
.INDENT3.5
.sp
.nf
.ftC
$ brew upgrade pipenv
.ftP
.fi
.UNINDENT
.UNINDENT
.sp
\fBNOTE:\fP
.INDENT0.0
.INDENT3.5
Homebrew installation is discouraged because it works better to install pipenv using pip on macOS.
.UNINDENT
.UNINDENT
.SHINSTALLINGPACKAGESFORYOURPROJECT
.sp
Pipenv manages dependencies on a per\-project basis. To install a package,
change into your project’s directory (or just an empty directory for this
tutorial) and run
.INDENT0.0
.INDENT3.5
.sp
.nf
.ftC
$ cd myproject
$ pipenv install <package>
.ftP
.fi
.UNINDENT
.UNINDENT
.sp
\fBNOTE:\fP
.INDENT0.0
.INDENT3.5
Pipenv is designed to be used by non\-privileged OS users. It is not meant
to install or handle packages for the whole OS. Running Pipenv as \fBroot\fP
or with \fBsudo\fP (or \fBAdmin\fP on Windows) is highly discouraged and might
lead to unintend breakage of your OS.
.UNINDENT
.UNINDENT
.sp
Pipenv will install the package and create a \fBPipfile\fP
for you in your project’s directory. The \fBPipfile\fP is used to track which
dependencies your project needs in case you need to re\-install them, such as
when you share your project with others.
.sp
For example when installing the \fBrequests\fP library, you should get output similar to this:
print(\(aqYour IP is {0}\(aq.format(response.json()[\(aqorigin\(aq]))
.ftP
.fi
.UNINDENT
.UNINDENT
.sp
Then you can run this script using \fBpipenv run\fP
.INDENT0.0
.INDENT3.5
.sp
.nf
.ftC
$ pipenv run python main.py
.ftP
.fi
.UNINDENT
.UNINDENT
.sp
You should get output similar to this:
.INDENT0.0
.INDENT3.5
.sp
.nf
.ftC
Your IP is 8.8.8.8
.ftP
.fi
.UNINDENT
.UNINDENT
.sp
Using \fB$ pipenv run\fP ensures that your installed packages are available to
your script by activating the virtualenv. It is also possible to spawn a new shell
that ensures all commands have access to your installed packages with \fB$ pipenv shell\fP\&.
.SHVIRTUALENVMAPPINGCAVEAT
.INDENT0.0
.IP\(bu2
\fBshell\fP will spawn a shell with the virtualenv activated. This shell can be deactivated by using \fBexit\fP\&.
Pipenv automatically maps projects to their specific virtualenvs.
.IP\(bu2
\fBrun\fP will run a given command from the virtualenv, with any arguments forwarded (e.g. \fB$ pipenv run python\fP or \fB$ pipenv run pip freeze\fP).
By default, the virtualenv is stored globally with the name of the project’s root directory plus the hash of the full path to the project’s root (e.g., \fBmy_project\-a3de50\fP).
.IP\(bu2
\fBcheck\fP checks for security vulnerabilities and asserts that \fI\%PEP 508\fP requirements are being met by the current environment.
Should you change your project’s path, you break such a default mapping and pipenv will no longer be able to find and to use the project’s virtualenv.
.IP\(bu2
If you must move or rename a directory managed by pipenv, run ‘pipenv \-\-rm’ before renaming or moving your project directory. Then, after renaming or moving the directory run ‘pipenv install’ to recreate the virtualenv.
.IP\(bu2
Customize this behavior with \fBPIPENV_CUSTOM_VENV_NAME\fP environment variable.
.IP\(bu2
You might also prefer to set \fBPIPENV_VENV_IN_PROJECT=1\fP in your .env or .bashrc/.zshrc (or other shell configuration file) for creating the virtualenv inside your project’s directory.
.UNINDENT
.SHAUTHOR
Python Packaging Authority
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.