How to use docker+devpi to build local pypi source

How to use docker+devpi to build local pypi source

Some time ago, I needed to use pip downloads frequently for development. Although I changed the pip source to a domestic source, I was still not satisfied with the speed. More importantly, the integrated test environment was offline. To develop in the integrated test environment, I obviously needed to build my own local pip source. Before using devpi, I used pip2pi, but there was a bug that caused the tox command in an offline environment to always fail, so I finally used devpi to build the pip source. Docker deployment is used here, which is convenient and fast. If it crashes accidentally, you only need to re-run the docker container. If Docker is not installed in your environment, you can search for installation methods yourself, such as the Docker community's document Install Docker. If you are a CentOS user, you can install it using the following method

sudo yum update
sudo yum -y install docker
sudo systemctl enable docker
sudo systemctl start docker

Next, use docker to deploy a Python local image source. We can use the existing image on docker hub. I choose
muccg/devpi this image

# Set the devpi server administrator password DEVPI_PASSWORD = 123

mkdir -p /src/docker/devpi
mkdir /tmp/wheelhouse

docker run -d --name devpi \
  --publish 3141:3141 \
  --volume /tmp/wheelhouse:/wheelhouse
  --volume /srv/docker/devpi:/data \
  --env=DEVPI_PASSWORD=$DEVPI_PASSWORD \
  --restart always \
  muccg/docker-devpi

Next, download the required wheel package locally. The content of the requirements.txt file is the list of Python libraries we need.

pip wheel --wheel-dir /tmp/wheelhouse -r requirements.txt

If the library downloaded from pip is already a wheel package, the file will be placed directly in /tmp/wheelhouse.
tar package, pip will first build a wheel package, which may take some time. After the download is complete, the content of wheelhouse is similar to

ll /tmp/wheelhouse
total 524K
-rwxrwxrwx 1 rookie rookie 155K Apr 6 23:40 certifi-2019.3.9-py2.py3-none-any.whl
-rwxrwxrwx 1 rookie rookie 131K Apr 6 23:40 chardet-3.0.4-py2.py3-none-any.whl
-rwxrwxrwx 1 rookie rookie 58K Apr 6 23:40 idna-2.8-py2.py3-none-any.whl
-rwxrwxrwx 1 rookie rookie 57K Apr 6 23:40 requests-2.21.0-py2.py3-none-any.whl
-rwxrwxrwx 1 rookie rookie 116K Apr 6 23:40 urllib3-1.24.1-py2.py3-none-any.whl

After the download is complete, if the local environment has the devpi client installed, you can directly upload the wheel package, but since we have already

Mount wheelhouse folder into the container, or you can operate directly in the container

# Enter the container docker exec -it -u root devpi bash

# Log in and upload devpi use http://<host_ip>:3141/root/public --set-cfg
devpi login root 123
devpi upload --from-dir /wheelhouse

After uploading is complete, you can use http://<host_ip>:3141 to view the status of the pip local source server.

For temporary use, you can use pip install's --index and --trusted-host options

pip install --index http://<host_ip>:3141/root/public/+simple/ \
      --trusted-host <host_ip>

Or modify the pip.conf file to use it permanently

# vim ~/.pip/pip.conf
[global]
index_url = http://<host_ip>:3141/root/public/+simple/
trusted-host = <host_ip>
[search]
index = http://<host_ip>:3141/root/public/

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to use the Python packaging module wheel and publish Python packages to PyPI
  • How to upload packages to pypi in python
  • How to use Docker to build a pypi private repository
  • Detailed explanation of the process of building a pypi private warehouse
  • Perfect solution to the pyinstaller packaging error that cannot find the dependency pypiwin32 or pywin32-ctypes
  • How to publish Python packages to PyPI and create whl files
  • Python self-made package and use pip to avoid submitting to pypi and only install it to the local machine [recommended]
  • Use the domestic pypi source provided by Douban
  • Python uploads package to Pypi (simple code)
  • How to install third-party libraries from non-PyPI official website using pip in Python
  • How to upload your own modules to pypi

<<:  Detailed explanation of how to use the mysql backup script mysqldump

>>:  Understanding Vuex in one article

Recommend

mysql backup script and keep it for 7 days

Script requirements: Back up the MySQL database e...

MySQL 5.7.18 Installer installation download graphic tutorial

This article records the detailed installation tu...

The easiest way to reset mysql root password

My mysql version is MYSQL V5.7.9, please use the ...

CentOS installation mysql5.7 detailed tutorial

This article shares the detailed steps of install...

General Guide to Linux/CentOS Server Security Configuration

Linux is an open system. Many ready-made programs...

How to find identical files in Linux

As the computer is used, a lot of garbage will be...

Detailed explanation of Vue's caching method example

Recently, a new requirement "front-end cache...

Two ways to reset the root password of MySQL database using lnmp

The first method: Use Junge's one-click scrip...

MySQL scheduled database backup operation example

This article describes the example of MySQL sched...

jQuery achieves the shutter effect (using li positioning)

This article shares the specific code of jQuery t...

Detailed explanation of group by and having in MySQL

The GROUP BY syntax can group and count the query...

MySQL data types full analysis

Data Type: The basic rules that define what data ...