Git Product home page Git Product logo

venvjail's Introduction

venvjail

Create Python virtualenvs (venv) in OBS.

This tool helps with the creation and management of Python virtual environments in OBS. Is initially designed to deal with the creation of venvs for OpenStack services, but can be generalized for other cases.

Basic usage

To build a venv in OBS we can use the sub-command create. This command will expect a place where all the RPMs are stored. By default OBS will generate a directory where all the RPMs that belong the dependency graph closure are stored. You can change this directory with the --repo parameter.

The command create will create a venv and store the RPM contents inside the venv directory. To decide the RPM that belong to the venv, two new files are used: include-rpm and exclude-rpm.

Both files are using Python regular expressions to indicate name of packages that will be included or excluded from the venv. The file include-rpm will list the RPM package names that can be included in the venv, and exclude-rpm will list the names of the packages that we do not expect for find in the venv. venvjail will iterate over the list of packages in the repository, and if the package is in include-rpm but not in exclude-rpm, will be installed inside the venv directory.

We can use both files to separate the packages that belongs to the operating system, from the one that belong to the venv. So for example, if a package that comes from the operating system is not listed in include-rpm, or is explicitly listed in exclude-rpm, it will not be installed in the venv. Because by default the venv is build with a system-site package access, a zypper up will update the package from outside the venv and a restart of the service that live inside the venv will see now the new version of the package.

This venv is later reallocated to an specific directory (parameter --relocate). This will fix the Python shebangs from the binaries, the venv activators and the systemd services.

Automatic generation of the files

Both files include-rpm and exclude-rpm can be automatically regenerated from venvjail. By default the program will check what packages belong to a repository in OBS, and this list will be considered to build include-rpm. So all the required packages that are living in a different repository will not be installed in the venv.

By default exclude-rpm is generated to explicitly exclude the Python2 and Python3 binaries, devel, test and doc packages. We can extend this list manually (or adjust the source code to generate a more informed list of packages)

Automatic maintenance of the spec file

A spec file require to list the BuildRequires and the Requires of the packages. The script can help us via the binary and requires commands. The first one will list the binary packages from a source package. If we add this list as a BuildRequires in the spec file, OBS will resolve all the dependencies that will build the minimal graph of packages that are needed for the creation of the venv.

Because there are packages that are needed in the venv, but are living outside it (because are excluded or not included in the initial list of RPMs), in order to install the new venv, those packages needs to be co-installed together. The command requres can help us to make this list. This command will download the source spec file from the package what we want to build the venv for, and get the list of requirements. Later will get the sublist of packages that are missing form the venv.

venvjail's People

Contributors

aplanas avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.