{"id":13398295,"url":"https://github.com/spotify/dh-virtualenv","last_synced_at":"2025-05-14T22:08:39.616Z","repository":{"id":41086481,"uuid":"13451234","full_name":"spotify/dh-virtualenv","owner":"spotify","description":"Python virtualenvs in Debian packages","archived":false,"fork":false,"pushed_at":"2024-04-27T01:41:37.000Z","size":446,"stargazers_count":1620,"open_issues_count":39,"forks_count":185,"subscribers_count":40,"default_branch":"master","last_synced_at":"2025-05-11T10:57:00.783Z","etag":null,"topics":["debian","debian-packages","dh-virtualenv","omnibus-packages","python"],"latest_commit_sha":null,"homepage":"http://dh-virtualenv.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spotify.png","metadata":{"files":{"readme":"README.md","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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-10-09T19:03:43.000Z","updated_at":"2025-05-10T19:44:33.000Z","dependencies_parsed_at":"2023-02-01T07:15:34.098Z","dependency_job_id":"5d964896-cad3-4b89-9c1e-d2595c029051","html_url":"https://github.com/spotify/dh-virtualenv","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2Fdh-virtualenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2Fdh-virtualenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2Fdh-virtualenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2Fdh-virtualenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spotify","download_url":"https://codeload.github.com/spotify/dh-virtualenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235700,"owners_count":22036964,"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":["debian","debian-packages","dh-virtualenv","omnibus-packages","python"],"created_at":"2024-07-30T19:00:22.143Z","updated_at":"2025-05-14T22:08:34.596Z","avatar_url":"https://github.com/spotify.png","language":"Python","readme":"# dh-virtualenv\n\n[![Build Status](https://travis-ci.org/spotify/dh-virtualenv.png)](https://travis-ci.org/spotify/dh-virtualenv)\n[![Docs](https://readthedocs.org/projects/dh-virtualenv/badge/)](http://dh-virtualenv.readthedocs.io/en/latest/)\n\n**Contents**\n\n  * [Overview](#overview)\n  * [Presentations, Blogs \u0026 Other Resources](#presentations-blogs--other-resources)\n  * [Using dh-virtualenv](#using-dh-virtualenv)\n  * [How does it work?](#how-does-it-work)\n  * [Running tests](#running-tests)\n  * [Building the package in a Docker container](#building-the-package-in-a-docker-container)\n  * [Building the documentation locally](#building-the-documentation-locally)\n  * [Releasing a new version](#releasing-a-new-version)\n  * [Code of conduct](#code-of-conduct)\n  * [License](#license)\n\n\n## Overview\n\ndh-virtualenv is a tool that aims to combine Debian packaging with\nself-contained virtualenv based Python deployments.\n\nThe idea behind dh-virtualenv is to be able to combine the power of\nDebian packaging with the sandboxed nature of virtualenvs. In addition\nto this, using virtualenv enables installing requirements via\n[Python Package Index](https://pypi.org) instead of relying on\nthe operating system provided Python packages. The only limiting\nfactor is that you have to run the same Python interpreter as the\noperating system.\n\nFor complete online documentation including installation instructions, see\n[the online documentation](https://dh-virtualenv.readthedocs.io/en/latest/).\n\n\n## Presentations, Blogs \u0026 Other Resources\n\nHere are a few external resources that can help you\nto get a more detailed first impression of dh-virtualenv,\nor advocate its use in your company or project team.\n\n* [How We Deploy Python Code](https://www.nylas.com/blog/packaging-deploying-python/)\n  – Building, packaging \u0026 deploying Python using versioned artifacts in Debian packages at Nylas.\n* [DevOps Tool Bazaar](https://speakerdeck.com/jhermann/devops-karlsruhe-meetup-2018-02-20)\n  – Slide deck presented at the DevOps Karlsruhe Meetup in February 2018, regarding Python software deployment for Debian with a practical example.\n* [The Architecture of Open Source Applications: Python Packaging](http://aosabook.org/en/packaging.html)\n  – This provides a lot of background (and possibly things you didn't know) about the Python side of packaging.\n\n\n## Using dh-virtualenv\n\nUsing dh-virtualenv is fairly straightforward. First, you need to\ndefine the requirements of your package in `requirements.txt` file, in\n[the format defined by pip](https://pip.pypa.io/en/latest/user_guide.html#requirements-files).\n\nTo build a package using dh-virtualenv, you need to add dh-virtualenv\nin to your build dependencies and write following `debian/rules` file:\n\n      %:\n              dh $@ --with python-virtualenv\n\nNote that you might need to provide\nadditional build dependencies too, if your requirements require them.\n\nAlso, you are able to define the root path for your source directory using\n`--sourcedirectory` or `-D` argument:\n\n      %:\n              dh $@ --with python-virtualenv --sourcedirectory=root/srv/application\n\nNOTE: Be aware that the configuration in debian/rules expects tabs instead of spaces!\n\nOnce the package is built, you have a virtualenv contained in a Debian\npackage and upon installation it gets placed, by default, under\n`/opt/venvs/\u003cpackagename\u003e`.\n\nFor more information and usage documentation, check the accompanying\ndocumentation in the `doc` folder, also available at\n[Read the Docs](https://dh-virtualenv.readthedocs.io/en/latest/).\n\n\n## How does it work?\n\nTo do the packaging, *dh-virtualenv* extends debhelper's sequence by\ninserting a new `dh_virtualenv` command, which effectively replaces\nthe following commands in the original sequence:\n\n* `dh_auto_clean`\n* `dh_auto_build`\n* `dh_auto_test`\n* `dh_auto_install`\n* `dh_python2`\n* `dh_pycentral`\n* `dh_pysupport`\n\nIn the new sequence, `dh_virtualenv` is inserted right before `dh_installinit`.\n\n\n## Running tests\n\n    $ nosetests ./test/test_deployment.py\n\n\n## Building the package in a Docker container\n\nTo build ``dh-virtualenv`` itself in a Docker container, call ``docker build --tag dh-venv-builder .``.\nThis will build the DEB package for Debian stable by default.\nAdd e.g. ``--build-arg distro=ubuntu:bionic`` to build for Ubuntu LTS instead.\n\nThe resulting files must be copied out of the build container, using these commands:\n\n```sh\nmkdir -p dist \u0026\u0026 docker run --rm dh-venv-builder tar -C /dpkg -c . | tar -C dist -xv\n```\n\nThere is also a short-cut for all this, in the form of ``invoke bdist_deb [--distro=‹id›:‹codename›]``.\n\n\n## Building the documentation locally\n\nIf you execute the following commands in your clone of the repository,\na virtualenv with all necessary tools is created.\n``invoke docs`` then builds the documentation into ``doc/_build/``.\n\n```sh\ncommand . .env --yes --develop\ninvoke docs\n```\n\nTo **start a watchdog that auto-rebuilds documentation** and reloads the opened browser tab on any change,\ncall ``invoke docs -w -b`` (stop the watchdog using the ``-k`` option).\n\n\n## Releasing a new version\n\nFollow these steps when creating a new release:\n\n1. Check version in `dh_virtualenv/_version.py` and `debian/changelog`.\n1. Make sure `doc/changes.rst` is complete.\n1. Bump release date in `debian/changelog` (`dch -r`).\n1. Tag the release and `git push --tags`.\n1. Edit release entry on GitHub (add changes).\n1. Update the *Ubuntu PPA*.\n1. Bump to next release version in `dh_virtualenv/_version.py`.\n1. Open new section in `debian/changelog` (with `…-0.1+dev` added).\n1. Open a new section in `doc/changes.rst`, so it can be maintained as features are added!\n\n\n## Code of conduct\n\nThis project adheres to the [Open Code of Conduct][code-of-conduct].\nBy participating, you are expected to honor this code.\n\n\n## License\n\nCopyright (c) 2013-2017 Spotify AB\n\ndh-virtualenv is licensed under GPL v2 or later. Full license is\navailable in the `LICENSE` file.\n\n[code-of-conduct]: https://github.com/spotify/code-of-conduct/blob/master/code-of-conduct.md\n","funding_links":[],"categories":["Distribution","Python","分发","virtualenv","Distribution [🔝](#readme)","Awesome Python"],"sub_categories":["Distribution"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspotify%2Fdh-virtualenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspotify%2Fdh-virtualenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspotify%2Fdh-virtualenv/lists"}