-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Describe the bug
When generating python package via setup.py bdist_wheel, imports of extension modules under namespace package org, e.g. org.rock.core fail due to scikit-build issue: scikit-build/scikit-build#363
The issue seems to be related to:
if compiled extension files are not in package_prefixes then the extension is classified as data, not as an extension.
prefixes are generated in:
Strangely this only happens using setup.py bdist_wheel and results in failed imports, while if using setup.py install no failed imports and the extension modules go to the correct package structure allowing imports to function properly.
To Reproduce
cookiecutter gh:practicalci/cookiecutter-cpp --no-input
cd rock
conda env create --file conda/conda_dev.yaml
conda activate rock
python setup.py bdist_wheel
pip install dist/rock.*whl
python -c "import org.sdk.core"
Expected behavior
Should import with success.
Solution
Current solutions are:
add to the namespace package to setup.py:
packages=['org', ...
setup(
name='org-rock',
version='1.0.0',
description='A rock solid project',
long_description=readme,
author='First Last',
author_email='[email protected]',
license='MIT',
package_dir = {'': os.path.join('src','python')},
packages=['org', 'org.rock'],
data_files={'': ['LICENSE'] },
install_requires=requirements,
tests_require=[],
setup_requires=setup_requirements,
test_suite='tests.python',
cmake_args=cmake_args,
cmake_minimum_required_version='3.12',
)
This solution is partial, as when using python setup.py install the install folder structure is kept, and linked libraries are kept in the same relative path position as in the cmake install directory, but the same does not occur when using bdist_wheel, the libs are packaged under data, and the relative path position set using RPATH is not longer valid.