Simple way to distribute your private Python packages within your organization

http://www.irasutoya.com/2017/05/blog-post_22.html

This article is a translation of this article, originally written by aodag in Japanese. I translated it with his permission. This article is aimed to know simple ways to prepare internal Python package host like a local gem server on Ruby.

Methods

  • Include your packages in your git repository
  • Publish a directory including your packages via HTTP server
  • Build a local PyPI-equivalent server

It is a high-cost way to create a local PyPI-equivalent server (translator note: like devpi), and I don’t think there is no need to do so, I will describe first two options.

Include your packages in your Git repository

If your packages are required for a particular project, it is straightforward to contain them in the Git repository. You can put them in the directory named wheelhouse, which comes from the name of the previous default directory created by pip wheel. (translator note: this method is assumed you to know wheel. If not, this story and this JIRA would be helpful.)If you put the private package foo in the wheelhouse, you can install as follows:

$ pip install foo -f wheelhouse

Note that -f is the short option for --find-links, with that option, pip will search packages in the directory first, then fall back to pypi.

Publish a directory including your packages via HTTP server

We can use--find-link option to search not only local directory but also a remote server via http. If you have a package used by multiple projects, this method will help you.

The easiest way to distribute your packages with this method is executing python -m http.server with Python 3.x (or python -m SimpleHTTPServer with Python 2.7) on the wheelhouse directory. This simple server provides directory listings so that we can just use--find-links to use the directory. Make sure to open http://localhost:8000 that you can see the list of files under the wheelhouse directory via a web browser.

To install foo package via HTTP server you launched, you can execute as follows:

$ pip install foo -f http://localhost:8000

Since this is a simple server, for production, it is good to put them in cloud storage such as AWS S3, you should check the way for directory listings, or you can use Apache with DirectoryIndex enabled.

Conclusion

I recommend these methods because they are simple and no need to prepare the dedicated application server.

::...
免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet


自怼圈/年度番新

DU22.4
关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::