Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python CFFI build problem on Windows #42

Open
a4z opened this issue Jul 5, 2021 · 3 comments
Open

Python CFFI build problem on Windows #42

a4z opened this issue Jul 5, 2021 · 3 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@a4z
Copy link
Contributor

a4z commented Jul 5, 2021

On Windows, the current CMake build ends with a Python CFFI problem.
This is unfortunately unsolved so far, and help for fixing this problem is welcome

...
...
  Building CFFI lib
  PyCFFIlib_cffi.c
CUSTOMBUILD : warning : I don't know what to do with 'runtime_library_dirs': ['.'] [C:\Users\a4z\work\djinni\support-lib\build\py2\test-suite\PyCFFIlib_cffi.vcxproj]
  Traceback (most recent call last):
    File "C:\Users\a4z\work\djinni\support-lib\build\py2\test-suite\generated-src\cffi\pycffi_lib_build.py", line 25, in <module>
      ffi.compile()
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\site-packages\cffi\api.py", line 725, in compile
      return recompile(self, module_name, source, tmpdir=tmpdir,
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\site-packages\cffi\recompiler.py", line 1564, in recompile
      outputfilename = ffiplatform.compile('.', ext,
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\site-packages\cffi\ffiplatform.py", line 22, in compile
      outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\site-packages\cffi\ffiplatform.py", line 51, in _build
      dist.run_command('build_ext')
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\build_ext.py", line 79, in run
      _build_ext.run(self)
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\command\build_ext.py", line 340, in run
      self.build_extensions()
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\command\build_ext.py", line 449, in build_extensions
      self._build_extensions_serial()
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\command\build_ext.py", line 474, in _build_extensions_serial
      self.build_extension(ext)
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\build_ext.py", line 196, in build_extension
      _build_ext.build_extension(self, ext)
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\command\build_ext.py", line 551, in build_extension
      self.compiler.link_shared_object(
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\ccompiler.py", line 713, in link_shared_object
      self.link(CCompiler.SHARED_OBJECT, objects,
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\_msvccompiler.py", line 460, in link
      lib_opts = gen_lib_options(self,
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\msvc.py", line 329, in msvc14_gen_lib_options
      return get_unpatched(msvc14_gen_lib_options)(*args, **kwargs)
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\ccompiler.py", line 1093, in gen_lib_options
      opt = compiler.runtime_library_dir_option(dir)
    File "C:\Users\a4z\AppData\Local\Programs\Python\Python39\lib\distutils\_msvccompiler.py", line 519, in runtime_library_dir_option
      raise DistutilsPlatformError(
  distutils.errors.DistutilsPlatformError: don't know how to set runtime library search path for MSVC
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): error MSB8066: Custom build for 'C:\Users\a4z\work\djinni\support-lib\build\py2\CMakeFiles 
\aadf18d4fcbdff197304b4b5d83cea85\pycffi_lib_build.py.rule;C:\Users\a4z\work\djinni\support-lib\build\py2\CMakeFiles\5ce445708c0c39eeaefe4c3c138abd3a\Foo_Record.py.rule;C:\Users\a4z\work\djinni\support-lib\build\py 
2\CMakeFiles\0723da9f51c0e0e7e15825be3e6cbffb\PyCFFIlib_cffi.rule' exited with code 1. [C:\Users\a4z\work\djinni\support-lib\build\py2\test-suite\PyCFFIlib_cffi.vcxproj]
~\work\djinni\support-lib [private/moreWindowsTweaks +4 ~1 -0 !] (18:36:58)
@a4z a4z added bug Something isn't working help wanted Extra attention is needed labels Jul 5, 2021
@paulocoutinhox
Copy link

Hi,

The module distutils is deprecated:
https://bugs.python.org/issue2437

https://www.python.org/dev/peps/pep-0632/

Need use setuptools instead.

@a4z
Copy link
Contributor Author

a4z commented Aug 4, 2021

that gets pulled in from cffi, so this is not our dependency

@a4z
Copy link
Contributor Author

a4z commented Aug 6, 2021

a little bit of progress, maybe

runtime lib dir setup

https://github.com/cross-language-cpp/djinni-generator/blob/4854a164b1aa737b4e09c36b1b403b3048346bd7/src/main/scala/djinni/CffiGenerator.scala#L56

needs kind of such a logic

if sys.platform=='win32':
   runtime_lib_dirs = []
else:
   runtime_lib_dirs = ['.']

Missing symbols

Additionally, our generated libraries do not export any symbols on Windows
This is a problem since there is nothing to link against
(when creating the test mylib.dll, we do not get the mylib.lib file so the Windows linker can find mylib from the python test)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants