[PYTHON] Pipenv and Pipfile.lock

I don't know how long I'll use it because it's so fashionable, but I'll write about Pipenv https://github.com/pypa/pipenv. Pipenv is a tool like npm, but it uses lock files a little differently, so I'll write this first.

Pipfile.lock

In Pipenv, the developer writes in Pipfile what version he wants to install, and Pipfile.lock records the version he actually installed. In this way, others can reproduce the same environment that the developer installed. Use it as follows.

If you want to reproduce the same environment as the person who created Pipfile.lock. (npm ci in npm)

pipenv install

Or the same thing happens with pipenv sync

If you want to ignore Pipfile.lock and install the latest packages listed in Pipfile. (npm install in npm)

pipenv update

Continue to write general usage.

If you also have pyenv installed, pyenv will be called via pipenv and the appropriate Python version will be installed automatically.

Typical work when creating a new pipenv environment by yourself

Installation example (Maybe the installer will write ʻeval "$ (pyenv init-)" `to .zshrc etc.):

brew install pipenv pyenv

Create a new environment by specifying the Python version. Pyenv is required for automatic Python installation.

pipenv --python 3.8

Enter the environment

pipenv shell

Install something for implementation. pipenv lock is also automatically executed and Pipfile.lock is updated.

pipenv install boto3

Install something for development. pipenv lock is also automatically executed and Pipfile.lock is updated.

pipenv install --dev autopep8

List installed packages

pipenv graph

Check the dependencies as defined in pep-508.

pipenv check

Find a package that is out of date

pipenv update --outdated

Update old packages. Ignore Pipfile.lock and look only at Pipfile to update the package. pipenv lock is also automatically executed and Pipfile.lock is updated.

pipenv update

Update Pipfile.lock to the latest version based on Pipfile, but do not install it.

pipenv lock

Create an environment based on Pipfile.lock. Same as pipenv install when Pipfile.lock exists.

pipenv sync

Delete environment

pipenv --rm

Participate in the development of code that already has Pipfile and Pipfile.lock

Install the package according to Pipfile.lock.

pipenv install

Digression

It is easy to check the operation if you use a package that updates quickly, such as boto3 https://pypi.org/project/boto3/.

Recommended Posts

Pipenv and Pipfile.lock
Pipenv
About _ and __
Run OpenVino on macOS and pyenv and pipenv environment