Setup.py issue with package with external link

Hi,

I have a question regarding the setup.py when I build my plugin.

I want to do an AI plugin, which requires the onnxruntime==1.15.0 and torch==1.8.1.

However, the 32bit python wheel files for onnxruntime==1.15.0 and torch==1.8.1 are not available in public repos such as piwheels.org. So I have to use a download link from Github to install it. Also, the setup.py does not consider the package difference between 32bit and 64bit.

So I have to modify the setup.py like this to define the plugin_requires

# Any additional requirements besides OctoPrint should be listed here
plugin_requires = [
    "numpy==1.24.3",
    "pillow==8.1.1",
    "onnxruntime @ https://github.com/nknytk/built-onnxruntime-for-raspberrypi-linux/raw/master/wheels/bullseye/onnxruntime-1.15.0-cp39-cp39-linux_armv7l.whl",
    "torch @ https://github.com/KumaTea/pytorch-arm/releases/download/v1.8.1/torch-1.8.1-cp39-cp39-linux_armv7l.whl",
    "torchvision @ https://github.com/KumaTea/pytorch-arm/releases/download/v1.8.1/torchvision-0.9.1-cp39-cp39-linux_armv7l.whl"
]

machine = platform.machine()
if machine.endswith('64'):
    plugin_requires = [
        "numpy==1.24.3",
        "pillow==8.1.1",
        "onnxruntime==1.15.0",
        "torch==1.8.1",
        "torchvision==0.9.1"
    ]

However, will such a modification trigger this:

  • Your plugin doesn’t have any additional code in its setup.py that would run directly on plugin installation, or any additional code in its __init__.py that would run outside of OctoPrint’s plugin framework just by loading it.
    Registering a new plugin

What does your guy think on this issue? I only add an If statement for the different platform, will it considers a modification of setup.py

That is completely fine and acceptable.

1 Like