ubuntu16.04自建pip源

cat >  /etc/apt/sources.list << EOF
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security multiverse
EOF

apt update
apt install python-pip -y
pip install --upgrade pip==20.0.1
pip install pip2pi  
pip install pypiserver  

# 上传需要密码
pip install passlib
apt install apache2-utils -y

# 创建用户deepwise 密码deepwise
htpasswd  -b -c /root/.pypipasswd  deepwise deepwise

# 创建文件夹
mkdir -p /var/pip-deepwise/





# 启动
# 当请求的Python包, 在本地 *pypiserver* 上没有找到时, 它会将请求转发到外部PyPI源, 默认为 https://pypi.doubanio.com/simple . 对于国内使用来说, 可以通过 `--fallback-url` 参数将转发目的地址设置为豆瓣源
nohup pypi-server -p 9898 -P /root/.pypipasswd    --fallback-url https://pypi.doubanio.com/simple  /var/pip-deepwise/  &
# nohup pypi-server -p 9898 -P /root/.pypipasswd    --fallback-url https://pypi.tuna.tsinghua.edu.cn/simple  /var/pip-deepwise/  &

单独下载指定版本的routes包

pip2tgz /var/pip-deepwise/ routes==1.12.3

批量下载软件包

# 会下载到/var/pip-deepwise/
pip2tgz /var/pip-deepwise/ -r list/requirements.txt

建立索引

# 建立索引后会/var/pip-deepwise/simple下显示
dir2pi /var/pip-deepwise/

更新索引

pip2acmeco uliweb=0.2.6 
pip2acmeco -r list/requirements.txt

apt install nginx -y

cat  > /etc/nginx/sites-enabled/default << EOF
server {
  listen 80;
  server_name localhost;
  root /var/pip-deepwise;
  # root /pip-link;
  location / {
   autoindex on;
   autoindex_exact_size off; #显示文件的大小
   autoindex_localtime on; #显示文件时间
   #limit_rate_after 5m; #5分钟后下载速度限制为200k
   limit_rate 200k;
  }
access_log /var/log/nginx/pip-deepwise.log ;
}
EOF

nginx -t 
nginx -s reload 


# 避免autoindex首页显示tar.gz包
# mkdir -p /pip-link
#ln -s /var/pip-deepwise/simple /pip-link/

安装

pip install -i http://192.168.10.84:9898/ routes  --trusted-host 192.168.10.84

客户端pip设置

cat .pip/pip.conf 
[global]
trusted-host = 172.16.1.1
index-url = http://172.16.1.1:8080/simple

客户端配置,不存在则新建
vim ~/.pypirc
添加如下内容(填入正确的地址和帐号密码,假设服务器地址为192.168.0.2)

[distutils]
index-servers =
  local
[local]
repository: http://192.168.0.2:9898
username: username
password: passwd

开机启动

cat /etc/rc.local |egrep -v "^#|^$"
pypi-server /python-packages &>/var/log/pypi-server.log &
exit 0
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爷来辣

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值