Skip to content

Commit

Permalink
fix: Fix the project generation for mesonpy build-system (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab authored May 4, 2024
1 parent b2cc87d commit 2a1102c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 28 deletions.
21 changes: 0 additions & 21 deletions src/scicookie/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,27 +389,6 @@ def prepare_git() -> None:
subprocess.call(["git", "branch", "-D", git_stash_branch])


# def add_binding_source_files():
# if BUILD_SYSTEM == "maturin":
# build_system_dir = PROJECT_DIRECTORY / "build-system"
# src_system_dir = PROJECT_DIRECTORY/ "src"
# if USE_SRC_LAYOUT :
# shutil.move(build_system_dir / "lib.rs", "src")
# else:
# os.makedir(src_system_dir)
# shutil.move(build_system_dir / "lib.rs", src_system_dir)
# elif BUILD_SYSTEM == "pybind11" :
# build_system_dir = PROJECT_DIRECTORY / "build-system"
# src_system_dir = PROJECT_DIRECTORY/ "src"
# if USE_SRC_LAYOUT :
# shutil.move(build_system_dir / "main.cpp", "src")
# else:
# os.makedir(src_system_dir)
# shutil.move(build_system_dir / "main.cpp", src_system_dir)
# else:
# pass


def post_gen():
# keep this one first, because it changes the package folder
clean_up_project_layout()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ static PyMethodDef methods[] = {

static struct PyModuleDef module = {
PyModuleDef_HEAD_INIT,
"{{ cookiecutter.package_slug }}",
"core",
NULL,
-1,
methods,
};

PyMODINIT_FUNC PyInit_{{ cookiecutter.package_slug }}(void)
PyMODINIT_FUNC PyInit_core(void)
{
return PyModule_Create(&module);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ project(
license: '{{ cookiecutter.project_license }}',
meson_version: '>= 1.1.0',
)
# name = '{{ cookiecutter.package_slug }}'
name = '{{ cookiecutter.package_slug }}'

cpp_sources = files('src/main.cpp')

py_mod = import('python')
py = py_mod.find_installation(pure: false)

py.extension_module(
'{{ cookiecutter.project_slug }}',
'core',
cpp_sources,
subdir: '{{ cookiecutter.project_slug }}',
subdir: '{{ cookiecutter.package_slug }}',
install: true,
)

install_subdir(
'{{ package_path }}',
install_dir: py.get_install_dir() / '{{ cookiecutter.project_slug }}',
install_dir: py.get_install_dir() / '{{ cookiecutter.package_slug }}',
strip_directory: true
)
6 changes: 5 additions & 1 deletion tests/smoke/base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,14 @@ else

fi

if [[ "$BUILD_SYSTEM" != "mesonpy" && "$BUILD_SYSTEM" != "maturin" ]]; then
if [[ "$BUILD_SYSTEM" != "maturin" ]]; then
python -c "import osl_python_package as mypkg; assert mypkg.__version__ == '0.1.0'"
fi

if [[ "$BUILD_SYSTEM" == "mesonpy" ]]; then
python -c "from osl_python_package import core; core.foo()"
fi

export PATH=${PATH_ORI}

echo '---------------------------- passed --------------------------'
Expand Down

0 comments on commit 2a1102c

Please sign in to comment.