Skip to main content

A better pip freeze workflow for Python application developers.

Project description

A simple pip freeze workflow for Python application developers.

About

pip-deepfreeze aims at doing one thing and doing it well, namely installing and pinning dependencies of Python applications (not libraries) in a virtual environment.

  • It is easy to use.

  • It is fast.

  • It relies on the documented pip command line interface and its ubiquitous requirements file format.

  • It assumes your project is configured using a PEP 517 compliant build backend but otherwise makes no assumption on the specific backend used.

  • It has first class support for VCS references.

  • It is written in Python 3.6+, yet works in any virtual environment that has pip installed, including python 2.

  • It is small, simple, with good test coverage and hopefully easy to maintain.

Installation

Using pipx (recommended):

pipx install pip-deepfreeze

Using pip:

pip install --user pip-deepfreeze

Quick start

Make sure your application declares its dependencies using setuptools (via the install_requires key in setup.py or setup.cfg), or any other compliant PEP 517 build backend such as flit.

First of all, create and activate a virtual environment using your favorite tool. Run pip list to make sure pip, setuptools and wheel are installed in the virtualenv.

To install your project (in editable mode if supported) in the active virtual environment, go to your project root directory and run:

pip-df sync

If you don’t have one yet, this will generate a file named requirements.txt, containing the exact version of all your application dependencies, as they were installed.

When you add or remove dependencies of your project, run pip-df sync again to update your environment and requirements.txt.

To update one or more dependencies to the latest allowed version, run:

pip-df sync --update DEPENDENCY1 --update DEPENDENCY2 ...

If you need to add some dependencies from VCS references (e.g. when a library with a patch you need is not available as a release on a package index), add the dependency as usual in your project, then add the VCS reference to a file named requirements.txt.in like this:

``DEPENDENCYNAME @ git+https://g.c/org/project@branch``

Then run pip-df sync. It will update requirements.txt with a VCS reference pinned at the exact commit that was installed (you need pip version 20.1 or greater for this to work). If later you need to update to the HEAD of the same branch, simply use pip-df sync --update DEPENDENCYNAME.

When, later again, your branch is merged upstream and the project has published a release, remove the line from requirements.txt.in and run pip-df sync --update DEPENDENCYNAME to update to the latest released version.

How to

(TODO)

  • Initial install (create a venv, and run pip-df sync which will install and generate requirements.txt)

  • Add pip options (--find-links, --extra-index-url, etc: in requirements.txt.in)

  • Add a dependency that is published in an index or accessible via --find-links (add it in setup.py)

  • Install dependencies from direct URLs such as git (add it in setup.py and add the git reference in requirements.txt.in)

  • Remove a dependency (remove it from setup.py)

  • Update a dependency to the most recent version (pip-df sync --update DEPENDENCY1 --update DEPENDENCY2)

  • Update all dependencies to the latest version (pip-df sync --update-all or remove requirements.txt and run pip-df sync)

  • Pass options to pip (via requirements.txt.in or via PIP_* environment variables)

  • Deploy my project (pip wheel --no-deps requirements.txt -e . --wheel-dir=release, ship the release directory then run pip install --no-index release/*.whl).

CLI reference

Global options:

Usage: pip-df [OPTIONS] COMMAND [ARGS]...

  A simple pip freeze workflow for Python application developers.

Options:
  --python PYTHON       [default: python]
  --install-completion  Install completion for the current shell.
  --show-completion     Show completion for the current shell, to copy it or
                        customize the installation.

  --help                Show this message and exit.

Commands:
  sync

sync command options:

Usage: pip-df sync [OPTIONS]

Options:
  -u, --update DEPENDENCY     Make sure DEPENDENCY is upgraded (or downgraded)
                              to the latest allowed version. If DEPENDENCY is
                              not part of your application dependencies
                              anymore, this option has no effect. This option
                              can be repeated.

  --update-all                Upgrade (or downgrade) all dependencies of your
                              application to the latest allowed version.

  --editable / --no-editable  Install the project in editable mode. Defaults
                              to editable if the project supports it.

  --help                      Show this message and exit.

Roadmap

  • Stabilize CLI options.

  • Optionally uninstall unneeded dependencies.

  • Support extras (e.g. for a test extra, we would have requirements-test.txt which includes requirements.txt and optionally requirements-test.txt.in).

  • Support different target environements for the same project (e.g. different python versions, which may result in different packages being installed). Is this actually useful in practice ?

Development

To run tests, use tox. You will get a test coverage report in htmlcov/index.html. An easy way to install tox is pipx install tox.

This project uses pre-commit to enforce linting (among which black for code formating, isort for sorting imports, and mypy for type checking).

To make sure linters run locally on each of your commits, install pre-commit (pipx install pre-commit is recommended), and run pre-commit install in your local clone of the pip-deepfreeze repository.

To release:

  • Select the next version number of the form x.y.z.

  • towncrier --version x.y.z.

  • Inspect and commit the updated HISTORY.rst.

  • git tag x.y.z ; git push --tags.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pip-deepfreeze-0.3.0.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

pip_deepfreeze-0.3.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file pip-deepfreeze-0.3.0.tar.gz.

File metadata

  • Download URL: pip-deepfreeze-0.3.0.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2

File hashes

Hashes for pip-deepfreeze-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d003a92dc6e66454ace67fc17f2aa97b9befd578b6096974c1d4bf1e48e1f1ef
MD5 dd20e7e61c23c02fb7cf3b12ffc7b5c8
BLAKE2b-256 a77300eb3758239f0d4964b87d59d93c4fb23e650678898c9d8ef5c4cf28621a

See more details on using hashes here.

File details

Details for the file pip_deepfreeze-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pip_deepfreeze-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2

File hashes

Hashes for pip_deepfreeze-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 781773b143b93e8f47c4e3097e1db30fa95a0c1298ca50bf2da1a55af42af2b0
MD5 77e2acb65d4f5fd26bcede5184afcc3a
BLAKE2b-256 255de8fa55d654019033fe8db42d747141c7a17db3f1764a8aee656f0d2d9a63

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page