Skip to content

Commit 9009d5e

Browse files
committed
refactor: Rename cython_compile_pyx to cython_transpile
The verb "transpile" more accurately describes the role of the function, as it is used to convert Cython (or Python) code to C/C++ code rather than directly compiling it. This change aligns the function name with its intended purpose.
1 parent dc6f901 commit 9009d5e

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/cython_cmake/cmake/UseCython.cmake

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
#
33
# The following functions are defined:
44
#
5-
# .. cmake:command:: Cython_compile_pyx
5+
# .. cmake:command:: Cython_transpile
66
#
77
# Create custom rules to generate the source code for a Python extension module
88
# using cython.
99
#
10-
# Cython_compile_pyx(<pyx_file>
11-
# [LANGUAGE C | CXX]
12-
# [CYTHON_ARGS <args> ...]
13-
# [OUTPUT <OutputFile>]
14-
# [OUTPUT_VARIABLE <OutputVariable>])
10+
# Cython_transpile(<pyx_file>
11+
# [LANGUAGE C | CXX]
12+
# [CYTHON_ARGS <args> ...]
13+
# [OUTPUT <OutputFile>]
14+
# [OUTPUT_VARIABLE <OutputVariable>])
1515
#
1616
# Options:
1717
#
@@ -44,7 +44,7 @@
4444
# find_package(Cython)
4545
# include(UseCython)
4646
#
47-
# Cython_compile_pyx(_hello.pyx
47+
# Cython_transpile(_hello.pyx
4848
# OUTPUT_VARIABLE _hello_source_files
4949
# )
5050
#
@@ -76,7 +76,7 @@ if(CMAKE_VERSION VERSION_LESS "3.8")
7676
message(FATAL_ERROR "CMake 3.8 required for COMMAND_EXPAND_LISTS")
7777
endif()
7878

79-
function(Cython_compile_pyx)
79+
function(Cython_transpile)
8080
set(_options )
8181
set(_one_value LANGUAGE OUTPUT OUTPUT_VARIABLE)
8282
set(_multi_value CYTHON_ARGS)
@@ -110,14 +110,14 @@ function(Cython_compile_pyx)
110110
message(FATAL_ERROR "One and only one input file must be specified, got '${_source_files}'")
111111
endif()
112112

113-
function(_compile_pyx _source_file generated_file language)
113+
function(_transpile _source_file generated_file language)
114114

115115
if(language STREQUAL "C")
116116
set(_language_arg "")
117117
elseif(language STREQUAL "CXX")
118118
set(_language_arg "--cplus")
119119
else()
120-
message(FATAL_ERROR "_compile_pyx language must be one of C or CXX")
120+
message(FATAL_ERROR "_transpile language must be one of C or CXX")
121121
endif()
122122

123123
set_source_files_properties(${generated_file} PROPERTIES GENERATED TRUE)
@@ -215,7 +215,7 @@ function(Cython_compile_pyx)
215215
endif()
216216

217217
if(NOT _language MATCHES "^(C|CXX)$")
218-
message(FATAL_ERROR "cython_compile_pyx LANGUAGE must be one of C or CXX")
218+
message(FATAL_ERROR "Cython_transpile LANGUAGE must be one of C or CXX")
219219
endif()
220220

221221
# Place the cython files in the current binary dir if no path given
@@ -226,7 +226,7 @@ function(Cython_compile_pyx)
226226
endif()
227227

228228
set(generated_file ${_args_OUTPUT})
229-
_compile_pyx(${_source_file} ${generated_file} ${_language})
229+
_transpile(${_source_file} ${generated_file} ${_language})
230230
list(APPEND generated_files ${generated_file})
231231

232232
# Output variable only if set

tests/packages/multiple_packages/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include(UseCython)
1010

1111
#-----------------------------------------------------------------------------
1212
# package1.module
13-
cython_compile_pyx(package1/module.pyx
13+
cython_transpile(package1/module.pyx
1414
LANGUAGE C
1515
OUTPUT_VARIABLE module_c
1616
)
@@ -21,7 +21,7 @@ install(TARGETS module1 DESTINATION "package1")
2121

2222
#-----------------------------------------------------------------------------
2323
# package1.package2.module
24-
cython_compile_pyx(package1/package2/module.pyx
24+
cython_transpile(package1/package2/module.pyx
2525
LANGUAGE C
2626
OUTPUT_VARIABLE module_c
2727
)
@@ -35,7 +35,7 @@ install(TARGETS module2 DESTINATION "package1/package2")
3535

3636
file(COPY package1/package2/module.pyx DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/..)
3737

38-
cython_compile_pyx(${CMAKE_CURRENT_SOURCE_DIR}/../module.pyx
38+
cython_transpile(${CMAKE_CURRENT_SOURCE_DIR}/../module.pyx
3939
LANGUAGE C
4040
CYTHON_ARGS
4141
--module-name "package1.package3.module"

tests/packages/simple/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ find_package(
88
find_package(Cython MODULE REQUIRED VERSION 3.0)
99
include(UseCython)
1010

11-
cython_compile_pyx(simple.pyx
11+
cython_transpile(simple.pyx
1212
LANGUAGE C
1313
# PLACEHOLDER
1414
OUTPUT_VARIABLE simple_c

0 commit comments

Comments
 (0)