0

I want to install a package with the following structure:

├── nsp
│   ├── __init__.pxd
│   └── A
|       ├── b.py
|       ├── extension.pxd
|       ├── extension.pyx
│       └── __init__.py
└── setup.py

whereby nsp is a namespace package. (Motivation: see here)

My setup script reads as follows:

from setuptools import setup
from setuptools.extension import Extension

# factory function
def my_build_ext(pars):
    # import delayed:
    from setuptools.command.build_ext import build_ext as _build_ext

    # include_dirs adjusted: 
    class build_ext(_build_ext):
        def finalize_options(self):
            _build_ext.finalize_options(self)
            # Prevent numpy from thinking it is still in its setup process:
            __builtins__.__NUMPY_SETUP__ = False
            import numpy
            self.include_dirs.append(numpy.get_include())

    #object returned:
    return build_ext(pars)

extensions = [Extension(nsp.A.extension, ['nsp/A/extension.cpp'])]

setup(
    cmdclass={'build_ext' : my_build_ext},
    setup_requires=['numpy'],
    install_requires=['numpy'], 
    packages=['nsp.A'],
    ext_modules=extensions
    package_data={
        '': ['*.pxd', '*.pyx']
    },
)

According to my current understanding, package_data describes all non-python files that shall be included. I desire to rebuild the exact file tree given above in the installation directory. Unfortunately, however, __init__.pxd is not copied. How could I achieve that?

I am working with Python 3.7 on Windows 10 x64.

Samufi
  • 2,465
  • 3
  • 19
  • 43
  • 1
    `packages = ['nsp', 'nsp.A']` or something like that? `package_data` describes what bits of the packages are installed, and since `nsp` isn't listed as a package then `pxd` files under it aren't included – DavidW Jan 02 '20 at 19:58
  • This is correct and works. Thanks @DavidW – Samufi Jan 02 '20 at 22:15

0 Answers0