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

fix: Fix the generation for mesonpy build-system #278

Merged
merged 1 commit into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading