基于Bandersnatch搭建本地pypi源
生活随笔
收集整理的這篇文章主要介紹了
基于Bandersnatch搭建本地pypi源
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、安裝python3
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel yum install libffi-devel -y wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz tar -xvJf Python-3.7.3.tar.xz cd Python-3.7.3 ./configure prefix=/usr/local/python3 make && make install ln -s /usr/local/python3/bin/python3 /usr/bin/python3# 將/usr/local/python3/bin加入PATH
# vim ~/.bash_profile # .bash_profile # Get the aliases and functions if[ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin:/usr/local/python3/bin export PATH按ESC,輸入:wq回車退出。
修改完記得執行行下面的命令,讓上一步的修改生效:
# source ~/.bash_profile檢查Python3及pip3是否正常可用:
# python3 -V Python 3.7.3 # pip3 -V pip 19.0.3 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)2、安裝Bandersnatch
Bandersnatch 是一個用于同步 pypi 源的工具,采用它下載和同步官網所有 package 到本地,最后由 nginx 發布
# pip3 install bandersnatch # find / -name master.py /usr/local/python3/lib/python3.7/site-packages/bandersnatch/master.py # cp /usr/local/python3/lib/python3.7/site-packages/bandersnatch/master.py{,.bak} # vim /usr/local/python3/lib/python3.7/site-packages/bandersnatch/master.py生成配置文件:
# bandersnatch mirror 2019-05-06 10:30:17,555 WARNING: Config file '/etc/bandersnatch.conf' missing, creating default config. 2019-05-06 10:30:17,555 WARNING: Please review the config file, then run 'bandersnatch' again.修改配置文件/etc/bandersnatch.conf
根據實際情況,重點修改以下兩個配置,directory 指 package 在本地存放的位置(要保證該目錄空間足夠,預留300G以上),master 指被同步的源。
下載所有 package 至本地(更新本地的 pacakge也用這個命令)
bandersnatch -c /etc/bandersnatch.conf mirror3、安裝 nginx
yum install nginx -y更改nginx.conf的配置文件
server {listen *:80;server_name locahost;root /srv/pypi/web;autoindex on;charset utf-8; }打開網頁查看是否正常:
http://172.28.88.102/simple/4、測試客戶端
在另一臺服務器配置pip的地址
# cat ~/.pip/pip.conf [global] trusted-host=172.28.88.102 index-url=http://172.28.88.102/simple# pip install baker # pip list | grep Baker Baker (1.3)總結
以上是生活随笔為你收集整理的基于Bandersnatch搭建本地pypi源的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微信扫一扫支付怎么弄?
- 下一篇: 完整LIS系统源码 大型医院实验室信息管