-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor testing to use an example package, instead of devpy itself (#25
) This also allows us to test the building of binaries Closes #10
- Loading branch information
Showing
14 changed files
with
120 additions
and
12 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
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
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
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
File renamed without changes.
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 @@ | ||
build | ||
build-install |
File renamed without changes.
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 @@ | ||
from ._core import echo |
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,44 @@ | ||
#define PY_SSIZE_T_CLEAN | ||
#include <Python.h> | ||
|
||
static PyObject * | ||
core_echo(PyObject *self, PyObject *args) | ||
{ | ||
const char *str; | ||
PyObject *ret; | ||
|
||
if (!PyArg_ParseTuple(args, "s", &str)) | ||
return NULL; | ||
|
||
printf("%s\n", str); | ||
|
||
ret = PyLong_FromLong(42); | ||
Py_INCREF(ret); | ||
return ret; | ||
} | ||
|
||
static PyMethodDef CoreMethods[] = { | ||
{"echo", core_echo, METH_VARARGS, "Echo a string and return 42"}, | ||
{NULL, NULL, 0, NULL} /* Sentinel */ | ||
}; | ||
|
||
static struct PyModuleDef coremodule = { | ||
PyModuleDef_HEAD_INIT, | ||
"core", /* name of module */ | ||
NULL, /* module documentation, may be NULL */ | ||
-1, /* size of per-interpreter state of the module, | ||
or -1 if the module keeps state in global variables. */ | ||
CoreMethods | ||
}; | ||
|
||
PyMODINIT_FUNC | ||
PyInit__core(void) | ||
{ | ||
PyObject *m; | ||
|
||
m = PyModule_Create(&coremodule); | ||
if (m == NULL) | ||
return NULL; | ||
|
||
return m; | ||
} |
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,17 @@ | ||
py.extension_module( | ||
'_core', | ||
'coremodule.c', | ||
install: true, | ||
subdir: 'example_pkg' | ||
) | ||
|
||
python_sources = [ | ||
'__init__.py' | ||
] | ||
|
||
py.install_sources( | ||
python_sources, | ||
subdir: 'example_pkg' | ||
) | ||
|
||
install_subdir('tests', install_dir: py.get_install_dir() / 'example_pkg/tests') |
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,6 @@ | ||
from example_pkg import echo | ||
|
||
|
||
def test_core(): | ||
ans = echo("hello world") | ||
assert ans == 42 |
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,20 @@ | ||
project( | ||
'devpy-example-pkg', | ||
'c', | ||
version: '0.0.dev0', | ||
license: 'BSD-3', | ||
meson_version: '>= 0.64.0', | ||
default_options: [ | ||
'buildtype=debugoptimized', | ||
'c_std=c99', | ||
'cpp_std=c++14', | ||
], | ||
) | ||
|
||
cc = meson.get_compiler('c') | ||
|
||
py_mod = import('python') | ||
py = py_mod.find_installation(pure: false) | ||
py_dep = py.dependency() | ||
|
||
subdir('example_pkg') |
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,17 @@ | ||
[project] | ||
name = "devpy-example" | ||
version = "0.0dev0" | ||
requires-python = ">=3.7" | ||
description = "DevPy Example Package" | ||
|
||
[tool.devpy] | ||
package = 'example_pkg' | ||
|
||
[tool.devpy.commands] | ||
# If you don't need sections, you can also provide a list of commands under [tool.devpy]: | ||
# | ||
# commands = ["devpy.build", "devpy.test", "devpy.shell", "devpy.ipython", "devpy.python", "custom/cmds.py:example"] | ||
|
||
"Build" = ["devpy.build", "devpy.test"] | ||
"Environments" = ["devpy.shell", "devpy.ipython", "devpy.python"] | ||
"Extensions" = [".devpy/cmds.py:example"] |
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