pip - 使用项目文件夹作为安装源

2024-01-06

我想配置pip使用自定义搜索路径从本地文件夹安装包,该文件夹未托管在 PyPI 上。目标是能够运行

$ pip install --user my_non_published_package

并让它安装所述软件包/home/myuser/projects/my_non_published_package.

我知道我可以使用显式安装它

$ pip install --user /home/myuser/projects/my_non_published_package

但这是not我想要的是。我希望 pip 透明地解决其他包的潜在依赖关系并从/home/myuser/projects/<package>前提是它们没有托管在 PyPI 上。所以,如果我有一个项目foo有一个setup.py含有

from setuptools import setup

setup(
    ...
    install_requires=[
        bar,
        ...
    ],
    ...
)

并包bar不在 PyPI 上,我希望 pip 从以下位置安装它/home/myuser/projects/bar自动地。

Update我找到了一些资料here https://stackoverflow.com/questions/35668295/how-to-include-and-install-local-dependencies-in-setup-py-in-python,但建议的解决方案不起作用。

#! /usr/bin/env python3
"""Setup configuration."""

from pathlib import Path

from setuptools import setup


def local_pkg(name: str) -> str:
    """Returns a path to a local package."""
    return f'{name} @ file://{Path.cwd().parent / name}'

setup(
    name='openimmodb',
    use_scm_version={
        "local_scheme": "node-and-timestamp"
    },
    setup_requires=['setuptools_scm'],
    author='HOMEINFO - Digitale Informationssysteme GmbH',
    author_email='<info at homeinfo dot de>',
    maintainer='Richard Neumann',
    maintainer_email='<r dot neumann at homeinfo period de>',
    install_requires=[
        local_pkg('filedb'),
        local_pkg('mdb'),
        local_pkg('openimmo'),
        local_pkg('openimmolib'),
        'peewee',
        local_pkg('peeweeplus'),
        'pyxb',
        local_pkg('timelib'),
        local_pkg('xmldom')
    ],
    packages=[
        'openimmodb',
        'openimmodb.dom',
        'openimmodb.dom.ausstattung',
        'openimmodb.json',
        'openimmodb.json.ausstattung',
        'openimmodb.json.barrier_freeness',
        'openimmodb.json.flaechen',
        'openimmodb.json.immobilie',
        'openimmodb.json.preise',
        'openimmodb.mixins',
        'openimmodb.orm'
    ],
    entry_points={
        'console_scripts': [
            'oidbctl = openimmodb.oidbctl:main'
        ]
    },
    description='Relational OpenImmo database'
)

结果是:

...
Processing dependencies for openimmodb==0.1.dev987+g199a834.d20220110094301
Searching for xmldom@ file:///home/neumann/Projekte/xmldom
Reading https://pypi.org/simple/xmldom/
Couldn't find index page for 'xmldom' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/

即使它在那里:

 $ ls /home/neumann/Projekte/xmldom
LICENSE  Makefile  README.md  setup.py  venv  xmldom.egg-info  xmldom.py

与附加相同localhost:

Searching for xmldom@ file://localhost/home/neumann/Projekte/xmldom
Reading https://pypi.org/simple/xmldom/
Couldn't find index page for 'xmldom' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/

#egg=

Processing dependencies for openimmodb==0.1.dev987+g199a834.d20220110095236
Searching for xmldom@ file://localhost/home/neumann/Projekte/xmldom#egg=xmldom
Reading https://pypi.org/simple/xmldom/
Couldn't find index page for 'xmldom' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/

与绝对路径install_requires I get:

$ python setup.py install
error in openimmodb setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Parse error at "'/home/ne'": Expected W:(abcd...)

None

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

pip - 使用项目文件夹作为安装源 的相关文章

