{"id":20518033,"url":"https://github.com/fridex/virtualenv-cache","last_synced_at":"2025-03-05T23:42:01.976Z","repository":{"id":191678772,"uuid":"684161155","full_name":"fridex/virtualenv-cache","owner":"fridex","description":"Manage cache of Python environments","archived":false,"fork":false,"pushed_at":"2023-08-30T17:00:27.000Z","size":28,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T20:35:42.287Z","etag":null,"topics":["packaging","packaging-python","packaging-tools","python","python3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/virtualenv-cache","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","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":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-28T15:23:02.000Z","updated_at":"2025-01-22T03:13:02.000Z","dependencies_parsed_at":"2023-08-31T04:25:27.163Z","dependency_job_id":"79481d8f-224a-4142-bfdd-6ee27d0d9f05","html_url":"https://github.com/fridex/virtualenv-cache","commit_stats":null,"previous_names":["fridex/virtualenv-cache"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridex%2Fvirtualenv-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridex%2Fvirtualenv-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridex%2Fvirtualenv-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridex%2Fvirtualenv-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fridex","download_url":"https://codeload.github.com/fridex/virtualenv-cache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242123190,"owners_count":20075344,"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":["packaging","packaging-python","packaging-tools","python","python3"],"created_at":"2024-11-15T21:38:13.766Z","updated_at":"2025-03-05T23:42:01.947Z","avatar_url":"https://github.com/fridex.png","language":"Python","readme":"virtualenv-cache\n----------------\n\nManage a cache of virtual environments based on changes in requirements files.\n\nAn example usage of this tool might be a CI system that executes a testsuite.\nIf there are no changes in requirements, a cached virtual environment already\navailable in the CI might be used. This environment can have all the\ndependencies already installed to speed up CI jobs.\n\nIf a new virtual environment is created, this virtual environment can be added\nto the cache to speed up next CI jobs.\n\nThis tool automatically manages the cache, lifetime of cache entries, and\nadditional cache parameters based on the supplied configuration file.\n\nInstallation\n============\n\nYou can install `the latest version from PyPI \u003chttps://pypi.org/project/virtualenv-cache\u003e`__:\n\n.. code-block:: console\n\n  pip install virtualenv-cache\n\nIf you wish to run the latest version from `the Git repository \u003chttps://github.com/fridex/virtualenv-cache\u003e`__:\n\n.. code-block:: console\n\n  pip install git+https://github.com/fridex/virtualenv-cache@latest\n\nUsage\n=====\n\nFirst, there needs to be generated a configuration file:\n\n.. code-block:: console\n\n  virtualenv-cache init\n\nThe command above will create a configuration file in the current directory (by\ndefault) called ``.virtualenv_cache.toml``. Check its configuration options as\ndescribed below to match your desired behavior. This file has be generated per\nproject that should be using the cache and should be part of the project code\nbase - e.g. committed to the Git repository so that it can be used on a clone.\n\nNext, your configuration in a CI can look similar to the code snipped bellow:\n\n.. code-block::\n\n  cd project-root/\n  virtualenv-cache restore\n  [ $? -eq 1 ] \u0026\u0026 ( python3 -m venv .venv \u0026\u0026 source .venv/bin/activate \u0026\u0026 pip install -r requirements.txt \u0026\u0026 virtualenv-cache store )\n\nThe code snipped above will try to restore a virtual environment from cache.\nIf there is no matching cached virtual environment, the ``restore`` command\nexists with exit code of 1 indicating cache miss. In that case, the virtual\nenvironment can be created and prepared for the next runs which will result in\na cache hit (unless there is a change in requirements files which results in a\nnew virtual environment creation that will get cached again). Just make sure\nyou keep all the requirements installed in your virtual environment and have\nthem stated in ``requirements_lock_paths``.\n\nConfiguration file\n==================\n\nThe configuration file can be generated using ``virtualenv-cache init``. An\nexample of such configuration file:\n\n.. code-block:: toml\n\n  [virtualenv-cache]\n  cache_size = 25\n  cache_path = \"${HOME}/.virtualenv-cache/my-project/cache/\"\n  virtualenv_path = \".venv\"\n  requirements_lock_paths = [\n      \"requirements.txt\",\n      \"requirements-dev.txt\",\n      \"requirements-typing.txt\"\n  ]\n\n``cache_size``\n##############\n\nThe number of virtual environments cached. If the ``cache_size`` is reached,\nthe cache is trimmed based on use of virtual environments - only the most used\nvirtual environments based on datetime are kept in the cache.\n\n``cache_path``\n##############\n\nA path where cached virtual environments should be stored. If you use\n``virtualenv-cache`` to manage cache for multiple projects, make sure you\ndefine different ``cache_path`` for each of them.\n\nThe path configuration value can state environment variables which get\nexpanded.\n\n``virtualenv_path``\n###################\n\nA path where the virtual environment is created for the project. This path is\nused to copy the virtual environment into the cache or restored from the cache.\n\nThe path configuration value can state environment variables which get\nexpanded.\n\n``requirements_lock_paths``\n###########################\n\nA list of requirements files that affect installed dependencies in the virtual\nenvironment. There can be stated lock files, such as ``requirements.txt`` as\nproduced by `pip-tools \u003chttps://pypi.org/project/pip-tools/\u003e`__, a\n``poetry.lock`` file as produced by `Poetry \u003chttps://python-poetry.org/\u003e`__, a\n`pdm.lock \u003chttps://pdm.fming.dev/\u003e`__ file as produced by `PDM\n\u003chttps://pdm.fming.dev/\u003e`__, or a ``Pipfile.lock`` as produced by `Pipenv\n\u003chttps://github.com/pypa/pipenv\u003e`__.\n\nNote there are internally computed hashes of these files on their content\nwithout taking into account semantics. That means any change, even a new line,\nadded to the file affects a new cache entry creation. Generally, this does not\ncreate any issues as the old cache entries will get removed over time based on\nthe ``cache_size`` configuration option. This also mean that you can add any\nother file which content potentially affects virtual environment to this\nlisting.\n\nCommands\n========\n\nThe tool can be run with the following sub-commands:\n\n* ``virtualenv-cache store`` - store the curent virtual environment into the cache\n* ``virtualenv-cache restore`` - restore the matching virtual environment from the cache\n* ``virtualenv-cache init`` - initialize the configuration file\n* ``virtualenv-cache list`` - list entries in the cache with their additional\n  metadata, such as the last access time\n* ``virtualenv-cache erase`` - drop all cached virtual environments\n\nSee ``--help`` for more information and options available.\n\nAdditional notes\n================\n\nAll the CLI parameters can be supplied as environment variables:\n\n* ``VIRTUALENV_CACHE_CONFIG_PATH`` - a path to the ``virtualenv-cache`` configuration file\n* ``VIRTUALENV_CACHE_FORMAT`` - format used to print output to terminal\n* ``VIRTUALENV_CACHE_WORK_DIR`` - a working directory for the CLI\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffridex%2Fvirtualenv-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffridex%2Fvirtualenv-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffridex%2Fvirtualenv-cache/lists"}