I have inherited a Python package with Torch-powered C++ extensions and I am trying to find my way around its installation and build process. I am a bit out of my depth, I haven't worked with compiled extensions before.
Currently, its setup.py
imports torch.utils.cpp_extension
to define how the system is built. Obviously, the import happens before the actual call to setup
, so a dependency resolver like pip
has no chance to install torch
before executing the setup.py
.
I am tempted to ask how to use torch.utils.cpp_extension
in setup.py
without assuming that Torch is installed (that question has already been asked an answered elsewhere), but I think what I actually want to know is the following:
What is the future-proof way to describe the build and install process of a Python package with C++ extensions using Torch, such that a pip install /my/local/packagepath
should work out of the box?
I hope I am not asking too much. I'm happy to shift away from legacy setup.py
and setuptools
.