File tree Expand file tree Collapse file tree 7 files changed +68
-0
lines changed
projects/core-cython-hello Expand file tree Collapse file tree 7 files changed +68
-0
lines changed Original file line number Diff line number Diff line change 77 "hello-cpp" ,
88 "hello-pybind11" ,
99 "hello-cython" ,
10+ "core-cython-hello" ,
1011]
1112if not sys .platform .startswith ("win" ):
1213 hello_list .extend (
Original file line number Diff line number Diff line change 1+ cmake_minimum_required (VERSION 3.15...3.26)
2+
3+ project (${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES C)
4+
5+ find_package (
6+ Python
7+ COMPONENTS Interpreter Development.Module
8+ REQUIRED)
9+ find_program (CYTHON "cython" )
10+
11+ add_subdirectory (hello)
Original file line number Diff line number Diff line change 1+ add_custom_command (
2+ OUTPUT _hello.c
3+ DEPENDS _hello.pyx
4+ COMMAND "${CYTHON} "
5+ "${CMAKE_CURRENT_SOURCE_DIR} /_hello.pyx"
6+ --output -file "${CMAKE_CURRENT_BINARY_DIR} /_hello.c"
7+ VERBATIM
8+ )
9+
10+ Python_add_library(_hello
11+ MODULE "${CMAKE_CURRENT_BINARY_DIR} /_hello.c"
12+ WITH_SOABI)
13+
14+ install (TARGETS _hello LIBRARY DESTINATION ${SKBUILD_PROJECT_NAME} )
Original file line number Diff line number Diff line change 1+ from ._hello import elevation , hello
2+
3+ __all__ = ("hello" , "elevation" )
Original file line number Diff line number Diff line change 1+
2+ cpdef void hello(str strArg):
3+ " Prints back 'Hello <param>', for example example: hello.hello('you')"
4+ print (" Hello, {}!" .format(strArg))
5+
6+ cpdef long elevation():
7+ " Returns elevation of Nevado Sajama."
8+ return 21463L
Original file line number Diff line number Diff line change 1+ [build-system ]
2+ requires = [" scikit-build-core[pyproject]" , " cython" ]
3+ build-backend = " scikit_build_core.build"
4+
5+ [project ]
6+ name = " hello"
7+ version = " 1.2.3"
8+ authors = [
9+ { name = " The scikit-build team" },
10+ ]
11+ description = " a minimal example package (cython version)"
12+ requires-python = " >=3.8"
13+ classifiers = [
14+ " License :: OSI Approved :: MIT License" ,
15+ ]
16+ dependencies = []
17+
18+ [tool .scikit-build ]
19+ cmake.source-dir = " ."
20+ minimum-version = " 0.5"
Original file line number Diff line number Diff line change 1+ import hello
2+
3+
4+ def test_hello (capfd ):
5+ hello .hello ("World" )
6+ captured = capfd .readouterr ()
7+ assert captured .out == "Hello, World!\n "
8+
9+
10+ def test_elevation ():
11+ assert hello .elevation () == 21463
You can’t perform that action at this time.
0 commit comments