Skip to content

Commit

Permalink
added setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ayeankit committed Aug 4, 2023
1 parent f816654 commit e9c6226
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 11 deletions.
10 changes: 7 additions & 3 deletions src/scicookie/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,13 @@ def clean_up_build_system():
PROJECT_DIRECTORY / 'CMakeLists.txt'
)
shutil.move(
build_system_dir / "skcdemo.cpp",
PROJECT_DIRECTORY / 'skcdemo.cpp'
)
build_system_dir / "setup.py",
PROJECT_DIRECTORY / 'setup.py'
)
shutil.move(
build_system_dir / "pybind11.cpp",
PROJECT_DIRECTORY / 'pybind11.cpp'
)
else:
shutil.move(
build_system_dir / "base-pyproject.toml",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% if cookiecutter.build_system == "scikit-build-core" -%}
cmake_minimum_required(VERSION 3.15...3.26)

project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES CXX)
Expand All @@ -7,3 +8,16 @@ find_package(pybind11 CONFIG REQUIRED)
pybind11_add_module(skcdemo MODULE skcdemo.cpp)

install(TARGETS skcdemo DESTINATION .)

{% elif cookiecutter.build_system == "pybind11" -%}
cmake_minimum_required(VERSION 3.15...3.26)

project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES CXX)

find_package(pybind11 CONFIG REQUIRED)

pybind11_add_module(pybind11 MODULE pybind11.cpp)

install(TARGETS pybind11 DESTINATION .)

{%- endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,6 @@ Homepage = "{{ cookiecutter.project_url }}"
Discussions = "{{ cookiecutter.project_url }}/discussions"
Changelog = "{{ cookiecutter.project_url }}/releases"

[tool.hatch.version]
{# keep this line here #}
{%- if cookiecutter.project_layout == 'flat' -%}
path = "{{ cookiecutter.package_slug }}/__init__.py"
{% elif cookiecutter.project_layout == 'src' -%}
path = "src/{{ cookiecutter.package_slug }}/__init__.py"
{% endif %}

{% include "build-system/base-pyproject.toml" %}
{#- keep this line at the end of the file -#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <pybind11/pybind11.h>

namespace py = pybind11;

PYBIND11_MODULE(skcdemo, m) {
m.def("hello", [](){
py::print("Hello, pybind11!");
});
}
17 changes: 17 additions & 0 deletions src/scicookie/{{cookiecutter.project_slug}}/build-system/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Available at setup time due to pyproject.toml
from pybind11.setup_helpers import Pybind11Extension
from setuptools import setup


setup(
name="OSL Python package",
author="{{cookiecutter.author_full_name}}",
author_email="{{cookiecutter.author_email}}",
url="https://{{ cookiecutter.project_slug }}.com",
description="A test project using pybind11",
long_description="",
#extras_require={"test": "pytest"},
# Currently, build_ext only provides an optional "highest supported C++
# level" feature, but in the future it may provide more features.
python_requires=">=3.7",
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace py = pybind11;

PYBIND11_MODULE(skcdemo, m) {
m.def("hello", [](){
py::print("Hello !!!");
py::print("Hello, scikit-build-core!");
});
}

0 comments on commit e9c6226

Please sign in to comment.