Code Monkey home page Code Monkey logo

devpi-enterprisey's Introduction

logo devpi-enterprisey

Augmentation of the awesome devpi project with ‘enterprisey’ requirements, configuration, and deployment.

Apache 2.0 licensed

Table of Contents

Overview

This project provides the following components:

  • Debian Packaging – read the docs on how to build and install a devpi release as a DEB package, contained in a Python virtualenv.
  • Puppet Deployment – see the example node definition in site.pp on how to install devpi-server behind a NginX proxy, using the devpi-puppet module.
  • The wiki contains some articles with details on different aspects of using devpi in an enterprise work environment.

How-Tos

Installing the ‘devpi’ client into your home

The following is an easy way to install the client on systems not derived from Debian (for Debian packaging, see above link). It uses pipsi to create a dedicated virtualenv for devpi-client.

grep '/.local/bin:' ~/.bash_aliases >/dev/null 2>&1 ||
    echo 'grep ":$HOME/.local/bin:" <<<":$PATH:" >/dev/null || export PATH="$HOME/.local/bin:$PATH"' >>~/.bash_aliases
source ~/.bash_aliases

which pipsi || curl https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py | python
which devpi || pipsi install devpi-client
devpi --version

The above command sequence is idempotent, i.e. you can repeat it as often as needed, in case of any problems.

Example for an index-per-team setup with shared global indexes

The following shows how an index setup for a department with multiple teams can look like – it tries to strike a balance between flexibility (i.e. independence and isolation of teams) and simplicity.

It's designed for the following requirements:

  • Give each team a space to share experimental and stable releases, under their control.
  • Provide a shared package pool, which consists of local reviewed releases, external releases not available on PyPI or patched locally, and finally the local PyPI proxy/cache.
  • Releases that are not team-internal must be pushed through a QA gateway towards the shared package pool, i.e. shared is owned by the QA team.

Sample Index Structure

All team indexes eventually lead to shared/stable, a virtual index that is not supposed to hold any packages, but only assemble other indexes into a common base for all teams. The shared/thirdparty-local index is the only one that needs its mirror_whitelist maintained (or set to *); «user»/dev is volatile, all others are not.

