brainy-petabyte-49210
01/23/2024, 2:15 PM/libs
/libs/my_code
/libs/3rd_party_code
In the 3rd party library, they have some C++ and CUDA code under
/libs/3rd_party_code/src/c++_cuda_code
If I were to install it using the library's setup.py
file, it would be dealt with through the following code snippet
from torch.utils.cpp_extension import CUDAExtension
ext_modules=[
CUDAExtension(
name="pytorch_quantization.cuda_ext",
sources=[os.path.join(abspath, "src/tensor_quant.cpp"),
os.path.join(abspath, "src/tensor_quant_gpu.cu")])
],
Is there anyway to get this to work with pants?
Many thanks!curved-television-6568
01/23/2024, 2:19 PMpython_distribution
for the cuda-based library using their setup.py
I think you should be able to depend on that dist from your code and pants will just do "the right thing". (and this dependency also ought to be inferred as soon as you import any modules from that library, so shouldn't even have to add explicit dep in any BUILD file..)brainy-petabyte-49210
01/23/2024, 2:33 PMlibs/
. This is the only one causing a bit of trouble.
Ah I think I see! So I read https://www.pantsbuild.org/2.18/docs/python/overview/building-distributions
So I would basically use the setup.py
file from the cuda-based library and pants will automatically generate the BUILD
file etc.?brainy-petabyte-49210
01/23/2024, 2:34 PMbrainy-petabyte-49210
01/23/2024, 2:36 PMpython_distribution
manually in the BUILD
for libs/cuda_library
?brainy-petabyte-49210
01/23/2024, 2:44 PMpython setup.py sdist
and I can use that in the monorepo?happy-kitchen-89482
01/23/2024, 3:39 PMpython_distribution
that uses that preexisting setup.py, per the instructions in https://www.pantsbuild.org/2.18/docs/python/overview/building-distributions#setuppy for not generating a setup.pyhappy-kitchen-89482
01/23/2024, 3:39 PM