在Python 2.7-3.5的Windows上,是否可以将多个Python轮子打包成一个轮子?
如果没有,使用标准库工具的替代方案是什么?
编辑
我打算使用 archive 来打包多个wheel,并在Python安装后将它们解压。
根据PEP 440和PEP 426以及pip 安装手册(如果我正确阅读它们),我应该能够创建我的库/轮子的预发行版本,并使用它们当且仅当我包含“ --pre”标志。
此外,我认为它的意思是,给定正确的安装选项(--pre?)预发布版本将适合标准数字版本控制方案,这样1.a1和1.dev1将显示为1.1,就像1.1+extra_tag也显示为1.1(注意:+extra_tag不需要--pre标志工作)
这些似乎都不起作用。
我看到的是:
pip install ... wheelname即使上传的轮子版本类似于 ,也会安装wheelname.1.dev6。无论以哪种方式,这--pre似乎都没有什么区别。wheelname==1.6,即使有--pre选项,如果我的轮子版本为wheelname.1.dev6、wheelname.1.a1等,也找不到。wheelname>=1根据我阅读 PEP 440 和 426 的理解,只要使用该选项,“a”、“b”、“c”和“cr”中缀就应该可用(即 1.a1 == 1.1)--pre(当然,--pre政治公众人物本身并没有明确指定,但我认为)。“.devN”后缀也是如此。
笔记:
--isolated没有什么区别(例如,这不是环境问题)我在创建/上传我的方向盘时使用了一个目录,而不是使用所有的繁杂内容来创建驾驶室。我的大致运行路线是这样的:
pip install wheelname --use-wheel --find-links=file:///tmp/wheelhouse [--pre]
pip …
我在 Spark 执行程序上有类似的导入错误,如这里所述,只是使用 psycopg2:ImportError: No module named numpy on spark workers
这里说“虽然熊猫太复杂了,无法作为 *.py 文件分发,但您可以为它及其依赖项创建一个 egg 并将其发送给执行程序”。
所以问题是“如何从包及其依赖项创建egg文件?” 或轮子,以防鸡蛋是遗产。在 pip 中是否有任何命令?
对于使用 otree ( http://otree.readthedocs.io/ )的项目,我在尝试安装时遇到了一些问题Channels以使用实时功能时遇到了一些问题。
由于输出很长,我试图找出最重要的部分:
有关完整输出,请参阅:https://jsfiddle.net/L4ccmr2k/1/
红色标记的输出和我认为相关的输出:
1.
Building wheels for collected packages: twisted
Running setup.py bdist_wheel for twisted ... error
Run Code Online (Sandbox Code Playgroud)
2.
creating build/temp.macosx-10.6-intel-3.6
creating build/temp.macosx-10.6-intel-3.6/src
creating build/temp.macosx-10.6-intel-3.6/src/twisted
creating build/temp.macosx-10.6-intel-3.6/src/twisted/test
/usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c src/twisted/test/raiser.c -o build/temp.macosx-10.6-intel-3.6/src/twisted/test/raiser.o
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Failed building wheel for twisted …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个 python 扩展,它使用 numpy C-API 来操作 numpy 数组。在设置部署链时,我遇到了一个问题。
在我requirements.txt和setup.py我中添加了依赖项numpy>=1.7,因为我正在使用该版本中引入的 API 功能。我正在quay.io/pypa/manylinux1_x86_64docker 镜像中造轮子。在图像内,我正在使用安装我的要求pip。这将安装numpy==1.14,因为这是当前版本,与我的依赖项匹配。
mypackage-xxx-manylinux_x84_64.whl但是,当我在 ubuntu 机器(有 numpy )上安装时1.8,在导入包时收到以下错误
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
RuntimeError: module compiled against API version 0xc but this version of numpy is 0x9
---------------------------------------------------------------------------
ImportError
[...]
ImportError: numpy.core.multiarray failed to import
Run Code Online (Sandbox Code Playgroud)
明显的解决方法是我运行pip install -U numpy. 但是,我不想告诉我的包的每个用户如果他们的 numpy 库是<1.14(即使它符合我的依赖项要求),则手动运行此命令。与此建议相关的几个问题(例如1、 2)。我是从软件包开发人员的角度在这里问的。首先我可以做什么来防止这种情况发生?
这里的最佳实践是什么?我是否应该专门添加 的依赖项numpy >= …
我使用wheel在Pypi上发布了一个示例python包。我想使用本教程在我的 Conda 频道上发布包。
但是,当我运行时:
conda skeleton pypi rutgerhofstepythonpackage出现以下错误:
Warning, the following versions were found for rutgerhofstepythonpackage
0.0.1
0.0.2
0.1.1
Using 0.1.1
Use --version to specify a different version.
Leaving build/test directories:
Work: /opt/anaconda3/conda-bld/skeleton_1523284768777/work
Test: /opt/anaconda3/conda-bld/skeleton_1523284768777/test_tmp
Leaving build/test environments:
Test: source activate /opt/anaconda3/conda-bld/skeleton_1523284768777/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho
Build: source activate /opt/anaconda3/conda-bld/skeleton_1523284768777/_build_env
Error: No source urls found for rutgerhofstepythonpackage
Run Code Online (Sandbox Code Playgroud) 我有一个包含 C 扩展的包,我想将其上传到 pypi: https: //github.com/Erotemic/netharn
我使用命令在 Ubuntu 18.04 上构建了一个轮子python setup.py bdist_wheel --py-limited-api=cp36,但是当我使用 上传时twine upload --skip-existing dist/*,却收到错误消息,它有一个不受支持的平台标签:
HTTPError: 400 Client Error: Binary wheel 'netharn-0.0.4-cp36-abi3-linux_x86_64.whl' has an unsupported platform tag 'linux_x86_64'. for url: https://upload.pypi.org/legacy/
Run Code Online (Sandbox Code Playgroud)
经过一番搜索后,我发现PEP 513需要构建一个轮子来支持manylinux(又名Centos5): https: //github.com/pypa/manylinux
他们在这里提供了一个示例:https://github.com/pypa/python-manylinux-demo/blob/master/travis/build-wheels.sh
然而,我能找到的所有示例总是使用某种 CI 服务器构建二进制文件。如果可能的话,我希望能够在本地构建它们。我认为复制 docker 命令并将其构建在我自己的机器上的 docker 容器中应该很简单。但是,我遇到了问题。(我确保删除了存储库中任何现有的构建和 dist 目录)
我做的第一件事就是将自己转入交互式 docker 会话中,这样我就可以玩东西了。我选择了 x8_64 映像并将本地目录安装到/iodocker 计算机上的代码存储库。然后我开始了交互式 bash 会话。
REPO_DPATH=$HOME/code/netharn
DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
PRE_CMD=""
# Interactive test
docker run -it --rm -v $REPO_DPATH:/io $DOCKER_IMAGE $PRE_CMD bash
Run Code Online (Sandbox Code Playgroud)
在 docker 内部,我首先想为 …
我的项目结构如下所示:
package1/ # a lot of files, submodules here.
package2/ # a lot of files, submodules here.
package3/ # a lot of files, submodules here.
tests/
setup.py
Run Code Online (Sandbox Code Playgroud)
我有一个setup.py类似的测试:
setup(
name='MyPackage',
packages=find_packages(exclude=['tests']),
package_data={
'package': ['./path/*.xsd'],
},
include_package_data=True,
py_modules=['package1'],
version=__version__,
description='My description',
classifiers=[
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
],
zip_safe=False,
author='Me',
author_email='example@example.com',
url='http://www.example.com/',
keywords=['Keyword1', 'Keyword2'],
scripts=['./script1.py', './script2.py'],
install_requires=[
'isodate',
'pycurl',
],
extras_require={':python_version < "3.0"': ['enum34', 'future']}
)
Run Code Online (Sandbox Code Playgroud)
我按以下方式使用它:
python setup.py bdist_wheel -d . …Run Code Online (Sandbox Code Playgroud) 我目前正在使用 buildhost 来运行第三方软件包
$ pip3 wheel --wheel-dir=/root/wheelhouse -r /requirements.txt
成功构建后,我将目录复制/root/wheelhouse到新机器上并通过运行安装编译的包
$ pip3 install -r /requirements.txt --no-index --find-links=/root/wheelhouse
有没有类似的东西pipenv?我发现的所有内容wheel都是 GitHub 上的错误报告。
请注意,复制 venv 目录不是一种选择。我正在使用 docker 容器并希望在系统范围内安装软件包。
我尝试从这里使用预先构建的轮子Pillow和相应的libraqmDLL:https :
//www.lfd.uci.edu/~gohlke/pythonlibs/#pillow
但以下返回False:
from PIL import features
features.check('raqm')
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?
上下文:我需要libraqm使用Pillow图像上的复杂字体,如下所示。