当前位置:网站首页>5 minutes to learn how to set up local pypi source

5 minutes to learn how to set up local pypi source

2022-06-10 04:21:00 Python Institute

Preface

Usually we are downloading python Tsinghua source or Alibaba source will be selected when packaging . But when our development environment cannot access the Internet , You need to build a private source . Today we will spend together 5 Minutes to learn how to build a local private source .

Tool selection

There are many ways to build local private sources , Including but not limited to pypiserver,pip2pi,bandsnatch, among pypiserver Minimum difficulty in getting started , Easy to use , Simple function . The latter two are suitable for building enterprise level sources , Because it has the function of automatically synchronizing packages .

Service establishment

download pypiserver

pip install pypiserver

Create package path

mkdir ~/packages

Start the service

PS C:\Users\admin> pypi-server.exe
127.0.0.1 - - [23/Jun/2021 10:44:49] "GET / HTTP/1.1" 200 1007
127.0.0.1 - - [23/Jun/2021 10:44:54] "GET /simple/ HTTP/1.1" 200 221
127.0.0.1 - - [23/Jun/2021 10:45:25] "POST /RPC2 HTTP/1.1" 200 509

see web page

↑ The welcome page

Here we are , Service startup complete .

Preparation package

First , Let's switch to ~/packages Under the table of contents , Then put your own python Copy the package here , Or upload the downloaded package to this directory .

We choose to download directly from external sources .

Download the sample package

cd ~/packages
pip download -i https://pypi.tuna.tsinghua.edu.cn/simple simplejson

Search from local sources

PS C:\Users\admin\packages> pip search -i http://localhost:8080 simplejson
simplejson (3.17.2)  - 3.17.2
PS C:\Users\admin\packages>

Installation package

Before the installation

PS C:\Users\admin\packages> pip show simplejson
WARNING: Package(s) not found: simplejson
PS C:\Users\admin\packages>

install

PS C:\Users\admin\packages> pip install -i http://localhost:8080/simple simplejson
Looking in indexes: http://localhost:8080/simple
Collecting simplejson
  Downloading http://localhost:8080/packages/simplejson-3.17.2-cp37-cp37m-win_amd64.whl (73 kB)
     |████████████████████████████████| 73 kB ...
Installing collected packages: simplejson
Successfully installed simplejson-3.17.2
PS C:\Users\admin\packages>

After installation

PS C:\Users\admin\packages> pip show simplejson
Name: simplejson
Version: 3.17.2
Summary: Simple, fast, extensible JSON encoder/decoder for Python
Home-page: https://github.com/simplejson/simplejson
Author: Bob Ippolito
Author-email: [email protected]
License: MIT License
Location: d:\python37\lib\site-packages
Requires:
Required-by:
PS C:\Users\admin\packages>

This place pypi The source construction is all over .

Linux Construction method and Windows Almost the same .

Tip

The source built in this test is only for development use , If you need to build an enterprise level private enterprise , The official source needs to be synchronized regularly , It is recommended that you use bandsnatch To set up .

That's all for today , Thank you for reading , We'll see you next .

End

Previous recommendation

IO Who ate it ?

Gevent | Use it asynchronously !

jenkinsclient | Easy to use jenkins client

PySimpleGUI Classic practice : How to read this Chinese character ?

Jmeter test TCP Million connections

use Python Operation profile , Super simple

loguru | Python Log artifact

FastApi-16- Page beautification -1

FastApi-17- Page beautification -2

Light up to see !

原网站

版权声明
本文为[Python Institute]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206100411424367.html

随机推荐