gpt4 book ai didi

python - Setup.py 安装需要本地包

转载 作者:行者123 更新时间:2023-12-04 17:31:48 25 4
gpt4 key购买 nike

我正在寻找安装包 my-package使用 setuptools . my-package具有本地依赖性,utils .我的文件结构如下:

parent/
my-package/
my-package/
setup.py
utils/
utils/
setup.py

我希望使用以下方法安装本地依赖项:
from setuptools import setup
import os

setup(
name='my-package',
version='1.0',
packages=['my-package'],
install_requires=[
# location to your my-package project directory
"file:\\" + os.path.join(os.path.dirname(os.getcwd()), 'utils#egg=utils-1.0')
]
)

不幸的是,这会出现以下错误:
    ERROR: Command errored out with exit status 1:
command: /path/to/python/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/my-package/setup.py'"'"'; __file__='"'"'/home/my-package/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info
cwd: /home/my-package/
Complete output (1 lines):
error in my-package setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Invalid requirement, parse error at "'://home/'"
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

我已经尝试了解决方案 here没有运气。任何帮助是极大的赞赏。

最佳答案

像这样的事情可以工作:

.
├── One
│   ├── one
│   │   └── __init__.py
│   └── setup.py
└── Two
├── setup.py
└── two
└── __init__.py
One/setup.py
#!/usr/bin/env python3

import setuptools
import pathlib

TWO_PATH = pathlib.Path(__file__).resolve().parent.parent.joinpath('Two')

setuptools.setup(
name='One',
version='1.2.3',
packages=['one'],
install_requires=['Two'],
dependency_links=[
'file://{}#egg=Two-1.2.3'.format(TWO_PATH),
],
)

关于python - Setup.py 安装需要本地包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58939983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com