从私有 PyPI 定义 setup.py 依赖项

2023-11-25

我想通过在我的私有 PyPI 中指定它们来安装依赖项setup.py.

我已经尝试指定在何处查找依赖项dependency_links这边走:

setup(
    ...

    install_requires=["foo==1.0"],
    dependency_links=["https://my.private.pypi/"],

    ...
)

我还尝试在 中定义整个 URLdependency_links:

setup(
    ...

    install_requires=[],
    dependency_links=["https://my.private.pypi/foo/foo-1.0.tar.gz"],

    ...
)

但是当我尝试安装时python setup.py install,他们都不适合我。

有谁能够帮助我?

EDITS:

使用第一段代码我得到了这个错误:

...

Installed .../test-1.0.0-py3.7.egg
Processing dependencies for test==1.0.0
Searching for foo==1.0
Reading https://my.private.pypi/
Reading https://pypi.org/simple/foo/
Couldn't find index page for 'foo' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/
No local packages or working download links found for foo==1.0
error: Could not find suitable distribution for Requirement.parse('foo==1.0')

而在第二种情况下,我没有收到任何错误,只是出现以下错误:

...

Installed .../test-1.0.0-py3.7.egg
Processing dependencies for test==1.0.0
Finished processing dependencies for test==1.0.0

更新1:

我尝试过改变setup.py按照sinoroc的指示。现在我的setup.py看起来像这样:

setup(
    ...

    install_requires=["foo==1.0"],
    dependency_links=["https://username:p[email protected]/folder/foo/foo-1.0.tar.gz"],

    ...
)

我建了图书馆test with python setup.py sdist并尝试安装它pip install /tmp/test/dist/test-1.0.0.tar.gz,但我仍然收到此错误:

Processing /tmp/test/dist/test-1.0.0.tar.gz
ERROR: Could not find a version that satisfies the requirement foo==1.0 (from test==1.0.0) (from versions: none)
ERROR: No matching distribution found for foo==1.0 (from test==1.0.0)

关于私有 PyPi,我没有任何其他信息,因为我不是它的管理员。正如你所看到的,我只有凭据(username and password)对于该服务器。

此外,PyPi 组织在子文件夹中,https://my.private.pypi/folder/..我要安装的依赖项在哪里。

更新2:

通过跑步pip install --verbose /tmp/test/dist/test-1.0.0.tar.gz,看来只有 1 个位置可以搜索图书馆foo,在公共服务器中https://pypi.org/simple/foo/并且不在我们的私人服务器中https://my.private.pypi/folder/foo/.

这里的输出:

...

1 location(s) to search for versions of foo:
* https://pypi.org/simple/foo/
Getting page https://pypi.org/simple/foo/
Found index url https://pypi.org/simple
Looking up "https://pypi.org/simple/foo/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
https://pypi.org:443 "GET /simple/foo/ HTTP/1.1" 404 13
Status code 404 not in (200, 203, 300, 301)
Could not fetch URL https://pypi.org/simple/foo/: 404 Client Error: Not Found for url: https://pypi.org/simple/foo/ - skipping
Given no hashes to check 0 links for project 'foo': discarding no candidates
ERROR: Could not find a version that satisfies the requirement foo==1.0 (from test==1.0.0) (from versions: none)
Cleaning up...
  Removing source in /private/var/...
Removed build tracker '/private/var/...'
ERROR: No matching distribution found for foo==1.0 (from test==1.0.0)
Exception information:
Traceback (most recent call last):

...

在你的第二次尝试中,我相信你应该仍然有foo==1.0 in the install_requires.


Update

意识到pip不支持dependency_links(以前是,但现在不再了)。

对于 pip,另一种方法是使用命令行选项,例如--index-url, --extra-index-url, or --find-links。这些选项不能对项目的用户强制执行(与依赖链接 from 设置工具),因此必须正确记录它们。为了促进这一点,一个好主意是提供一个示例要求.txt file给您项目的用户。该文件可以包含一些 pip 选项。

例如:

# requirements.txt
# ...
--find-links 'https://my.private.pypi/'
foo==1.0
# ...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

从私有 PyPI 定义 setup.py 依赖项 的相关文章

