Skip to main content

A simple wrapper around pip to support Pipenv files

Project description

A lightweight wrapper for pip to support Pipenv files or converting them to pip-tools compatible output.

micropipenv use cases

Why should I use micropipenv instead of Pipenv?

  • I would like to convert files produced by Pipenv to a pip-tools compatible output.

  • I don’t want to install Pipenv, but I would like to run a project that uses Pipenv for dependency management (e.g. restricted environments).

  • My Pipenv installation is broken and Pipenv upstream did not issue any new Pipenv release - see also Thoth’s Pipenv release for possible fix.

  • I would like to deploy my application into a production environment and my application dependencies are managed by Pipenv (dependencies are already resolved), but I don’t want to run Pipenv in production (e.g. OpenShift’s s2i build process).

micropipenv install

You can install dependencies found in Pipfile.lock by issuing:

micropipenv install --dev  # --dev is optional

micropipenv does not create any virtual environment as in case of Pipenv. It rather directly talks to pip, if necessary, and constructs arguments for it out of Pipfile.lock file.

To create a virtual environment to be used by micropipenv:

python3 -m venv venv/ && . venv/bin/activate

If you wish to mimic pipenv --deploy functionality, you can do so:

micropipenv install --deploy

Note however, there is a need to parse Pipfile and verify its content corresponds to Pipefile.lock used (digest computed on Pipfile content). micropipenv requires toml extras for this functionality, so you will need to install micropipenv[toml] (see installation instructions bellow).

You can supply additional positional arguments that will be passed to pip. Use double dashes to distinguish pip options from micropipenv options.

# issue `pip install --user'
micropipenv install -- --user

See micropipenv install --help for more info.

micropipenv requirements / micropipenv req

To generate output compatible with pip-tools, you can issue the following command:

micropipenv requirements

Additional configuration options can limit what is present in the output (e.g. --no-dev to remove development dependencies).

A special option --only-direct makes micropipenv work on Pipfile instead of Pipfile.lock. This requires toml extras, so install micropipenv[toml] for this functionality (see installation instructions bellow). To get direct dependencies of an application and store them in requirements.txt file:

micropipenv requirements --only-direct > requirements.txt

For a setup that follows pip-tools convention with requirements.in and requirements.txt

micropipenv requirements --no-dev > requirements.txt
micropipenv requirements --no-dev --only-direct > requirements.in
micropipenv requirements --no-default > dev-requirements.txt
micropipenv requirements --no-default --only-direct > dev-requirements.in

See micropipenv requirements --help for more info.

micropipenv as a library

micropipenv exposes some core functionality on top of Pipfile/Pipfile.lock. You can import its functions and use micropipenv as a lightweight library for Pipfile/Pipfile.lock manipulation.

Adjusting options using environment variables

All options can be triggered using environment variables - the name of an environment variable is always prefixed with MICROPIPENV_ and consists of the name of the option converted to uppercase, dashes are replaced with underscores (example --no-dev is mapped to MICROPIPENV_NO_DEV). All environment variables corresponding to flags are parsed as integers and subsequently casted to a boolean. For example, to turn --no-dev flag on, set MICROPIPENV_NO_DEV=1 (0 disables the flag). Parameters supplied to CLI take precedence over environment variables.

A special environment variable MICROPIPENV_PIP_BIN can point to an alternate pip binary.

To run this tool in a verbose mode, you can set the MICROPIPENV_DEBUG=1 (the same behavior can be achieved with multiple --verbose supplied).

Installation

The project is hosted on PyPI so installing it using pip works as expected:

pip install micropipenv

The default installation does no bring any dependencies so its just micropipenv that gets installed. However, the default installation supports only Pipfile.lock management. If you would like to manipulate also with Pipfile you will need to install micropipenv with TOML support (TOML is not in the standard Python library):

pip install micropipenv[toml]

Once the project gets installed, you can browse the help message by invoking the micropipenv CLI:

micropipenv --help

No installation

You can run micropipenv without actually installing it - simply download the file and execute it. If you do not wish to save micropipenv.py file to disk, you can issue:

curl https://raw.githubusercontent.com/thoth-station/micropipenv/master/micropipenv.py | python3 - --help

Anything after python3 - will be passed as an argument to micropipenv.py so installing packages can be simply performed using:

curl https://raw.githubusercontent.com/thoth-station/micropipenv/master/micropipenv.py | python3 - install -- --user

All arguments after – will be passed to pip as options.

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

micropipenv-0.0.1.post1.tar.gz (8.9 kB view details)

Uploaded Source

File details

Details for the file micropipenv-0.0.1.post1.tar.gz.

File metadata

  • Download URL: micropipenv-0.0.1.post1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.4.2 requests/2.21.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.5

File hashes

Hashes for micropipenv-0.0.1.post1.tar.gz
Algorithm Hash digest
SHA256 bc74911bc9dc32b8e1e7c3e7256a2e87942b656694a97ed8cfc87ac982da97da
MD5 5801d53505fc19cabf5e57bf59458bfd
BLAKE2b-256 6d8d23afa09a8d62c5d310da92eedae52899f9c2427cbbec1b22a4f820984ddf

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