Wednesday 17 May 2023

Building Python C module on Windows

I am trying to build a 'C' python extension on Windows, the core C code compiles absolutely fine, but I am unable to build the python module using setuptool as I am getting

mandlebrot.c(36): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory

error: command 'e:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\HostX86\x86\cl.exe' failed with exit code 2

I am trying to build using:

python3.9 setup.py build_ext --inplace --plat-name win32

Any help would be welcome as I have spent a long time trying to work out how to get this to work.

The setup file:

from setuptools import setup, Extension
from subprocess import getoutput

LIB_DIRS=['.\mandlebrot_set\libs']
INCLUDE_DIRS=['.\mandlebrot_set\includes']
    
module1 = Extension("mandlebrot",
                    sources = ["mandlebrot.c", "mandlebrot_python.c"],
                    libraries = ['mpfr', 'mpir'],
                    library_dirs = LIB_DIRS,
                    include_dirs = INCLUDE_DIRS)

setup(name = "PackageName",
      version = '0.1',
      description = 'Mandlebrot Set calculator',
      author = '',
      author_email = '',
      ext_modules = [module1]
)


from Building Python C module on Windows

No comments:

Post a Comment