随机推荐

  • React 路由器重定向条件

    我正在尝试制作一个按钮 仅在验证正确完成后将用户重定向到新页面 有没有办法做这样的事情 如何在类方法内激活路由 import validator from validator class Example constructor props
  • 使用 microsoft.web.helpers 后登录重定向发生变化

    在 asp net mvc3 网站中 我导入了 microsoft web helpers webmatrix data 和 webmatrix webdata 之后 我发现当我在控制器中的某些 ActionResults 上使用 Auth
  • Rails 3 引擎和静态资源

    我正在构建一个捆绑为 gem 的引擎 gmaps4rails 我将引擎的 public 复制到了 Rails 应用程序的 public 中 在开发中一切正常 但在生产中无法正常工作 似乎找不到静态资产 我的引擎和我的主应用程序 日志讲述了以
  • Bash 脚本将日期和时间列转换为 .csv 中的 unix 时间戳

    我正在尝试创建一个脚本来将 csv 文件中的两列 日期和时间 转换为 unix 时间戳 因此 我需要从每一行获取日期和时间列 将其转换并将其插入到末尾包含时间戳的附加列中 有人可以帮助我吗 到目前为止 我已经发现了将任何给定时间和日期转换为
  • WaitHandle.WaitAny 和 Semaphore 类

    Edit 我想说这个问题只是暂时的精神错乱 但当时这是有道理的 见下面的编辑2 对于 NET 3 5 项目 我有两种类型的资源 R1 and R2 我需要检查其可用性 每种资源类型在任何时候都可以有 比如说 10 个实例 当任一类型的资源可
  • 如何访问 MIPS 中字的各个位的状态?

    我正在编写一个程序 我需要确定是否设置了位 3 和 6 我知道我可以旋转一个单词或左 右移动它 但如何访问各个位的状态呢 我是否使用像 and xor 这样的按位运算符 您可以使用 0x08 和 0x40 进行按位与运算 假设位 0 是最低
  • 如何枚举私有 JavaScript 类字段

    我们如何通过私有类字段进行枚举 class Person isFoo true isBar false constructor first last this firstName first this lastName last enume
  • Fetch Api 无法从 PHP 服务器获取会话

    我在我的应用程序中使用 Fetch Api 我有一个 PHP 服务器页面来获取之前已经定义的会话数据 看起来像这样
  • NHibernate中的inverse和cascade是什么意思

    我正在学习 Fluent Nhibernate 我的问题是 什么是Inverse意思是 我读到这意味着关系的另一方负责储蓄 也是如此Cascade 有人可以解释一下它们之间有什么区别吗 请详细解释一下 因为我是NH的新手 看一下本文 链接已
  • 如何并行处理 Flux 事件?

    我有需要丰富的传入事件流 然后在它们到达时并行处理 我以为 Project Reactor 是为这项工作定制的 但在我的测试中 所有处理似乎都是串行完成的 这是一些测试代码 ExecutorService executor Executor
  • 二维数组中每个对角线的最大值

    我有数组 需要动态窗口的最大滚动差异 a np array 8 18 5 15 12 print a 8 18 5 15 12 所以首先我自己创造差异 b a a None print b 0 10 3 7 4 10 0 13 3 6 3
  • 如何使用 One Signal + PHP + Server API 发送推送通知?

    我正在使用一个信号来发送 Android 应用程序的推送通知 我的问题是 如何设置使用服务器 REST API 发送推送通知
  • 将 GroupBy 平均结果添加为 pandas 中的新列

    我有一个数据框 给出每个指标的上限和下限值 如下所示 df pd DataFrame indicator indicator 1 indicator 1 indicator 2 indicator 2 year 2014 2014 2015
  • 如何将 jar 放在 jetty 类路径上的 jetty/lib 中?

    我有 Jetty jetty 9 2 3 v20140905 我的理解是 lib jar 或 lib ext 中的 jar 自动位于类路径上 但这可能是 jetty 8 的旧行为 我正在尝试使用 websockets 部署一个 web 应用
  • 自定义 ng-options 选择外观

    我正在使用 ng options 作为选择下拉菜单 我想根据条件使用不同的颜色作为选项 select ng model myCompany ng options company code as company name for compan
  • JQuery 无法与 Vuejs 一起使用

    我正在尝试将 JQuery 插件 owl carousel 添加到使用 Vuejs 渲染的列表中 HTML h4 1 Vuejs rendered items with OWL Carousel not working h4 div cla
  • Ruby 将上下文分配给 lambda?

    是否可以不将上下文分配给 lambda 例如 class Rule def get rule return lambda puts name end end class Person attr accessor name def init
  • 未找到合适的驱动程序 Postgres JDBC

    当我在 tomcat 上测试 Web 服务时 收到 找不到合适的驱动程序 错误 我在 lib 文件夹中有 JDBC jar 正如各种教程所说的那样 这是我的代码 public class PostDBConnection PreparedS
  • 如何合并两个元组列表?

    我在 Scala 中有两个列表 如何合并它们以使元组分组在一起 是否有现有的 Scala 列表 API 可以做到这一点 或者需要我自己做 Input List a 4 b 1 c 1 d 1 List a 1 b 1 c 1 预期输出 Li
  • 从私有 PyPI 定义 setup.py 依赖项

    我想通过在我的私有 PyPI 中指定它们来安装依赖项setup py 我已经尝试指定在何处查找依赖项dependency links这边走 setup install requires foo 1 0 dependency links ht