随机推荐

  • 包含多个 import_playbook 文件中的变量

    这是使用 Ansible 2 7 时出现的错误 我正在尝试将其中包含变量的文件包含到我的具有多个 import playbook 的剧本中 我有3个文件 与所有变量合一 一个有剧本和任务的人 带有 import playbook 的一个 我
  • 如果元素以不同的高度和宽度平铺,如何使用 Bootstrap 3 网格

    我用过引导程序3 http getbootstrap com 最近做了几个项目 喜欢它的简单工作方式 不过 我现在有一些问题 我真的不知道如何使用它 如果我有一些平铺的 div 我想知道最好的方法是如何更改顺序或网格内不同断点上的位置 我做
  • 方法声明中的变量= null?它是什么意思以及如何调用该方法?

    当我今天浏览一些代码时 我偶然发现了以下方法声明 public List
  • AngularJS + UI-Router - 在 HTML5 模式下手动输入 URL,无需 HashBang

    我目前正在使用 AngularJS 和 UI Router 进行状态管理并在后端进行表达 我目前启用了 hash bang 模式 并一直在尝试找到一种解决方案 允许您在地址栏中手动键入 URL 而无需使用 hash bang 例如 不要输入
  • “语义正确”是什么意思?

    我在 css 谈话中看到过很多次 语义正确是什么意思 正确贴标 这意味着您所称的事物就是它的实际含义 经典的例子是 如果某物是table 它应该包含数据行和列 使用它进行布局在语义上是不正确的 你说的是 这是一张桌子 但事实并非如此 另一个
  • 单击单选按钮清除下拉选择

    我有一组单选按钮 选择主要公司后 主要公司字段将被隐藏 我此时还想清除下拉选择 我怎样才能做到这一点 p p
  • Git 显示克隆后修改的随机文件;不能丢弃它们

    一旦我在 MacBook Pro 上克隆某个存储库 我就会立即看到该存储库中修改的文件 我尝试过 git pull git checkout git reset 似乎没有什么能让这些所谓的修改过的文件消失 我使用 git 一段时间了 以前从
  • Google 数据存储身份验证问题 - C#

    我正在尝试使用服务帐户凭据文件 我根据文档创建的 连接到我帐户上的 Google 数据存储 但在尝试插入实体时遇到身份验证错误 Grpc Core RpcException 状态 StatusCode 未验证 详细信息 元数据凭据插件中发生
  • Webservice C# 构造函数不允许参数?

    我试图创建一个 Web 服务 在其构造函数中采用一些参数来保存往返 但我不断收到错误 CS1729 servicename 不包含采用 1 参数的构造函数 尽管当我尝试在本地创建即时 在与服务相同的项目中 时 一切正常 什么给出了 网络服务
  • 使用 Google API - GClientGeocoder()

    我尝试关注此页面 http melandri net 2009 07 03 get location coordinates using google maps 但 GClientGeocoder 未定义 有错误 我已经在我的页面上使用了谷
  • 使用 Regex golang 查找所有匹配的字符串

    我试图返回一个数组或切片 其中包含特定正则表达式与字符串的所有匹配项 该字符串是 city state zip 我想返回一个数组 其中包含花括号之间的所有字符串匹配项 我尝试过使用regexp https golang org pkg re
  • jqgrid 列宽自动

    有没有办法让jqgrid的列宽根据该列的内容动态变化 我使用了shrinkToFit和autoWidth 但它们都不适合我 我使用jqgrid 4 5 2 我搜索并阅读了其他问题 但这些对我不起作用 也许有一个小部件可以做到这一点 如果你帮
  • 如何根据值更改输入滑块拇指颜色?

    我正在制作一个包含范围输入滑块的网站 我希望滑块拇指根据滑块的值改变颜色 例如 如果值为 0 则拇指颜色将为rgb 255 0 0 如果是 100 颜色将为rgb 0 255 0 拇指会变色 需要明确的是 我不想要这样的事情 if slid
  • 使用 html/css3 和 WebView 将图像缩放到屏幕...在图像加载之前出现白屏

    我正在 Android 中使用 WebView 来加载一些本地 html 将图像缩放到屏幕作为背景 但是 当我开始加载 WebView 的活动时 我在图像之前看到了非常短暂的白屏闪烁负载 这不是什么大不了的事 但我想避免这种情况 我尝试将所
  • Django:如何迁移运行时创建的动态模型

    在我的 Django 应用程序中 特定的用户输入将导致创建新模型 这是我用来创建模型并注册它的代码 model type model name ExistingModel attrs admin site register model ad
  • 如何让 Safari 发送 if-modified-since 标头?

    当我生成页面时 我发送标题 HTTP 1 1 200 OK Cache Control private Content Type text html charset utf 8 Last Modified Mon 04 Apr 2011 2
  • PHP 中的 JavaScript 函数 fromCharCode()

    var test String fromCharCode 112 108 97 105 110 document write test Output plain 有没有 PHP 代码可以用作String fromCharCode JavaS
  • CanCan::Ability current_user 方法在哪里定义?

    差不多就是我在标题中提到的内容 我在代码中使用 CanCan Ability 来检查权限和能力 它期望定义一个 current user 方法 我猜它来自 devise 但不确定 我希望覆盖它 最好的方法是什么 被发现了here https
  • JQuery:可以有 3 个输入的滑块吗?

    我想创建一个具有 3 个输入的滑块 我做了很多研究 但找不到比带有 2 个输入的滑块更多的东西 这是代码 http jqueryui com slider range http jqueryui com slider range 如何创建
  • pip - 使用项目文件夹作为安装源

    我想配置pip使用自定义搜索路径从本地文件夹安装包 该文件夹未托管在 PyPI 上 目标是能够运行 pip install user my non published package 并让它安装所述软件包 home myuser proje