如何打包依赖于tflite_运行时的python项目?

2024-06-16 12:44:11 发布

您现在位置: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的方法


Tags: installpyhttpsiogithubpypiurlindex
1条回答
网友
1楼 · 发布于 2024-06-16 12:44:11

这对我来说很有用,可以安装.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,但我无法让它起作用

相关问题 更多 >