{"id":13494781,"url":"https://github.com/kevinconway/rpmvenv","last_synced_at":"2025-03-28T14:31:53.027Z","repository":{"id":27653546,"uuid":"31138911","full_name":"kevinconway/rpmvenv","owner":"kevinconway","description":"RPM packager for Python virtualenv.","archived":false,"fork":false,"pushed_at":"2024-01-11T17:26:41.000Z","size":171,"stargazers_count":153,"open_issues_count":5,"forks_count":36,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-01-06T04:10:05.768Z","etag":null,"topics":["packaging","python","rpm","rpmbuild","rpmbuilder","virtualenv"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kevinconway.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING","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":"2015-02-21T20:03:40.000Z","updated_at":"2024-08-26T14:56:24.000Z","dependencies_parsed_at":"2024-06-20T23:24:54.047Z","dependency_job_id":"e8feee21-c50e-452f-ade3-213b7d3f832d","html_url":"https://github.com/kevinconway/rpmvenv","commit_stats":{"total_commits":129,"total_committers":22,"mean_commits":5.863636363636363,"dds":0.4651162790697675,"last_synced_commit":"88fad01f8fc257a6b692724899d2a1aa47510680"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinconway%2Frpmvenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinconway%2Frpmvenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinconway%2Frpmvenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinconway%2Frpmvenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevinconway","download_url":"https://codeload.github.com/kevinconway/rpmvenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246046103,"owners_count":20714905,"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","python","rpm","rpmbuild","rpmbuilder","virtualenv"],"created_at":"2024-07-31T19:01:28.105Z","updated_at":"2025-03-28T14:31:52.566Z","avatar_url":"https://github.com/kevinconway.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"=======\nrpmvenv\n=======\n\n*RPM package helper which support packaging Python virtual environments.*\n\n-   `Basic Usage \u003c#basic-usage\u003e`_\n\n-   `Customizing \u003c#customizing\u003e`_\n\n    -   `Core \u003c#core\u003e`_\n\n    -   `Blocks \u003c#blocks\u003e`_\n\n    -   `File Permissions \u003c#file-permissions\u003e`_\n\n    -   `Additional Files \u003c#additional-files\u003e`_\n\n    -   `Python Virtualenv \u003c#python-virtualenv\u003e`_\n\n    -   `CLI Flags And Environment Variables \u003c#cli-flags-and-environment-variables\u003e`_\n\n    -   `Additional Options \u003c#additional-options\u003e`_\n\n-   `NOTE: python 2 support \u003c#note-python-2-support\u003e`_\n\n-   `NOTE: manylinux \u003c#note-manylinux\u003e`_\n\n-   `NOTE: unicode \u003c#note-unicode\u003e`_\n\n-   `NOTE: system python \u003c#note-system-python\u003e`_\n\n-   `NOTE: bdist eggs with scripts \u003c#note-bdist-eggs-with-scripts\u003e`_\n\n-   `Testing \u003c#testing\u003e`_\n\n-   `License \u003c#license\u003e`_\n\n-   `Contributing \u003c#contributing\u003e`_\n\nBasic Usage\n===========\n\nIn order to package a Python project in an RPM containing a virtualenv drop\na file in your repository root with a '.json' extensions and the following\ncontent. Change the values where appropriate.\n\n.. code-block:: javascript\n\n    {\n        \"extensions\": {\n            \"enabled\": [\n                \"python_venv\",\n                \"blocks\"\n            ]\n        },\n        \"core\": {\n            \"group\": \"Application/System\",\n            \"license\": \"MIT\",\n            \"name\": \"some-rpm-package-name\",\n            \"summary\": \"short package summary\",\n            \"version\": \"1.2.3\"\n        },\n        \"python_venv\": {\n            \"name\": \"name_of_venv_dir_to_create\",\n            \"path\": \"/path/where/to/install/venv\"\n        },\n        \"blocks\": {\n            \"desc\": [\n                \"some long package description\",\n                \"each array element is a new line\"\n            ]\n        }\n    }\n\nMake sure `rpmbuild \u003chttp://www.rpm.org\u003e`_ is installed.\nWith the configuration file in place run the command line tool installed with\nthe package to generate the RPM.\n\n.. code-block:: shell\n\n    rpmvenv path/to/the/config.json\n\nThis will generate a new RPM and place it in your current working directory.\n\nCustomizing\n===========\n\nWhile the above example will generate an installable RPM it has limitations.\nFor example, it does not set the user/group ownership of the packaged files,\nit does not include non-Python files such as init scripts, and it does not\nperform any post install actions. This project uses a plugin system for adding\nand enabling extra functionality. For convenience, some features ship with the\nproject already.\n\nCore\n----\n\nThe 'core' extension is always enabled. This extension provides the options\nfor interacting with all the required RPM SPEC file tags like \"Version\" or\n\"Url\". Current core options:\n\n.. code-block:: javascript\n\n    {\"core\":{\n        // The name of the RPM file which is generated.\n        \"name\": \"some-pkg-name\",\n        // The RPM version to build.\n        \"version\": \"1.2.3\",\n        // The release number for the RPM. Default is 1.\n        \"release\": \"1\",\n        // The short package summary.\n        \"summary\": \"a package for code\",\n        // The RPM package group in which this package belongs.\n        \"group\": \"Application/System\",\n        // The license under which the package is distributed.\n        \"license\": \"MIT\",\n        // The URL of the package source.\n        \"url\": \"https://projectsite.com\",\n        // The path to the package source. Defaults to the parent of the config.\n        \"source\": \"/path/to/my/source\",\n        // The name of the buildroot directory to use. Default is random temp dir.\n        \"buildroot\": \"%(mktemp -ud %{_tmppath}/%{SOURCE0}-%{version}-%{release}-XXXXXX)\",\n        // System dependencies.\n        \"requires\": [],\n        // Conflicting packages.\n        \"conflicts\": [],\n        // Packages to mark as obsolete.\n        \"obsoletes\": [],\n        // Virtual packages satisfied by this RPM.\n        \"provides\": []\n    }}\n\nBlocks\n------\n\nRPM files contain several sections, or blocks, which can contain multi-line\ncontent. Most blocks contain shell code used to build and install a project.\nThis extension is enabled by adding 'blocks' to the list of enabled extensions.\nEach block configuration item is a list of strings. Each string represents a\nline in the body of the block.\n\n.. code-block:: javascript\n\n    {\"blocks\" {\n        // Shell to execute on post-install.\n        \"post\": [],\n        // Shell to execute on post-uninstall.\n        \"postun\": [],\n        // Shell to execute on pre-install.\n        \"pre\": [],\n        // Shell to execute on pre-uninstall.\n        \"preun\": [],\n        // Shell to execute during the prep phase.\n        \"prep\": [],\n        // Shell to execute during the build phase.\n        \"build\": [],\n        // Shell to execute during the install phase.\n        \"install\": [],\n        // Shell to execute during the clean phase.\n        \"clean\": [],\n        // Long form description of the package.\n        \"desc\": [],\n        // A list of files which are included in the package.\n        \"files\": [],\n        // A list of the changes that have been done\n        \"changelog\": [],\n    }}\n\nFile Permissions\n----------------\n\nThis extension will set the user and group ownership properties of all files\nincluded with the package. It is enabled by adding 'file_permissions' to the\nlist of enabled extensions.\n\n.. code-block:: javascript\n\n    {\"file_permissions\": {\n        // The name of the user who should own the files.\n        \"user\": \"webserver\",\n        // The name of the group which should own the files.\n        \"group\": \"webserver\",\n        // If true, the user will be created during install if missing.\n        \"create_user\": false,\n        // If true, the group will be created during install if missing.\n        \"create_group\": false,\n    }}\n\nAdditional Files\n----------------\n\nThis extension will allow for packaging any files even if they are not a part\nof the built project. This extension is enabled by adding \"file_extras\" in the\nlist of enabled extensions. This extension also requires that\n'file_permissions' be enabled. It uses the same user and group to assign\nownership of the extra files by default but allows for individual files to have\nspecial permissions set. Source paths are relative to the root.\n\n.. code-block:: javascript\n\n    {\"file_extras\": {\n        \"files\": [\n            {\n                \"src\": \"somedir/project_init_script\",\n                \"dest\": \"etc/init.d/project\",\n            },\n            {\n                \"src\": \"somedir/with/perms\",\n                \"dest\": \"etc/with/perms\",\n                \"attr\": {\n                    \"permissions\": \"0644\",\n                    // Leaving user or group unspecified means they use the\n                    // default value from files_permissions.\n                    \"user\": \"testuser\",\n                    \"group\": \"testgroup\"\n                }\n            },\n            {\n                \"src\": \"somedir/readme\",\n                \"dest\": \"usr/share/doc/project/readme\",\n                \"doc\": true\n            },\n            {\n                \"src\": \"somedir/project.conf\",\n                \"dest\": \"etc/project.conf\",\n                // valid options include true, \"noreplace\", and \"missingok\"\n                \"config\": \"noreplace\"\n            },\n            // source:destination pairs (deprecated)\n            \"somedir/project_init_script:etc/init.d/project\"\n        ]\n    }}\n\nPython Virtualenv\n-----------------\n\nThis extension automates generating an RPM from a Python virtualenv. It is\nenabled by adding 'python_venv' to the list of enabled extensions.\n\n.. code-block:: javascript\n\n    {\"python_venv\": {\n        // The executable to use for creating a venv.\n        \"cmd\": \"virtualenv\",\n        // Flags to pass to the venv during creation.\n        \"flags\": [\"--always-copy\"],\n        // The name of the installed venv.\n        \"name\": \"project_venv\",\n        // The path in which to install the venv.\n        \"path\": \"/usr/share/python\",\n        // The python executable to use in the venv.\n        \"python\": \"python3.9\",\n        // Optional flag to enable building an rpm with, without a setup.py file. Default is true if not present.\n        \"require_setup_py\": true,\n        // Names of requirements files to install in the venv.\n        \"requirements\": [\"requirements.txt\"],\n        // Flags to pass to pip during pip install calls.\n        \"pip_flags\": \"--index-url https://internal-pypi-server.org\",\n        // Optional flag to enable, disable binary striping. Default is true if not present.\n        \"strip_binaries\": true,\n        // Optional flag to install the distribution into the venv with\n        // pip install, rather than setup.py install. Default is false if\n        // not present.\n        \"use_pip_install\": false,\n        // Optional flag to remove compiled bytecode from venv.\n        // It will reduce size of resulting package. Default is false if not present.\n        \"remove_pycache\": false,\n    }}\n\nCLI Flags And Environment Variables\n-----------------------------------\n\nIn addition to adding the above sections to a configuration file, all values\nmay also be given as command line flags to the 'rpmvenv' command as well as\nenvironment variables.\n\nCommand line flags follow a common pattern: '--extension_name_option_name'. A\ncommon use for this feature is setting the RPM package version over the CLI\nrather than hard coding it into a configuration file.\n\n.. code-block:: shell\n\n    rpmvenv /path/to/some/config.json --core_version=\"$(date -u +%Y.%m.%d.%H.%M.%S)\"\n\nThis CLI argument pattern may be used to set any options. Alternatively,\nenvironment variables can also be set using a similar naming scheme:\n'export RPMVENV_EXTENSION_NAME_OPTION_NAME=\"\"'. Setting the version with\nenvironment variables, for example:\n\n.. code-block:: shell\n\n    RPMVENV_CORE_VERSION=\"$(date -u +%Y.%m.%d.%H.%M.%S)\" \\\n    rpmvenv /path/to/some/config.json\n\nThe precedence order for options is configuration file, environment variables,\nthen CLI flags. That is, environment variables will always override items in\nthe configuration file and CLI flags will override both the file and the\nenvironment variables.\n\nAdditional Options\n------------------\n\nIn addition to the options for modifying the spec file, the following are also\navailable as CLI flags:\n\n-   --source\n\n    The path to a Python source repository. By default, this value resolves to\n    the directory containing the specified configuration file. It can be\n    overridden if the Python source is not adjacent the configuration file.\n\n-   --destination\n\n    The directory in which to place the RPM. The default value is the current\n    working directory.\n\n-   --spec\n\n    This flag disables the actual build in favour of printing the spec file\n    contents to stdout. Use this option if you need to manually verify the\n    spec file before running a build.\n\n-   --verbose\n\n    Normally, the stdout and stderr of the rpmbuild call are captured unless\n    there is an exception. Adding this flag enables the real-time output from\n    the rpmbuild command.\n\nNOTE: python 2 support\n======================\n\nPython 2, itself, was discontinued on 2020-01-01. Since then, libraries that\n`rpmvenv` depends on have started breaking compatibility with Python 2 or even\nadding code that prevents the use of that library in Python 2 regardless of\ncompatibility. It has also become increasingly difficult to support code that\nworks from Python 2.6 to the most recent versions of Python 3.\n\nThe last releases that support Python 2 are version `0.27.0` and `1.0.0`. These\nare both the same release. There will be no more releases in the `0.x` or `1.x`\nranges.\n\nIf you are using Python 2 then here is an example `requirements.txt` that has\ndependencies pinned to the last known versions that support Python 2:\n\n::\n\n    jinja2==2.11.3\n    venvctrl\u003e=0.5.0,\u003c2.0.0\n    argparse\u003e=1.4.0,\u003c2.0.0\n    confpy\u003e=0.11.0,\u003c2.0.0\n    ordereddict\u003e=1.1.0,\u003c2.0.0\n    semver\u003e=2.9.1,\u003c3.0.0\n\nNOTE: manylinux\n===============\n\nAs of 2019-05-26, the issue with packages generated as part of the\n`manylinux \u003chttps://github.com/pypa/manylinux\u003e`_ project appears to have\nbeen resolved. This means wheels containing universal linux binaries should\nwork as expected without any special options being enabled for `rpmvenv`.\n\nFor background, an issue was opened on 2017-02-01 that reported broken builds\nwhen one of the project dependencies was built using manylinux. The root cause\nappeared to be an incompatiblity between manylinux binaries and the standard\n`strip` system utility. Without being able to `strip` the binaries we were\nunable to remove metadata from those files which included the temporary RPM\nbuild root. RPM builds automatically fail if any file within the package\ncontains a reference to the build root.\n\nA test has been added to this project's suite that will fail if the manylinux\nproject issue with `strip` regresses. If the issues does regress you can\nrestore your builds by adding `strip_binaries=false` to the `venv` section of\nyour configuration and setting the `QA_SKIP_BUILD_ROOT=1` environment variable\nbefore running `rpmvenv`. The `strip_binaries=false` disables the call to\n`strip` and the `QA_SKIP_BUILD_ROOT=1` variable disables the RPM tool's check\nfor build root.\n\nNOTE: unicode\n=============\n\nAn issue was opened on 2018-09-01 showing a conflict between some Python\npackages and some environments. Notably, CentOS (and possibly others) default\nto having a global system encoding value set to `ASCII` rather than `UTF-8`.\nPython2.X opens files using the system encoding which results in several errors\nif any of the source code files contain non-ASCII characters. If you encounter\nthis issue then the easiest way to resolve it is to set the\n`LC_ALL=en_US.UTF-8` variable before running `rpmvenv`. This will adjust the\nglobal setting and enable processing of non-ASCII encoded files.\n\nNOTE: system python\n===================\n\nAn issue was opened on 2017-05-18 showing a build failure wnen using the\ndefault Python installations for some versions of CentOS, Fedora, and RedHat.\nThe issue manifests during the creation of the `virtualenv` and appears as\nsomething like `ImportError: No module named \\'time\\'` or other error messages\nreferencing Python built-ins. The cause appears to related to an\n`unresolved issue \u003chttps://github.com/pypa/virtualenv/issues/565\u003e`_ between the\naffected system distribution provided Python installations and `virtualenv`.\nThe only known fix for this issue is to re-build Python from source for any\naffected system.\n\nNOTE: bdist eggs with scripts\n=============================\n\nAn issue was opened on 2019-01-28 showing a build failure whenever the usual\n`python setup.py install` line was executed for a project that both contained\nscripts and triggered the `bdist` packaging path for an egg. For unknown\nreasons, the `bdist` egg package both installs scripts in the relevant `bin`\ndirectory _and_ retrains a copy within the egg directory. `rpmvenv` rewrites\nthe shebang paths in `bin` but does not account for the second copy in the\n`bdist` egg directory. The result is a build failure because the build root is\nreferenced in a file.\n\nThe way to resolve this issue is to use the `\"use_pip_install\": true` option\nwhich switches the installation method from `python setup.py install` to\n`pip install .`. These two methods result in different installation behavior\nbecause `pip` will always generate a wheel rather than an egg which does not\nsuffer from this issue.\n\nTesting\n=======\n\nThe included tests are written using py.test. There is also an included tox.ini\nwhich is configured to run the tests in addition to style checks. By default,\nthe integration tests run using rpmvenv as the target project to build.\nHowever, any project with a requirements.txt file in the repository root can\nbe specified with the '--python-git-url' flag while running the tests.\n\nLicense\n=======\n\n::\n\n    (MIT License)\n\n    Copyright (C) 2015 Kevin Conway\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to\n    deal in the Software without restriction, including without limitation the\n    rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n    sell copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in\n    all copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n    IN THE SOFTWARE.\n\n\nContributing\n============\n\nAll contributions to this project are protected under the agreement found in\nthe `CONTRIBUTING` file. All contributors should read the agreement but, as\na summary::\n\n    You give us the rights to maintain and distribute your code and we promise\n    to maintain an open source distribution of anything you contribute.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinconway%2Frpmvenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevinconway%2Frpmvenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinconway%2Frpmvenv/lists"}