0

I'm working on improving the setup.py script for an open source package that supports various platforms.

On Linux, the package defines a setuptools.Extension for some C code that needs to be built alongside the Python code. This produces a wheel whose name indicates that it is only compatible with a particular version of CPython and a particular OS and hardware architecture.

On macOS, however, it invokes xcodebuild manually, and then includes that framework in eager_resources. Setuptools cannot detect that the resulting wheel is platform-specific, so it gives it a generic filename.

If it's possible to, I'd prefer to have setuptools build the Xcode project for me, but if not, can I somehow tell it that this is platform-specific? I was thinking I could include an empty extension, but that seems hacky.

phd
  • 82,685
  • 13
  • 120
  • 165
rgov
  • 3,516
  • 1
  • 31
  • 51

1 Answers1

0

This is the hacky way:

# Add a dummy extension so setuptools knows this is platform-specific
try:
    os.mkdir('build')
except:
    pass
open('build/dummy.c', 'w').close()
mod1 = Extension('package._dummy', sources=['build/dummy.c'])
ext_modules.append(mod1)
rgov
  • 3,516
  • 1
  • 31
  • 51