Install Helpers
Helpers Distribution Package
-
This document describes how to build, distribute and install the
helperspackage -
Note for dev/data science members: if you are looking for how to install packages for your daily work, go to Client Configuration.
Creating and installing the package
PyPI local file
- You can create the
helperspackage with:
```bash
cd helpers python setup.py bdist_wheel ```
-
This creates a file
dist/helpers-1.0.0-py3-none-any.whlthat contains the package -
You can install the package with: ```
python -m pip install dist/helpers-1.0.0-py3-none-any.whl ```
PyPI workflow
-
This section describes a temporary solution while we build the CI pipeline.
-
The maintainer of
helperspackage after merging changes ofhelpers/intomaster, should run: -
Edit or create a
~/.pypircfile with:
ini
[distutils]
index-servers =
part
[part]
username:<upload_pypi_username>
password:<upload_pypi_passwd>
-
Update the
helpers/CHANGELOGand add version -
Edit
setup.py, changingversionin accordance inCHANGELOG, updateinstall_requiresparameters. -
Run
python setup.py sdist upload -r part
PyPI server installation
General Information
- We use pypiserver as a corporate
PyPI Index server for installing
pip - It implements the same interfaces as PyPI, allowing
standard Python packaging tooling such as
pipto interact with it as a package index just as they would with PyPI - The server is based on bottle and serves packages from regular directories
- Wheels, bdists, eggs can be uploaded either with
pip,setuptoolsor simply copied withscpto the server directory
Client Configuration / Installation
You have two options:
-
Since
pypiserverredirectspip installto the pypi.org index if it doesn't have a requested package, it is a good idea to configure them to always use your local pypi index. -
For pip command this can be done by setting the environment variable
PIP_EXTRA_INDEX_URL
```bash
export PIP_EXTRA_INDEX_URL=http://172.31.36.23:8855/simple/ ```
or by adding the following lines to ~/.pip/pip.conf:
ini
[global]
extra-index-url = http://172.31.36.23:8855/simple/
trusted-host = 172.31.36.23
- Manual installation:
```bash
pip install --extra-index-url http://172.31.36.23:8855/simple --trusted-host 172.31.36.23 helpers ```
or
```bash
pip install --extra-index-url http://172.31.36.23:8855 helpers ```
- Search hosted packages:
```bash
pip search --index http://172.31.36.23:8855 ... ```
- Note that pip search does not currently work with the /simple/ endpoint.
Server Details
Simple Index WebUI: http://172.31.36.23:8855/simple
Host: ubuntu@172.31.36.23
Runtime: by docker (standalone container)
Server Configuration
-
The corporate PyPI Index server runs with Docker as a standalone container with mapped volumes on the host.
-
All corporate packages serve from host directory:
/home/ubuntu/pypi/packages -
Uploading a new packages or updates existing packages password-protected. Only authorized user can upload packages. Authorized user credential serves from host Apache-Like authentication file:
/home/ubuntu/pypi/.htpasswd. -
Credential details you can find on the server in a file
~/.pypi_credentials -
To serve packages and authenticate against local
.htpasswd:
```bash
docker run -d -p 8855:8080 -v ~/pypi/packages:/data/packages -v ~/pypi/.htpasswd:/data/.htpasswd --restart=always pypiserver/pypiserver:latest -v -P .htpasswd packages ```
Limitation
- The
pypiserverdoes not implement the full API as seen on PyPI. It implements just enough to makepip install, andsearchwork.
Links
Code organization in helpers
- In
helpersthe following hierarchy should be respected: repo_config.pyhwarnings,hserver,hlogginghdbghintrospection,hprinthenv,hsystem,hio,hversio-
hgit -
A library should only import libs that precede it or are on the same level in the hierarchy above.
- E.g.
henvcan importhdbg,hprintandhio, but it cannot importhgit. - While importing a lib on the same level, make sure you are not creating an import cycle.
- For more general infomation, see all.imports_and_packages.how_to_guide.md.