-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add a test for cython structured_sources
- Loading branch information
Showing
6 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
|
||
|
||
def main() -> None: | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('out') | ||
args = parser.parse_args() | ||
|
||
with open(args.out, 'w') as f: | ||
f.write('cpdef int generate(int in_)\n') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
cpdef int generate(int in_): | ||
return in_ + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from gen import generated | ||
|
||
cpdef int foo(int in_): | ||
return generated(in_) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
project('structured sources', 'cython') | ||
|
||
py_mod = import('python') | ||
py3 = py_mod.find_installation('python3') | ||
py3_dep = py3.dependency(required : false) | ||
if not py3_dep.found() | ||
error('MESON_SKIP_TEST: Python library not found.') | ||
endif | ||
|
||
gen = custom_target( | ||
'gen.pyd', | ||
output : ['gen.pyd'], | ||
command : ['gen.py', '@OUTPUT@'], | ||
) | ||
|
||
py3.extension_module( | ||
'lib', | ||
structured_sources( | ||
'lib.pyx', | ||
{'gen' : [gen, 'gen/gen.pyx', 'gen/__init__.pyd']}, | ||
), | ||
dependencies : py3_dep, | ||
) | ||
|
||
test( | ||
'lib', | ||
py3, | ||
args : [files('test.py')], | ||
env : ['PYTHONPATH=' + meson.current_build_dir()] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import lib | ||
|
||
|
||
def main() -> int: | ||
return int(lib.generate(1)) == 2 | ||
|
||
|
||
if __name__ == "__main__": | ||
exit(main()) |