Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of using docker+devpi to build local pypi source

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Some time ago, developers need to use pip to download frequently. Although the pip source has been changed to domestic source, I am still not satisfied with the speed. What is more important is integration.

The test environment is offline, and it is obvious that you need to build your own local pip source to develop in the integrated test environment. I used pip2pi before using devpi, but a bug caused the tox command to always fail in an offline environment, so I ended up using devpi to build the pip source. Using docker deployment here, it is convenient and fast, and if you accidentally break it, you just need to rerun the docker container. If your environment does not have docker installed, you can search for installation methods on your own, such as the docker community documentation install docker. If you are a Centos user, you can install it using the following methods

Sudo yum updatesudo yum-y install dockersudo systemctl enable dockersudo systemctl start docker

Next, we use docker to deploy a Python local mirror source. We can use the existing image on docker hub. I choose here.

The mirror image of muccg/devpi

# set the devpi server administrator password DEVPI_PASSWORD= 123mkdir-p / src/docker/devpimkdir / tmp/wheelhousedocker run-d-- name devpi\-- publish 3141src/docker/devpimkdir 3141\-- volume / tmp/wheelhouse:/wheelhouse-- volume / srv/docker/devpi:/data\-- env=DEVPI_PASSWORD=$DEVPI_PASSWORD\-- restart always\ muccg/docker-devpi

Then download the required wheel package locally, and 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 the pip source is already a wheel package, the file will be placed directly in / tmp/wheelhouse, if so

Tar package, pip will first build the wheel package, which may take some time. After the download is completed, the wheelhouse content is similar.

In

Ll / tmp/wheelhousetotal 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 completed, if the devpi client is installed in the local environment, you can upload the wheel package directly, but since we already created the container

Load the wheelhouse folder into it, or operate it directly in the container.

# enter the container docker exec-it-u root devpi bash#, log in and upload devpi use http://:3141/root/public-- set-cfgdevpi login root 123devpi upload-- from-dir / wheelhouse

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

To temporarily use the-- index and-- trusted-host options of pip install

Pip install-- index http://:3141/root/public/+simple/\-- trusted-host

Or modify the pip.conf file for permanent use

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

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report