ITPub博客

首页 > IT职业 > IT职场 > 使用pypiserver快速搭建内网离线pypi仓库实践

使用pypiserver快速搭建内网离线pypi仓库实践

IT职场 作者:hahadelphi 时间:2021-09-09 09:30:52 0 删除 编辑

前言

本文介绍了如何快速搭建一个pypiserver,通过自建pypiserver,我们可以解决网络环境不好,或者离线无法安装python包的问题。如果结合最新的GitLab CI/CD和pipenv我相信各位还可以玩出更多的花样。

pypiserver - minimal PyPI server for use with pip/easy_install

更新记录

2018年04月12日 - 初稿

阅读原文 - https://wsgzao.github.io/post/pypiserver/

扩展阅读

pypiserver - https://github.com/pypiserver/pypiserver

pypiserver 简介

pypiserver is a minimal PyPI compatible server for pip or easy_install. It is based on bottle and serves packages from regular directories. Wheels, bdists, eggs and accompanying PGP-signatures can be uploaded either with pip, setuptools, twine, pypi-uploader, or simply copied with scp.

pypiserver 服务端配置

如果你的Linux环境缺少Python 2.7可以参考我的文章直接离线升级至最新版本

Python 2.6 升级至 Python 2.7 的实践心得
https://wsgzao.github.io/post/python-2-6-update-to-2-7/

pypiserver > 1.2.x works with python 2.7 and 3.3+ or pypy. Older python-versions may still work, but they are not tested. For legacy python versions, use pypiserver-1.1.x series.

# 替换pip为阿里云,感概豆瓣的时代已经过去tee ~/.pip/pip.conf 

pypiserver 客户端配置

## Download and Install hosted packages.pip install  --extra-index-url http://localhost:8080/simple/ ...# orpip install --extra-index-url http://localhost:8080## Search hosted packagespip search --index http://localhost:8080 ...# 个人推荐的配置tee ~/.pip/pip.conf 

pypiserver 进阶配置

pypiserver Running as a systemd service

https://github.com/pypiserver/pypiserver#running-as-a-systemd-service

Adjusting the paths and adding this file as pypiserver.service into your systemd/system directory will allow management of the pypiserver process with systemctl, e.g. systemctl start pypiserver.

More useful information about systemd can be found at https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units

# 安装需要的包yum install nginx -y
pip install passlib pypiserver gunicorn# 创建pypiserver服务方便服务启停管理tee /usr/lib/systemd/system/pypiserver.service 

 作者:王奥OX

链接:https://www.jianshu.com/p/9cb6f698caa3


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2471/viewspace-2810464/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-09-01

  • 博文量
    78
  • 访问量
    8404