Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The current implementation had logic errors -- it did not support paths containing a '.'. Support the "root package" and duplicate the logic from distutils, which is documented and expected. https://docs.python.org/2/distutils/setupscript.html#listing-whole-packages
- Loading branch information
Showing
8 changed files
with
172 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
"""test_root_package | ||
---------------------------------- | ||
Ensure that skbuild supports the root package, i.e. the nameless top level | ||
"package". | ||
""" | ||
|
||
from . import project_setup_py_test | ||
|
||
|
||
@project_setup_py_test(("unit", "root-package"), ["build"], clear_cache=True) | ||
def test_hello_builds(): | ||
pass |
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,11 @@ | ||
cmake_minimum_required(VERSION 3.5.0) | ||
|
||
project(root-package) | ||
|
||
enable_testing() | ||
|
||
find_package(PythonInterp REQUIRED) | ||
find_package(PythonLibs REQUIRED) | ||
find_package(PythonExtensions REQUIRED) | ||
|
||
add_subdirectory(lib) |
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 @@ | ||
add_library(_spam MODULE _spam.c) | ||
python_extension_module(_spam) | ||
|
||
add_test(NAME spam | ||
COMMAND ${PYTHON_EXECUTABLE} -m spam | ||
WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}) | ||
|
||
install(TARGETS _spam LIBRARY DESTINATION "lib") | ||
install(FILES spam.py DESTINATION "lib") |
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,41 @@ | ||
#include <Python.h> | ||
|
||
static PyObject * | ||
spam_system(PyObject *self, PyObject *args) | ||
{ | ||
const char *command; | ||
int sts; | ||
|
||
if (!PyArg_ParseTuple(args, "s", &command)) | ||
return NULL; | ||
sts = system(command); | ||
return PyLong_FromLong(sts); | ||
} | ||
|
||
|
||
static PyMethodDef spam_methods[] = { | ||
{"system", spam_system, METH_VARARGS, | ||
"Execute a shell command."}, | ||
{NULL, NULL, 0, NULL} /* Sentinel */ | ||
}; | ||
|
||
|
||
#if PY_MAJOR_VERSION < 3 | ||
PyMODINIT_FUNC init_spam(void) | ||
{ | ||
(void) Py_InitModule("_spam", spam_methods); | ||
} | ||
#else /* PY_MAJOR_VERSION >= 3 */ | ||
static struct PyModuleDef spam_module_def = { | ||
PyModuleDef_HEAD_INIT, | ||
"_spam", | ||
"Internal \"_spam\" module", | ||
-1, | ||
spam_methods | ||
}; | ||
|
||
PyMODINIT_FUNC PyInit__spam(void) | ||
{ | ||
return PyModule_Create(&spam_module_def); | ||
} | ||
#endif /* PY_MAJOR_VERSION >= 3 */ |
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 ._spam import spam # noqa: F401 |
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,11 @@ | ||
from skbuild import setup | ||
|
||
setup( | ||
name="root-package", | ||
version="1.2.3", | ||
description="a package that populates the root (nameless) package", | ||
author='The scikit-build team', | ||
license="MIT", | ||
package_dir={'': 'lib'}, | ||
py_modules=['spam'] | ||
) |