{"id":13501496,"url":"https://github.com/thoth-station/micropipenv","last_synced_at":"2025-05-15T06:07:44.229Z","repository":{"id":37855403,"uuid":"239500398","full_name":"thoth-station/micropipenv","owner":"thoth-station","description":"A lightweight wrapper for pip to support requirements.txt, Pipenv and Poetry lock files or converting them to pip-tools compatible output. Designed for containerized Python applications but not limited to them.","archived":false,"fork":false,"pushed_at":"2025-04-28T20:26:46.000Z","size":752,"stargazers_count":237,"open_issues_count":11,"forks_count":27,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-28T21:38:52.287Z","etag":null,"topics":["dependency-management","hacktoberfest","pip","pip-tools","pip3","pipenv","poetry","python","python3","thoth"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/micropipenv/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thoth-station.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-10T11:54:36.000Z","updated_at":"2025-04-28T20:26:50.000Z","dependencies_parsed_at":"2022-08-08T22:02:02.566Z","dependency_job_id":"ca1ed270-829c-4ac6-b485-24fc5f24cdc2","html_url":"https://github.com/thoth-station/micropipenv","commit_stats":{"total_commits":281,"total_committers":16,"mean_commits":17.5625,"dds":0.5516014234875445,"last_synced_commit":"1450160a479b670e639f8ac44a6b3055a12be3c4"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":"thoth-station/template-project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoth-station%2Fmicropipenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoth-station%2Fmicropipenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoth-station%2Fmicropipenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoth-station%2Fmicropipenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thoth-station","download_url":"https://codeload.github.com/thoth-station/micropipenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254283350,"owners_count":22045141,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency-management","hacktoberfest","pip","pip-tools","pip3","pipenv","poetry","python","python3","thoth"],"created_at":"2024-07-31T22:01:39.431Z","updated_at":"2025-05-15T06:07:44.020Z","avatar_url":"https://github.com/thoth-station.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"µPipenv\n-------\n\n.. image:: https://img.shields.io/github/v/tag/thoth-station/micropipenv?style=plastic\n  :target: https://github.com/thoth-station/micropipenv/releases\n  :alt: GitHub tag (latest by date)\n\n.. image:: https://travis-ci.com/thoth-station/micropipenv.svg?branch=master\n  :target: https://travis-ci.com/thoth-station/micropipenv\n\n.. image:: https://img.shields.io/pypi/pyversions/micropipenv?style=plastic\n  :target: https://pypi.org/project/micropipenv\n  :alt: PyPI - Python Version\n\n.. image:: https://img.shields.io/pypi/l/micropipenv?style=plastic\n  :target: https://pypi.org/project/micropipenv\n  :alt: PyPI - License\n\n.. image:: https://img.shields.io/pypi/dm/micropipenv?style=plastic\n  :target: https://pypi.org/project/micropipenv\n  :alt: PyPI - Downloads\n\nA lightweight wrapper for pip to support requirements.txt, Pipenv and Poetry\nlock files or converting them to `pip-tools\n\u003chttps://pypi.org/project/pip-tools/\u003e`_ compatible output. Designed for\ncontainerized Python applications but not limited to them.\n\nFor a brief video preview, `check this demo\n\u003chttps://www.youtube.com/watch?v=I-QC83BcLuo\u0026t=8m58s\u003e`_ (the micropipenv\npart starts at 9:00).\n\nSee also `micropipenv: Installing Python dependencies in containerized\napplications\n\u003chttps://developers.redhat.com/articles/2021/05/19/micropipenv-installing-python-dependencies-containerized-applications\u003e`__\nfor more info about this tool and a `blog post published about it\n\u003chttps://dev.to/fridex/micropipenv-the-one-installation-tool-that-covers-pipenv-poetry-and-pip-tools-3ee7\u003e`__.\n\nWhat's the difference in comparision to pip when using requirements.txt?\n=========================================================================\n\n* if ``requirements.txt`` state all the packages in a pinned version with\n  hashes (e.g. `pip-tools \u003chttps://pypi.org/project/pip-tools/\u003e`_), micropipenv\n  installs packages with a possible fallback if the installation order is\n  relevant\n\n  * you don't need to care about the installation and maintain correct order or\n    requirements in ``requirements.txt``\n\n  * best effort installation - try until there is a possibility to succeed\n\n* if ``requirements.txt`` do not state all the packages in a pinned form\n\n  * pip's resolver algorithm is used and it's left on pip to resolve\n    requirements\n\n  * the same behavior as micropipenv would not be used\n\n\nWhat's the difference in comparision to Poetry?\n===============================================\n\n* a lightweight addition to Poetry, not a Poetry replacement\n\n  * micropipenv does not substitute Poetry it rather complements it for\n    containerized deployments where the size of the container image and\n    software shipped with it matters\n\n* no release management to Python package indexes\n\n* micropipenv does not implement resolver, it uses already resolved stack that\n  application is shipped with based on ``poetry.lock`` and ``pyproject.toml``\n\n* no virtual environment management\n\n  * virtual environment management is left on user, if needed\n\nWhat's the difference in comparision to Pipenv?\n===============================================\n\n* a lightweight addition to Pipenv, not a Pipenv replacement\n\n  * micropipenv does not substitute Pipenv it rather complements it for\n    containerized deployments where the size of the container image and\n    software shipped with it matters\n\n* it does not `vendor all the dependencies as Pipenv\n  \u003chttps://github.com/pypa/pipenv/tree/master/pipenv/vendor\u003e`_\n\n* micropipenv does not implement resolver, it uses already resolved stack that\n  application is shipped with ``Pipfile.lock``\n\n* no virtual environment management\n\n  * virtual environment management is left on user, if needed\n\nmicropipenv use cases\n=====================\n\nWhy should I use ``micropipenv`` instead of `Pipenv \u003chttps://github.com/pypa/pipenv\u003e`_\nor `Poetry \u003chttps://pypi.org/project/poetry\u003e`_?\n\n* I would like to have a tool that \"rules them all\" - one lightweight tool to\n  support all Python dependency lock file managers (pip-tools, Poetry, Pipenv)\n  and lets users decide what they want to use when deploying Python applications\n  in containerized environments (e.g. Kubernetes, OpenShift, ...).\n\n* I would like to have a fast and minimalistic tool to install software\n  packages in CI.\n\n* I would like to have containerized Python applications as small as possible\n  with minimum software shipped and required to build and run the Python\n  application in production.\n\n* I would like to convert files produced by Pipenv/Poetry to a pip-tools\n  compatible output.\n\n* I don't want to install Pipenv/Poetry, but I would like to run a project that\n  uses Pipenv/Poetry for dependency management (e.g. restricted environments).\n\n* My Pipenv installation is broken and `Pipenv upstream did not issue any new\n  Pipenv release \u003chttps://github.com/pypa/pipenv/issues/4058\u003e`_.\n\n* I would like to deploy my application into a production environment and my\n  application dependencies are managed by Pipenv/Poetry (dependencies are\n  already resolved), but I don't want to run Pipenv/Poetry in production (e.g.\n  OpenShift's s2i build process).\n\n\n``micropipenv install``\n=======================\n\nThe tool supports installing dependencies of the following formats:\n\n* ``Pipenv`` style lock format - files ``Pipfile`` and ``Pipfile.lock``\n* ``Poetry`` style lock format - files ``pyproject.toml`` and ``poetry.lock``\n* ``pip-tools`` style lock format - file ``requirements.txt``\n* raw ``requirements.txt`` as used by ``pip`` (not a lock file)\n\nIn case of Pipenv, Poetry and pip-tools style format, the tool performs\nautomatic recovery if the installation order of dependencies is relevant (one\ndependency fails to install as it depends on an another one).\n\nTo enforce the installation method used, specify ``--method`` option to the\n``install`` subcommand. By default, ``micropipenv`` traverses the filesystem up\nfrom the current working directory and looks for the relevant files in the\nfollowing order:\n\n1. ``Pipfile.lock`` and optionally ``Pipfile`` (if ``--deploy`` set)\n2. ``poetry.lock`` and ``pyproject.toml``\n3. ``requirements.txt`` for ``pip-tools`` and raw ``pip`` requirements\n\nTo install dependencies issue the following command:\n\n.. code-block:: console\n\n  micropipenv install --dev  # --dev is optional\n\nYou can supply additional positional arguments that will be passed to ``pip``.\nUse double dashes to distinguish ``pip`` options from ``micropipenv`` options.\n\n.. code-block::\n\n  # issue `pip install --user'\n  micropipenv install -- --user\n\n\nVirtual environment management\n==============================\n\n``micropipenv`` does not create any virtual environment as in the case of\nPipenv/Poetry.  It simply executes ``pip``, and constructs arguments out of the\nlock file used. ``pip``'s default behaviour is to install its arguments into\nthe same Python environment where ``pip`` is installed (i.e., the system Python\nenvironment).\n\nTo rather install its arguments into a virtual environment, run ``micropipenv``\nfrom a shell where that virtual environment has been activated. This causes\n``micropipenv`` to run the ``pip`` command already installed in the virtual\nenvironment:\n\n.. code-block:: console\n\n  python3 -m venv venv/ \u0026\u0026 (. venv/bin/activate \u0026\u0026 micropipenv install)\n\nAlternatively, ``micropipenv`` can run the ``pip`` command from the system\nPython environment, which can in turn be told to install its arguments into an\nexplicitly specified virtual environment by using the ``PIP_PYTHON``\nenvironment variable.\n\nThis allows for the installation of dependencies into a minimal virtual\nenvironment that does not itself have ``pip`` and its dependencies installed\ninto it:\n\n.. code-block:: console\n\n  python3 -m venv venv/ --without-pip \u0026\u0026 PIP_PYTHON=venv/bin/python micropipenv install\n\n\nUsing another package index\n===========================\n\nTo set the default Python Package Index to something other than ``https://pypi.org/simple``, set the ``MICROPIPENV_DEFAULT_INDEX_URLS`` to one or more comma-separated URLs.\n\n  Note: if the package manager file contains a package index URL, it will be used over this value.\n\n.. code-block:: console\n\n  export MICROPIPENV_DEFAULT_INDEX_URLS=https://pypi.example.com/simple,https://pypi.org/simple\n  micropipenv install\n\n\n``micropipenv install --deploy``\n================================\n\nIf you wish to mimic ``pipenv --deploy`` functionality, you can do so:\n\n.. code-block:: console\n\n  micropipenv install --deploy\n\nNote however, there is a need to parse ``Pipfile`` and verify its content\ncorresponds to Pipefile.lock used (digest computed on ``Pipfile`` content).\n``micropipenv`` requires toml extras for this functionality, so you will need\nto install ``micropipenv[toml]`` (see installation instructions bellow).\n\nThe ``--deploy`` option takes no effect for Poetry and requirements\ninstallation methods.\n\n\n``micropipenv install --dev``\n================================\n\nInstallation of \"development\" dependencies can be acomplished using the\n``--dev`` flag. This flag has no effect when ``requirements.txt`` file is used.\n\n\n``micropipenv requirements`` / ``micropipenv req``\n==================================================\n\nTo generate output compatible with `pip-tools\n\u003chttps://pypi.org/project/pip-tools/\u003e`_, you can issue the following command:\n\n.. code-block:: console\n\n  micropipenv requirements\n\nThis applies to conversion from Poetry and Pipenv specific lock files.\n\nAdditional configuration options can limit what is present in the output (e.g.\n``--no-dev`` to remove development dependencies).\n\nA special option ``--only-direct`` makes ``micropipenv`` work on ``Pipfile``\ninstead of ``Pipfile.lock``. This requires toml extras, so install\n``micropipenv[toml]`` for this functionality (see installation instructions\nbellow). To get direct dependencies of an application and store them in\nrequirements.txt file:\n\n.. code-block:: console\n\n  micropipenv requirements --only-direct \u003e requirements.txt\n\n\nFor a setup that follows ``pip-tools`` convention with ``requirements.in`` and\n``requirements.txt``\n\n.. code-block:: console\n\n  micropipenv requirements --no-dev \u003e requirements.txt\n  micropipenv requirements --no-dev --only-direct \u003e requirements.in\n  micropipenv requirements --no-default \u003e dev-requirements.txt\n  micropipenv requirements --no-default --only-direct \u003e dev-requirements.in\n\n\nSee ``micropipenv requirements --help`` for more info.\n\n\n``micropipenv`` as a library\n============================\n\n``micropipenv`` exposes some core functionality on top of\n``Pipfile``/``Pipfile.lock``.  You can import its functions and use\n``micropipenv`` as a lightweight library for ``Pipfile``/``Pipfile.lock`` and\n``pyproject.toml``/``poetry.lock`` manipulation.\n\n\nAdjusting options using environment variables\n=============================================\n\nAll options can be triggered using environment variables - the name of an\nenvironment variable is always prefixed with ``MICROPIPENV_`` and consists of\nthe name of the option converted to uppercase, dashes are replaced with\nunderscores (example ``--no-dev`` is mapped to ``MICROPIPENV_NO_DEV``). All\nenvironment variables corresponding to flags are parsed as integers and\nsubsequently casted to a boolean. For example, to turn ``--no-dev`` flag on,\nset ``MICROPIPENV_NO_DEV=1`` (0 disables the flag). Parameters supplied to CLI\ntake precedence over environment variables.\n\nA special environment variable ``MICROPIPENV_PIP_BIN`` can point to an\nalternate ``pip`` binary.\n\nTo run this tool in a verbose mode, you can set the ``MICROPIPENV_DEBUG=1`` (the\nsame behavior can be achieved with multiple ``--verbose`` supplied).\n\nThe tool prints software stack information to the standard error output. This was\ndesigned for Thoth to capture information about installed dependencies as a\nuseful source of information for Thoth's build analyzers. This behaviour can be\nsuppressed by setting ``MICROPIPENV_NO_LOCKFILE_PRINT=1`` environment variable.\n\nBesides printing, the tool also writes the content of Pipfile.lock (if a locked\nsoftware stack is used) to the directory where lock files are present (for Pipenv\nfiles, the Pipfile.lock is kept untouched). This behaviour can be suppressed by\nproviding ``MICROPIPENV_NO_LOCKFILE_WRITE=1`` environment variable.\n\nExample usage\n=============\n\nInstall dependencies managed by Poetry as ``pip install --user`` would do\n(option ``--method`` is optional, auto-discovery is performed if omitted):\n\n.. code-block:: console\n\n  $ ls\n  poetry.lock pyproject.toml project.py\n  $ micropipenv install --method poetry -- --user\n\nInstall dependencies (both main and develop) managed by Poetry into a virtual\nenvironment:\n\n.. code-block:: console\n\n  $ ls\n  poetry.lock pyproject.toml project.py\n  $ python3 -m venv venv/\n  $ . venv/bin/activate\n  (venv) $ micropipenv install --dev\n\nInstall dependencies managed by Pipenv (both main and develop) into a virtual\nenvironment  (option ``--method`` is optional, auto-discovery is performed if\nomitted):\n\n.. code-block:: console\n\n  $ ls\n  Pipfile Pipfile.lock src/\n  $ python3 -m venv venv/\n  $ . venv/bin/activate\n  (venv) $ micropipenv install --dev\n\nPerform deployment of an application as Pipenv would do with Python interpreter\nversion check and Pipfile file hash check (you can create virtual environment\nonly if necessary):\n\n.. code-block:: console\n\n  $ ls\n  Pipfile Pipfile.lock src/\n  $ python3 -m venv venv/\n  $ . venv/bin/activate\n  (venv) $ micropipenv install --deploy\n\nGenerate `pip-tools \u003chttps://pypi.org/project/pip-tools/\u003e`_ compliant\n``requirements.in``, ``dev-requirements.in``, ``requirements.txt`` and\n``dev-requirements.txt`` out of ``Pipfile`` and ``Pipfile.lock`` - project\ndependencies managed by Pipenv:\n\n.. code-block:: console\n\n  $ ls\n  Pipfile Pipfile.lock src/\n  $ micropipenv requirements --no-dev \u003e requirements.txt\n  $ micropipenv requirements --no-dev --only-direct \u003e requirements.in\n  $ micropipenv requirements --no-default \u003e dev-requirements.txt\n  $ micropipenv requirements --no-default --only-direct \u003e dev-requirements.in\n\nGenerate `pip-tools \u003chttps://pypi.org/project/pip-tools/\u003e`_ complaint\n``requirements.in``, ``dev-requirements.in``, ``requirements.txt`` and\n``dev-requirements.txt`` out of ``pyproject.toml`` and ``poetry.lock`` - project\ndependencies managed by Poetry:\n\n.. code-block:: console\n\n  $ ls\n  poetry.lock pyproject.toml src/\n  $ micropipenv requirements --no-dev \u003e requirements.txt\n  $ micropipenv requirements --no-dev --only-direct \u003e requirements.in\n  $ micropipenv requirements --no-default \u003e dev-requirements.txt\n  $ micropipenv requirements --no-default --only-direct \u003e dev-requirements.in\n\nFor OpenShift's s2i integration,\n`check this repo with a demo \u003chttps://github.com/fridex/s2i-example-micropipenv\u003e`_.\n\nInstallation\n============\n\nThe project is `hosted on PyPI \u003chttps://pypi.org/project/micropipenv\u003e`_ so\ninstalling it using ``pip`` works as expected:\n\n.. code-block:: console\n\n  pip install micropipenv\n\nThe default installation does not bring any dependencies so its just\n``micropipenv`` that gets installed. However, the default installation supports\nonly ``Pipfile.lock`` management. If you would like to manipulate also with\n``Pipfile`` or Poetry specific lock files, you will need to install\n``micropipenv`` with TOML support (TOML is not in the standard Python library):\n\n.. code-block:: console\n\n  pip install micropipenv[toml]\n\nOnce the project gets installed, you can browse the help message by invoking\nthe ``micropipenv`` CLI:\n\n.. code-block:: console\n\n  micropipenv --help\n\nIf you wish to install ``micropipenv`` on your Fedora system:\n\n.. code-block:: console\n\n  dnf install -y micropipenv\n\nSee available `RPM packages \u003chttps://src.fedoraproject.org/rpms/micropipenv\u003e`_.\n\nNo installation\n===============\n\nYou can run ``micropipenv`` without actually installing it - simply download\nthe file and execute it. If you do not wish to save ``micropipenv.py`` file to\ndisk, you can issue:\n\n.. code-block:: console\n\n  curl https://raw.githubusercontent.com/thoth-station/micropipenv/master/micropipenv.py | python3 - --help\n\nAnything after ``python3 -`` will be passed as an argument to\n``micropipenv.py`` so installing packages can be simply performed using:\n\n.. code-block:: console\n\n  curl https://raw.githubusercontent.com/thoth-station/micropipenv/master/micropipenv.py | python3 - install -- --user\n\nAll arguments after -- will be passed to ``pip`` as options.\n\nOpenShift s2i (Source-To-Image)\n===============================\n\nmicropipenv is available in UBI, Fedora and RHEL based container images. To\nenable micropipenv and benefit from its features, you need to export\n``ENABLE_MICROPIPENV=1`` environment variable in more recent Python 3 container\nimages. See `sclorg/s2i-python-container\n\u003chttps://github.com/sclorg/s2i-python-container/tree/master/3.8\u003e`__ repo for\nmore information.\n\nLicense and copying\n===================\n\nThis project is licensed under the terms of the GNU Lesser General Public\nLicense v3 or later. See ``LICENSE-LGPL`` and ``LICENSE-GPL`` files for the\nlicense terms.\n\nCopyright (C) 2020-2022 `Project Thoth \u003chttp://thoth-station.ninja/\u003e`__; Red Hat Inc.\n\nOriginal author:\n * Fridolín 'fridex' Pokorný \u003cfridolin@redhat.com\u003e\n\nMaintainers:\n * Lumír 'Frenzy' Balhar \u003clbalhar@redhat.com\u003e\n * Max Gautier \u003cmax.gautier@redhat.com\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoth-station%2Fmicropipenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthoth-station%2Fmicropipenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoth-station%2Fmicropipenv/lists"}