PipEnv:如何处理本地安装的 .whl 包 [英] PipEnv: How to handle locally installed .whl packages

查看:45
本文介绍了PipEnv:如何处理本地安装的 .whl 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PipEnv 来设置一个项目,我需要从预编译的二进制文件中安装一些包.在之前的项目中,我只是 pipenv 将 .whl 文件从某个本地文件夹安装到我的环境中,但这似乎会导致锁定文件出现问题,如果其他人尝试从存储库安装,因为 pipfile 跟踪本地路径.这方面的最佳做法是什么?我应该创建一个包存储库作为项目的一部分并从中安装吗?

解决方案

你应该设置一个私有的 PyPI 索引服务器,并且 配置 Pipenv 以使用该服务器.

设置私有 PyPI 服务器对于像 pypiserver:

$ mkdir private_pypi &&cd private_pypi$ pipenv install # 创建 pipenv 文件$ pipenv 安装 pypiserver$ mkdir 包$ pipenv 运行 pypi-server -p 8080 ./packages &

并将您的轮子放入 packages 目录的 projectname 子目录中,或者使用 twine 将您的包发布到服务器.

然后在您的项目 Pipfile 中添加一个 [[source]] 部分以指向服务器(要使用的 url 以 /simple 结尾>,所以 http://hostname:8080/simple):

[[来源]]url = "http://hostname:8080/simple"verify_ssl = 假name = "some_logical_name"

您可以使用默认的 name = "pypi" 部分作为指南.

[packages] 部分,指定用于那些私有轮子的索引:

[包]wheel1 = {version="*", index="some_logical_name"}wheel2 = {version="0.41.1", index="some_logical_name"}some_public_project = "*"

同样,您可以明确命名任何命名索引,包括 index="pypi".不添加 index="..." 限制让 Pipenv 搜索所有索引以寻找可能的分布.

对于在索引之外发布的二进制轮子(例如 那些由 Christoph Gohlke 构建的a>),您可以考虑只安装完整的轮子网址:

pipenv 安装 https://download.lfd.uci.edu/pythonlibs/l8ulg3xw/aiohttp-3.3.2-cp36-cp36m-win_amd64.whl

这确实迫使每个使用您的 Pipfile 的人都使用特定平台.

I'm using PipEnv to set up a project, and some packages I'm needing to install from precompiled binaries. In a previous project I just pipenv installed the .whl files from some local folder into my environment, but this seems to cause issues with the lock file throwing an error if someone else tries to install from the repository since the pipfile tracks the local path. What are best practices for this? Should I create a packages repository as part of the project and install from that?

解决方案

You should set up a private PyPI index server, and configure Pipenv to use that server.

Setting up a private PyPI server is trivial with a project like pypiserver:

$ mkdir private_pypi && cd private_pypi
$ pipenv install   # create pipenv files
$ pipenv install pypiserver
$ mkdir packages
$ pipenv run pypi-server -p 8080 ./packages &

and put your wheels into their projectname subdirectry of the packages directory, or use twine to publish your package to the server.

Then add a [[source]] section in your projects Pipfile to point to the server (the url to use ends in /simple, so http://hostname:8080/simple):

[[source]]
url = "http://hostname:8080/simple"
verify_ssl = false
name = "some_logical_name"

You can use the default name = "pypi" section as a guide.

In the [packages] section, specify the index to use for those private wheels:

[packages]
wheel1 = {version="*", index="some_logical_name"}
wheel2 = {version="0.41.1", index="some_logical_name"}
some_public_project = "*"

Again, you can explicitly name any of the named indices, including index="pypi". Not adding a index="..." restriction lets Pipenv search all indexes for possible distributions.

For binary wheels published outside of an index (such as those built by Christoph Gohlke), you could consider just installing the full wheel URL:

pipenv install https://download.lfd.uci.edu/pythonlibs/l8ulg3xw/aiohttp-3.3.2-cp36-cp36m-win_amd64.whl

This does force everyone using your Pipfile to a specific platform.

这篇关于PipEnv:如何处理本地安装的 .whl 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