0

tflite_runtime is not hosted in pypi, but can be installed as:

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

How can I package my project which has this dependency?

I have seen this setuptools docs and some threads 1, 2 but no luck so far.

setup.cfg

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

Bonus: locally I use mac. My deployment will be on linux. Is there a way to install the right whl based on OS?

Arash
  • 522
  • 7
  • 24
  • 1
    `dependency_links` were declared obsolete and finally [removed](https://setuptools.readthedocs.io/en/latest/userguide/dependency_management.html#dependencies-that-aren-t-in-pypi) in `pip` 19.0. The replacement for it is `install_requires` with special syntax (supported since `pip` 19.1): `'package_name @ git+https://gitlab.com//.git@'`. See https://pip.pypa.io/en/stable/cli/pip_install/#requirement-specifiers and https://www.python.org/dev/peps/pep-0440/#direct-references . This requires `pip install` and doesn't work with `python setup.py install`. – phd May 18 '21 at 00:45
  • I suspect dependencies that aren’t in PyPI are not fully supported now. Either you point a direct reference to an exact file (no platform and no version variability) or to a VCS repository. But not to an extra index. – phd May 18 '21 at 00:52

1 Answers1

0

This worked for me to install .whl package and make it OS specific.

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,
        ...
    ]

A cleaner approach should be using Environment Markers, but I couldn't get that to work.

Arash
  • 522
  • 7
  • 24