linux环境搭建pypi源,用pypiserver搭建个人的pypi源

上一篇文章http://www.linuxdiyf.com/linux/25882.html中已经讲了怎么搭建pypi源,但是这个源有很多个人用不到的包而且同步时间长,我只需要一些常用的pypi怎么办?pypiserver可以满足。可以拉取Docker pull becivells/pypiserver Dockerfile贴出来供大家参考

1.supervisord.conf

[supervisord]

nodaemon=true

[program:pypiserver]

command=pypi-server -p 80 --fallback-url https://mirrors.ustc.edu.cn/pypi/web/simple/ /opt/pypi/

user = root

autostart = true

stdout_logfile=/dev/stdout

stdout_logfile_maxbytes=0

如果找不到默认会去中科大的源上找

2.Dockerfile

FROM ubuntu:latest

MAINTAINER  python

RUN apt-get -y update && apt-get install -y  python-pip  supervisor && pip install pypiserver  && pip install pip2pi

COPY supervisord.conf  /etc/supervisor/conf.d/supervisord.conf

EXPOSE 80

VOLUME ["/opt/pypi/"]

CMD ["/usr/bin/supervisord"]

镜像大小大概56M

使用方法

3.创建镜像

docker build -t pypiserver .

运行

学校寝室网速不行图片传不上去,以后再补

docker run -d  -p 80:80  -v  /docker/pypi/:/opt/pypi/  pypiserver

添加包

列出你所要安装的pip包requirements.txt

另开一个docker

docker run -i -t -v  /docker/pypi/:/opt/pypi/  pypiserver /bin/sh

在里面创建requirements.txt将需要包写里面

在网上找了一些openstack的需求包

sqlalchemy-migrate>=0.8.2,!=0.8.4

netaddr>=0.7.6

suds>=0.4

paramiko>=1.9.0

pyasn1

Babel>=1.3

iso8601>=0.1.9

jsonschema>=2.0.0,<3.0.0

python-cinderclient>=1.0.6

python-neutronclient>=2.3.4,<3

python-glanceclient>=0.9.0

python-keystoneclient>=0.7.0

six>=1.5.2

stevedore>=0.14

websockify>=0.5.1,<0.6

wsgiref>=0.1.2

oslo.config>=1.2.0

oslo.rootwrap

pycadf>=0.4.1

oslo.messaging>=1.3.0a9

Django==1.5.5

amqp==1.0.12

pip

beautifulsoup

requests

lxml

furl

执行

pip2tgz /opt/pypi -r requirements.txt

执行过程可能会报错

浏览器访问localhost会出现

Welcome to pypiserver!

This is a PyPI compatible package index serving 100 packages.

To use this server with pip, run the the following command:

pip install --extra-index-url http://localhost/ PACKAGE [PACKAGE2...]

To use this server with easy_install, run the the following command:

easy_install -i http://localhost/simple/ PACKAGE

The complete list of all packages can be found here or via the simple index.

This instance is running version 1.2.0 of the pypiserver software.

pip尝试一下(软件包存在时)

# user-admin @ Y400 in ~ [23:30:49]

$ pip install django

Collecting django

Downloading http://localhost/packages/Django-1.5.5.tar.gz (8.1MB)

100% |██████████████████████| 8.1MB 88.8MB/s

Building wheels for collected packages: django

Running setup.py bdist_wheel for django ... done

Stored in directory: /home/user-admin/.cache/pip/wheels/2a/57/9b/2391e20ca8f06a8b2ce0d9a7b768c59948f6e49488ef8ad98e

Successfully built django

Installing collected packages: django

Successfully installed django-1.5.5

不存在时

# user-admin @ Y400 in ~ [23:39:10]

$ pip install psutil

Collecting psutil

Downloading https://mirrors.ustc.edu.cn/pypi/web/packages/6c/49/0f784a247868e167389f6ac76b8699b2f3d6f4e8e85685dfec43e58d1ed1/psutil-4.4.2.tar.gz (1.8MB)

100% |█████████████████████| 1.8MB 240kB/s

Building wheels for collected packages: psutil

Running setup.py bdist_wheel for psutil ... done

Stored in directory: /home/user-admin/.cache/pip/wheels/57/0e/48/7eca7f1f9a9cddead4dbacecdc8873a8cfdd3c4c5bee641efe

Successfully built psutil

Installing collected packages: psutil

Successfully installed psutil-4.4.2

使用本地源

linux下在用户目录下创建.pip文件夹,在.pip文件夹中创建文件pip.conf

mkdir ~/.pip

touch ~/.pip/pip.conf

# root @ Y400 in ~ [23:43:33]

$ cat .pip/pip.conf

[global]

index-url = http://localhost/simple

extra-index-url=https://pypi.mirrors.ustc.edu.cn/simple

[install]

trusted-host = localhost

windows下

在用户目录下例如C:\Users\user-admin\ 创建pip文件夹创建一个文件pip.ini

[global]

index-url = http://localhost/simple

extra-index-url=https://pypi.mirrors.ustc.edu.cn/simple

[install]

trusted-host = localhost

或者

在window的文件夹窗口输入 : %APPDATA%

创建文件夹pip在pip文件加下创建文件pip.ini

[global]

index-url = http://localhost/simple

extra-index-url=https://pypi.mirrors.ustc.edu.cn/simple

[install]

trusted-host = localhost

或者临时使用

pip install -i http://192.168.10.90/pypi/simple --trusted-host 192.168.10.90 Django

你可能感兴趣的:(linux环境搭建pypi源)