构建pypi同步源

之前写过一次,旧版本的,最近有个需求,要再搞一次,就直接按照官网的方式部署了,记录下。
3.0.0(2018-10-30) 本次版本的安装方式

首先要更新我们的python版本

[root@localhost ~]# wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
[root@localhost ~]# tar xvf Python-3.6.4.tgz
[root@localhost ~]# cd Python-3.6.4/
[root@localhost Python-3.6.4]# ./configure --prefix=/usr/local/python36
[root@localhost Python-3.6.4]# make && make install

切换到要装软件的目录,生成一个python的虚拟环境

[root@localhost ~]# cd /home/mirror_public_synchronizer/
[root@localhost mirror_public_synchronizer]# virtualenv --python=/usr/local/python36/bin/python3 bandersnatch
Running virtualenv with interpreter /usr/local/python36/bin/python3
Using base prefix '/usr/local/python36'
New python executable in /home/mirror_public_synchronizer/bandersnatch/bin/python3
Also creating executable in /home/mirror_public_synchronizer/bandersnatch/bin/python
Installing setuptools, pip, wheel...
done.

安装bandersnatch包

[root@localhost mirror_public_synchronizer]# bandersnatch/bin/pip install bandersnatch

生成一下配置文件

[root@localhost bandersnatch]# bin/bandersnatch mirror
2018-11-20 00:00:10,843 WARNING: Config file '/etc/bandersnatch.conf' missing, creating default config.
2018-11-20 00:00:10,843 WARNING: Please review the config file, then run 'bandersnatch' again.

编辑配置文件,设置同步路径等信息

[root@localhost home]# cat /etc/bandersnatch.conf|grep -v "^;"|grep -v "^$"
[mirror]
directory = /home/mirror_public_data/pypi
master = https://pypi.python.org
timeout = 10
workers = 10
hash-index = false
stop-on-error = false
delete-packages = true

然后就执行同步吧,时间可能会比较长

[root@localhost ~]# /home/mirror_public_synchronizer/bandersnatch/bin/bandersnatch mirror

你可能感兴趣的:(构建pypi同步源)