I have an existing python project that is using mostly setup.py to build the project. The project has 2 x Cython extension modules configured in setup.py.
Initially I did pip install -e . for development, but since then I'm using python setup.py build_ext --inplace to rebuild only the extensions when needed. Which is much faster compared to installing the package.
I started migrating the project to pyproject.toml including the project configs in the [project] section in pyproject.toml
My setup.py basically only contains the Cython extension modules, which I understand can not be migrated to 'pyproject.toml' as of yet.
Now my problem: python setup.py build_ext --inplace doesn't work anymore, because setup.py doesn't have all the information, and is not consulting pyproject.toml to read the project config (hence project configs information are missing).
Do I need to revert to my original setup.py/*.cfg config, or is there some way to tell setup.py to retrieve the config from pyproject.toml?
Below is a little bit hack example to build the ext with pyproject.toml
pyproject.toml
[tool.setuptools]
py-modules = ["_custom_build"]
[tool.setuptools.cmdclass]
build_py = "_custom_build.build_py"
_custom_build.py
from setuptools import Extension
from setuptools.command.build_py import build_py as _build_py
class build_py(_build_py):
def run(self):
self.run_command("build_ext")
return super().run()
def initialize_options(self):
super().initialize_options()
if self.distribution.ext_modules == None:
self.distribution.ext_modules = []
self.distribution.ext_modules.append(
Extension(
"termial_random.random",
sources=["termial_random/random.c"],
extra_compile_args=["-std=c17", "-lm"],
)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With