微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何打包依赖于tflite_runtime的python项目?

如何解决如何打包依赖于tflite_runtime的python项目?

tflite_runtime 不在 pypi 中托管,但可以安装为:

pip3 install --extra-index-url https://google-coral.github.io/py-repo/ tflite_runtime

如何打包具有此依赖项的项目?

我已经看到了这个 setuptools docs 和一些主题 12,但到目前为止没有运气。

setup.cfg

[options]
...
dependency_links = https://google-coral.github.io/py-repo/tflite-runtime/
install_requires =
    tflite_runtime==2.5.0

奖励:我在本地使用 mac。我的部署将在 linux 上进行。有没有办法根据操作系统安装正确的whl?

解决方法

这对我来说安装 .whl 包并使其特定于操作系统。

setup.py

import setuptools
import platform

# tflite for linux
tflite = "tflite_runtime@https://github.../tflite_runtime-...-cp37m-linux...",if platform.system() == 'Darwin':
    # tflite for macos
    tflite = "tflite_runtime@https://github../tflite_runtime...cp37m-macosx..."

setuptools.setup(
    include_package_data=True,install_requires=[
        tflite,...
    ]

更简洁的方法应该是使用 Environment Markers,但我无法让它发挥作用。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。