python - 从源代码安装 pip 无需构建轮子
问题描述
我有一个包含大型 PyTorch 模型检查点的 Python 包。我尝试将那些包含在我setup.py
的 as
package_data = {'mypackage': ['model_weights/*', 'model_weights/sequential_models*']},
现在的问题是,每当我尝试从源代码安装时,pip install mypackage/ --no-cache-dir
我都会得到一个MemoryError
. 我尝试调试--verbose
并意识到这发生在
creating '/tmp/pip-wheel-bs29bp6a/tmpp0itbxn1/mypackage-1.0-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it
adding 'mypackage/model_weights/distilled_model.pt'
adding 'mypackage-1.0.dist-info/RECORD'
Traceback (most recent call last):
...
File "/zhome/1d/8/153438/miniconda3/envs/testenv/lib/python3.9/zipfile.py", line 1127, in write
data = self._compressor.compress(data)
MemoryError
Building wheel for mypackage (PEP 517) ... error
ERROR: Failed building wheel for mypackage
我真的只希望安装将文件复制model_weights/
到安装目录中。将它们包括在轮子中似乎是不可能的。
有没有办法在运行时抑制这一步pip install
?该包将仅作为源分发,永远不会在 PyPI 上分发,因为model_weights
无论如何文件都太大了。
解决方案
你可以跑
$ pip install mypackage/ --no-cache-dir --no-binary=mypackage
跳过轮子构建(假设mypackage
实际上是您的发行版名称 - 这是您传递name
给setup()
功能的名称)。
推荐阅读
- flutter - 使用提供程序时在构建期间调用的 setState() 或 markNeedsBuild()
- android - React Native App 中未显示 S3 私有存储桶图像
- nginx - 删除 index.php 的同一台服务器上的前端 + api 的 nginx 配置
- postgresql-11 - pg_basebackup 没有创建备份标签文件
- ios - SF 符号在约束下表现得很奇怪
- django - DJANGO 中格式错误的十六进制 UUID 字符串
- vba - 无需打开应用程序且无需用户交互 VBA 即可打印
- android - 更新文档时如何跳过 Firestore 中的字段?
- php - Ad_group_ad_asset_view 中的 Google 广告 api 字段asset.name 为空,类型为 YOUTUBE_VIDEO
- symfony - 始终在学说 DQL 中获得列