{"id":20518032,"url":"https://github.com/fridex/s2i-example-micropipenv","last_synced_at":"2025-04-14T00:55:43.561Z","repository":{"id":53597127,"uuid":"247017212","full_name":"fridex/s2i-example-micropipenv","owner":"fridex","description":"An example of micropipenv as part of OpenShift's Python s2i (source-to-image) container image build process","archived":false,"fork":false,"pushed_at":"2021-03-22T08:55:55.000Z","size":289,"stargazers_count":2,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T15:02:15.737Z","etag":null,"topics":["dependency-management","micropipenv","pip","pip3","pipenv","poetry"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fridex.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-13T07:59:06.000Z","updated_at":"2023-03-14T16:05:49.000Z","dependencies_parsed_at":"2022-09-21T21:41:43.533Z","dependency_job_id":null,"html_url":"https://github.com/fridex/s2i-example-micropipenv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridex%2Fs2i-example-micropipenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridex%2Fs2i-example-micropipenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridex%2Fs2i-example-micropipenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridex%2Fs2i-example-micropipenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fridex","download_url":"https://codeload.github.com/fridex/s2i-example-micropipenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248804784,"owners_count":21164131,"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","micropipenv","pip","pip3","pipenv","poetry"],"created_at":"2024-11-15T21:38:13.475Z","updated_at":"2025-04-14T00:55:43.537Z","avatar_url":"https://github.com/fridex.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"micropipenv example for OpenShift's Python s2i\n----------------------------------------------\n\n\nThis repository contains all the materials needed to test and demo `micropipenv\n\u003chttps://github.com/thoth-station/micropipenv\u003e`_ in OpenShift's s2i container\nimage build process.\n\nThe application consists of a simple Flask server that is built and deployed\ninto OpenShift.\n\nInstallation instructions\n=========================\n\nTo install this application into your OpenShift namespace, run the following\ncommand:\n\n.. code-block:: console\n\n   oc project \u003cYOUR-NAMESPACE-GOES-HERE\u003e\n   oc process -f https://raw.githubusercontent.com/fridex/s2i-example-micropipenv/master/openshift.yaml | oc apply -f -\n\nAfter triggering the given command the application named\n\"s2i-example-micropipenv\" should be built in your namespace.\n\nmicropipenv lock file discovery\n===============================\n\nCheck `micropipenv documentation\n\u003chttps://github.com/thoth-station/micropipenv\u003e`_ for the automatic lock file\ndiscovery.  micropipenv looks for files describing dependencies in the\nfollowing order:\n\n1. Pipenv files - ``Pipfile.lock`` and ``Pipfile``\n2. Poetry files - ``poetry.lock`` and ``pyproject.toml``\n3. requirements.txt files for ``pip-tools`` style requirements or raw requirements.txt\n\nAs micropipenv unifies build log output across all the dependency managers, it\nmight be not directly visible what file is used (DEBUG mode can be helpful for\nthis case). To distinguish which file was used as a source for requirements,\nthis demo pins different versions of Flask for different cases.\n\nDemo Pipenv support\n===================\n\nTo test Python s2i with Pipenv functionality, run application without any\nchanges (Pipenv has the highest priority). Based on the lock file, you should\nbe able to see Flask in version 1.0.1 installed and the application should be\nrunning.\n\n.. figure:: https://raw.githubusercontent.com/fridex/s2i-example-micropipenv/master/fig/pipfile_lock.png\n   :alt: Build log screen shot (part of it).\n   :align: center\n\nDemo Poetry support\n===================\n\nNow, let's rename our ``Pipfile.lock`` so micropipenv does not find it and\nfallbacks to Poetry style requirements:\n\n.. code-block:: console\n\n  mv Pipfile.lock Pipfile.lock_bac\n\nLet's start the build and use the content of the local directory as a package\nsource (to avoid committing to Git):\n\n.. code-block:: console\n\n  oc start-build --from-dir=. s2i-example-micropipenv\n\nAs Poetry style requirements are used, you should be able to see Flask in\nversion 1.0.3 being installad. The Python s2i build process prints the\ninstalled stack onto standard error output (to unify logs, ``Pipfile.lock``\nformat is used). Mind the logs are identical with the scenario before where we\nused Pipenv (the difference is in Flask version).\n\nDemo pip-tools support\n======================\n\nLet's perform similar operation as before to let micropipenv install\ndependencies from ``requirements.txt`` that have lowest priority:\n\n\n.. code-block:: console\n\n  mv poetry.lock poetry.lock_bac\n\nAnd start the build process once again:\n\n.. code-block:: console\n\n  oc start-build --from-dir=. s2i-example-micropipenv\n\nThe ``requirements.txt`` file pins down Flask to version 1.1.1. You should see\nthis version of Flask being installed in the OpenShift's build logs.\n\nNote the ``requirements.txt`` file was produced using ``pip-tools`` with\n``--require-hashes`` being set. Note the build log has identical structure as\nin the previous Pipenv and Poetry scenarios (the difference is in Flask version).\n\nDemo pip support\n================\n\nNow, let's demo the last use case - ``requirements.txt`` does not state full\nstack of Python libraries that should be installed. This is a bad practice as\nthe application deployed hasn't all stated dependencies. The packages\ninstalled can be different if you trigger the build tomorrow or one year later.\nIt's also harder for maintainers (assuming source code only access) to track\ndown what packages the developer used to run the application.\n\n.. code-block:: console\n\n  mv requirements.txt requirements.txt{,_bac}\n  mv requirements_unpinned.txt requirements.txt\n\nAfter triggering the build, you should see a big warning about unpinned Python\napplication stack produced:\n\n.. code-block:: console\n\n  oc start-build --from-dir=. s2i-example-micropipenv\n\nTo notify Python s2i user what packages are installed, micropipenv populates\n``pip freeze`` output to Python s2i build logs.\n\n.. figure:: https://raw.githubusercontent.com/fridex/s2i-example-micropipenv/master/fig/requirements_unpinned.png\n   :alt: Warning produced when Python requirements are not pinned down.\n   :align: center\n\nExplictly specifying requirements file\n======================================\n\nYou can also provide ``MICROPIPENV_METHOD`` environment variable to the\nOpenShift build process to make sure your desired installation method is used.\nRefer to micropipenv docs for more info. See also ``openshift.yaml`` and\ncomments in the build configuration.\n\nmicropipenv vs Pipenv size\n==========================\n\nLet's compare size needed for installing Pipenv and micropipenv (size and\nsoftware shipped to prod matters) - the test was done on Fedora 31 with Python\n3.7:\n\n.. code-block:: console\n\n  $ python3 -m venv venv_pipenv\n  $ . venv_pipenv/bin/activate\n  $ du -s -B1 venv_pipenv\n  11210752\tvenv_pipenv\n  $ pip3 install pipenv\n  $ du -s -B1 venv_pipenv\n  42049536\tvenv_pipenv\n  $ deactivate\n\n\nAnd now with micropipenv:\n\n.. code-block:: console\n\n  $ python3 -m venv venv_micropipenv\n  $ . venv_micropipenv/bin/activate\n  $ du -s -B1 venv_micropipenv\n  11210752      venv_micropipenv\n  $ pip3 install 'micropipenv[toml]'\n  $ du -s -B1 venv_micropipenv\n  11595776      venv_micropipenv\n  $ deactivate\n\nThat's 30453760 bytes (30.4 Megabyte) difference!\n\nClean up\n========\n\nTo clean up your name space after the demo, you can run the following command:\n\n\n.. code-block:: console\n\n  $ oc delete -l app=s2i-example-micropipenv bc,is,dc,route,svc\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffridex%2Fs2i-example-micropipenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffridex%2Fs2i-example-micropipenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffridex%2Fs2i-example-micropipenv/lists"}