从 PyPI 进行 pip 安装但从 .whl 进行 pip 安装时,包上的 Numpy 安装要求失败
我最近构建了我的第一个Python软件包,并试图通过test.pypi.org( github repo a href =“ https://test.pypi.org/project/project/mathsom/” rel =“ nofollow noreferrer”> test pypi )
代码用于构建dist:
python setup.py sdist bdist_wheel
用于上传的dist:test PYPI的代码:
twine upload --repository testpypi dist/*
然后我创建和创建和创建和空的conda env测试安装:
conda create --prefix ./envs --no-default-packages python=3.6
在此环境中,我使用 susces pip pip安装与车轮文件:
pip install mathsom-0.1.1-py3-none-any.whl
但是,如果我尝试通过test pypi numpy安装安装失败(IN install_requirlements en setup.cfg)文件)。代码:
pip install -i https://test.pypi.org/simple/ mathsom
setup.cfg代码:
[metadata]
name = mathsom
author = Oliver Mohr B.
author_email = [email protected]
version = 0.1.1
description = Personal library for math related problems
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/oliverm91/mathsom
license_files = LICENSE
keywords = solvers, solver, interpolations, interpolation, numerics, derivatives, integrals
[options]
package_dir=
= src
packages=find:
setup_requires =
numpy
install_requires =
numpy
scipy
[options.packages.find]
where=src
setup.py
from setuptools import setup
if __name__ == '__main__':
setup()
I recently build my first python package and tried to test distribution with test.pypi.org (Github repo Test PyPI)
Code for building the dist:
python setup.py sdist bdist_wheel
Code for uploading to Test PyPI:
twine upload --repository testpypi dist/*
Then I created and empty conda env to test the installation with:
conda create --prefix ./envs --no-default-packages python=3.6
In this enviroment I used succesfully pip install with wheel file:
pip install mathsom-0.1.1-py3-none-any.whl
But if I try to install it from Test PyPI numpy installation fails (it is in install_requirements en setup.cfg file). Code:
pip install -i https://test.pypi.org/simple/ mathsom
Setup.cfg code:
[metadata]
name = mathsom
author = Oliver Mohr B.
author_email = [email protected]
version = 0.1.1
description = Personal library for math related problems
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/oliverm91/mathsom
license_files = LICENSE
keywords = solvers, solver, interpolations, interpolation, numerics, derivatives, integrals
[options]
package_dir=
= src
packages=find:
setup_requires =
numpy
install_requires =
numpy
scipy
[options.packages.find]
where=src
Setup.py
from setuptools import setup
if __name__ == '__main__':
setup()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您查看错误消息,您可以看到
因此它也使用了 whl 文件。但是,numpy 的安装方式有所不同。在您的错误消息中,很明显
numpy
正在尝试从源代码进行编译,这并不奇怪,因为您将索引设置为https://test.pypi.org/simple/
并且该索引下只有 numpy 的源发行版。如果您允许从 pypi 中提取依赖项,通过使用--extra-index-url
将 test.pypi 设置为额外索引,那么一切正常(在使用创建的新 conda 环境中进行测试)您提供的命令):If you look at your error message, you can see
So it is also using a whl file. However, the way numpy is installed differs. In your error message, it is clear that
numpy
is trying to compile from source, which is not suprising, since you set the index tohttps://test.pypi.org/simple/
and there is only source distributions of numpy under that index. If you allow that the dependencies can be pulled from pypi, by setting test.pypi as an extra-index with--extra-index-url
then everything works (tested in a fresh conda env created with the command you have provided):