AOT compilation inside setup.py

Hi I have a python library that we have now migrated from jit compilation to AOT compilation. My setup.py now contains the following code from the docs:

from distutils.core import setup

from source_module import cc

setup(...,
      ext_modules=[cc.distutils_extension()])

It installs locally using pip install -e . with no problems. However when I try to upload this package to pypi I get the following error message

error: Error: setup script specifies an absolute path:

    /home/path_to_my_conda_env/numba/cext/dictobject.c

setup() arguments must *always* be /-separated paths relative to the
setup.py directory, *never* absolute paths.

I have tried lots of things to fix including

Distribution().fetch_build_eggs([my_requirements])

which did change the path but still gave the same error.

Is there anything you suggest?

Thanks
Tom

This specific problem I fixed by setting include_package_data=False in setup(...) however i have since changed it back and works fine so who knows.

Another important thing I found is that using the method described above ext_modules=[cc.distutils_extension()] only works when running setup.py locally but cannot be uploaded to pypi as it will not recognize the compiled binary file (the auditwheels trick didnt work because of linux version issues). It will also only be compiled for your local architecture so dosent make sense to upload the binaries.

I have found a work around where I only upload a source distribution to pypi (no wheels) using

python setup.py sdist
twine upload --repository pypi dist/*

This means that it runs my setup.py when i pip install module where i have added a post install script that compiles my AOT functions.

Maybe this is worth adding to the AOT docs?