While the overall complexity of this setup can be staggering, it only ever reflects the complexity of your organization (having a lot of teams). The isolation it provides actually helps to cope with that, since a single developer only has to consider at most three of these indexes (his team's, and the virtual shared one). There is no need to co-ordinate their use with other teams, and the QA gateway ensures the integrity of the shared pool. In case you need to scale across several departments, you can simply apply the same pattern in a fractal way, or set up discrete instances of devpi-server.

Using devpi in Jenkins

First things first, every slave in your Jenkins farm should either get the devpi package installed, or else an equivalent install of devpi-client (e.g. by pipsi). Then add the devpi_use helper functions as described here into your Jenkins user's ~/.bashrc.

Each job is responsible to select the proper index to use, by issuing the following command early on in its build step (take notice of the underscore in devpi_use):

devpi_use shared/stable # select the proper index for your project
# Now an alias for "devpi" is set, that uses "${WORKSPACE}/.devpi" as its clientdir;
# also sets PIP_INDEX_URL, so you can do «pip install …» without further thoughts.

The shared/stable index should be set as the user's default, so if you only need internally released or external packages, you can simply use pip without any extra considerations. You then don't need the above command, since ~/.pip/pip.conf is used. The final step of preparation is to install your project's requirements via a requirements.txt as usual

❢❢❢ Do NOT use devpi directly with --set-cfg or without a --clientdir pointing into your workspace on Jenkins, you'd otherwise create a hell of race conditions for yourself and others! Also, related config files shouldn't be writable anyway to prevent exactly that.

SSL certificate handling

Accessing your devpi server over a secure connection is recommended, and also silences that pesky pip warning about insecure connections. Unless your certificate is issued by a well-known authority, you have to provide clients with the root certificates you're using, either self-signed or local PKI ones.

To query where your devpi client gets its CA certificates from, you can use the following scary-looking but harmless command:

$(head -n1 $(command which devpi) | tr -d '#!') -m requests.certs

In case you have your root CA certificates on a Debian system properly installed so that update-ca-certificates sees them, all you need is this (preferably added to a file in /etc/profile.d):

export PIP_CERT="/etc/ssl/certs/ca-certificates.crt"
export REQUESTS_CA_BUNDLE="$PIP_CERT"

Otherwise, let's say you have a bunch of local CA or self-signed certificates in /usr/share/ca-certificates/acme.com, then the following will make them accessible to both devpi and pip:

company=acme.com
mkdir -p ~/.local
export PIP_CERT="$HOME/.local/cacert.pem"
export REQUESTS_CA_BUNDLE="$PIP_CERT"
cat >"$PIP_CERT" $($(head -n1 $(command which devpi) | tr -d '#!') -m requests.certs) /usr/share/ca-certificates/$company/*.crt

In case your devpi server is a virtual host and shares its IP with a bunch of other domains, you also need SNI support for Python 2 (SNI = Server Name Indication). To enable that, use your virtualenv's pip to install these packages:

pip install -U pip pyOpenSSL pyasn1 ndg-httpsclient

Note that we also update pip to the latest version here, since only recent ones can take advantage of the improved SSL packages. You might also need to provide a HTTP --index-url or activate a --proxy to perform this initial bootstrap – this is an example why it makes sense to keep a devpi server port for HTTP open for the time being.

Related Tickets

Related Projects

References

devpi-enterprisey's People

Contributors

chopmann avatar jhermann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

devpi-enterprisey's Issues

Doesn't work with 0.11 of dh_virtualenv helper

I believe this is due to it depending on the '--upgrade-pip' flag for dh_virtualenv. probably need to add a minimum version specifier somewhere.

Tested on Ubuntu Xenial.

dpkg-buildpackage: source package devpi
dpkg-buildpackage: source version 4.7.1-1~xenial
dpkg-buildpackage: source distribution xenial
dpkg-buildpackage: source changed by Juergen Hermann <[email protected]>
dpkg-buildpackage: host architecture amd64
 dpkg-source --before-build debianized-devpi
 debian/rules clean
test ! -d debian/sdist || rm -rf debian/sdist
rm debian/*.tar.gz
dh clean --setuptools --upgrade-pip --python /usr/bin/python3  --preinstall "setuptools>=17.1" --preinstall "wheel" --preinstall pytest --preinstall webtest 
   dh_testdir -O--setuptools -O--upgrade-pip -O--python=/usr/bin/python3 -O--preinstall=setuptools\>=17.1 -O--preinstall=wheel -O--preinstall=pytest -O--preinstall=webtest
   dh_auto_clean -O--setuptools -O--upgrade-pip -O--python=/usr/bin/python3 -O--preinstall=setuptools\>=17.1 -O--preinstall=wheel -O--preinstall=pytest -O--preinstall=webtest
   dh_clean -O--setuptools -O--upgrade-pip -O--python=/usr/bin/python3 -O--preinstall=setuptools\>=17.1 -O--preinstall=wheel -O--preinstall=pytest -O--preinstall=webtest
 debian/rules build
dh build --with python-virtualenv --sourcedir debian/sdist
   dh_testdir -O--sourcedir=debian/sdist
   debian/rules build-arch
make[1]: Entering directory '/devpi-enterprisey/debianized-devpi'
# TODO: This should be an orig-tarball
cd debian && curl -sLOkS https://files.pythonhosted.org/packages/8c/f5/d117c11aaab61862ba345d085a22b7574da607d3f4c29be7d9d07f906921/devpi-server-4.7.1.tar.gz
mkdir -p debian/sdist
tar -xz -C debian/sdist --strip-components=1 --exclude '*.egg-info' -f debian/*.tar.gz
echo "devpi-client==4.1.0 devpi-common==3.3.1 devpi-web==3.4.1 requests==2.19.1" "devpi-findlinks==2.0.0" | tr ' ,' '\n\n' >>debian/sdist/requirements.txt
dh build-arch --with python-virtualenv --sourcedir debian/sdist
   dh_testdir -a -O--sourcedir=debian/sdist
   dh_update_autotools_config -a -O--sourcedir=debian/sdist
   dh_auto_configure -a -O--sourcedir=debian/sdist
make[1]: Leaving directory '/devpi-enterprisey/debianized-devpi'
   dh_update_autotools_config -O--sourcedir=debian/sdist
   dh_auto_configure -O--sourcedir=debian/sdist
 debian/rules binary
dh binary --with python-virtualenv --sourcedir debian/sdist
   dh_testroot -O--sourcedir=debian/sdist
   dh_prep -O--sourcedir=debian/sdist
   dh_installdirs -O--sourcedir=debian/sdist
   dh_install -O--sourcedir=debian/sdist
   dh_installdocs -O--sourcedir=debian/sdist
   dh_installchangelogs -O--sourcedir=debian/sdist
   dh_installexamples -O--sourcedir=debian/sdist
   dh_installman -O--sourcedir=debian/sdist
   dh_installcatalogs -O--sourcedir=debian/sdist
   dh_installcron -O--sourcedir=debian/sdist
   dh_installdebconf -O--sourcedir=debian/sdist
   dh_installemacsen -O--sourcedir=debian/sdist
   dh_installifupdown -O--sourcedir=debian/sdist
   dh_installinfo -O--sourcedir=debian/sdist
   debian/rules override_dh_virtualenv
make[1]: Entering directory '/devpi-enterprisey/debianized-devpi'
dh_virtualenv --setuptools --upgrade-pip --python /usr/bin/python3  --preinstall "setuptools>=17.1" --preinstall "wheel" --preinstall pytest --preinstall webtest  --sourcedir debian/sdist
Usage: dh_virtualenv [options]

dh_virtualenv: error: no such option: --upgrade-pip
debian/rules:60: recipe for target 'override_dh_virtualenv' failed
make[1]: *** [override_dh_virtualenv] Error 2
make[1]: Leaving directory '/devpi-enterprisey/debianized-devpi'
debian/rules:57: recipe for target 'binary' failed
make: *** [binary] Error 2
dpkg-buildpackage: error: debian/rules binary gave error exit status 2```

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.