-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more tests of package traversal #906
Draft
vyasr
wants to merge
9
commits into
scikit-build:main
Choose a base branch
from
vyasr:test/editable_package_traversal
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
56ee6eb
Add full set of new tests
vyasr 6c8bb9a
Move assert into subprocess
vyasr 84a04ba
Also import all extension modules in __init__.py files
vyasr 81a4224
Remove now duplicative imports
vyasr 35f6128
Differentiate module and package names
vyasr 8a5f301
Add more nested imports
vyasr 6ad3b64
Consolidate and simplify package names
vyasr cd29989
Update test_importlib_resources
vyasr e119367
Add top-level modules
vyasr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,13 @@ | ||
cmake_minimum_required(VERSION 3.15...3.26) | ||
project(${SKBUILD_PROJECT_NAME} LANGUAGES C) | ||
|
||
find_package( | ||
Python | ||
COMPONENTS Interpreter Development.Module | ||
REQUIRED) | ||
|
||
python_add_library(emod MODULE emod.c WITH_SOABI) | ||
install(TARGETS emod DESTINATION .) | ||
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/pmod.py" DESTINATION .) | ||
|
||
add_subdirectory(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,25 @@ | ||
#define PY_SSIZE_T_CLEAN | ||
#include <Python.h> | ||
|
||
float square(float x) { return x * x; } | ||
|
||
static PyObject *square_wrapper(PyObject *self, PyObject *args) { | ||
float input, result; | ||
if (!PyArg_ParseTuple(args, "f", &input)) { | ||
return NULL; | ||
} | ||
result = square(input); | ||
return PyFloat_FromDouble(result); | ||
} | ||
|
||
static PyMethodDef emod_methods[] = { | ||
{"square", square_wrapper, METH_VARARGS, "Square function"}, | ||
{NULL, NULL, 0, NULL}}; | ||
|
||
static struct PyModuleDef emod_module = {PyModuleDef_HEAD_INIT, "emod", | ||
NULL, -1, emod_methods}; | ||
|
||
/* name here must match extension name, with PyInit_ prefix */ | ||
PyMODINIT_FUNC PyInit_emod(void) { | ||
return PyModule_Create(&emod_module); | ||
} |
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,8 @@ | ||
python_add_library(emod_a MODULE emod_a.c WITH_SOABI) | ||
|
||
install(TARGETS emod_a DESTINATION pkg/) | ||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testfile" "This is the file") | ||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/testfile" DESTINATION pkg/) | ||
|
||
add_subdirectory(sub_a) | ||
add_subdirectory(sub_b) |
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,48 @@ | ||||||
# Don't let ruff sort imports in this file, we want to keep them with the comments as is | ||||||
# for clarity. | ||||||
# ruff: noqa: I001 | ||||||
|
||||||
# Level one pure modules | ||||||
from . import pmod_a | ||||||
|
||||||
# Level one extension modules | ||||||
from . import emod_a | ||||||
|
||||||
# Level one subpackages | ||||||
from . import sub_a, sub_b | ||||||
|
||||||
# Level two pure modules | ||||||
from .sub_a import pmod_b | ||||||
from .sub_b import pmod_c | ||||||
|
||||||
# Level two extension modules | ||||||
from .sub_a import emod_b | ||||||
from .sub_b import emod_c | ||||||
|
||||||
# Level two subpackages | ||||||
from .sub_b import sub_c, sub_d | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Let's focus the |
||||||
|
||||||
# Level three pure modules | ||||||
from .sub_b.sub_c import pmod_d | ||||||
from .sub_b.sub_d import pmod_e | ||||||
|
||||||
# Level three extension modules | ||||||
from .sub_b.sub_c import emod_d | ||||||
from .sub_b.sub_d import emod_e | ||||||
|
||||||
__all__ = [ | ||||||
"emod_a", | ||||||
"emod_b", | ||||||
"emod_c", | ||||||
"emod_d", | ||||||
"emod_e", | ||||||
"pmod_a", | ||||||
"pmod_b", | ||||||
"pmod_c", | ||||||
"pmod_d", | ||||||
"pmod_e", | ||||||
"sub_a", | ||||||
"sub_b", | ||||||
"sub_c", | ||||||
"sub_d", | ||||||
] |
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,25 @@ | ||
#define PY_SSIZE_T_CLEAN | ||
#include <Python.h> | ||
|
||
float square(float x) { return x * x; } | ||
|
||
static PyObject *square_wrapper(PyObject *self, PyObject *args) { | ||
float input, result; | ||
if (!PyArg_ParseTuple(args, "f", &input)) { | ||
return NULL; | ||
} | ||
result = square(input); | ||
return PyFloat_FromDouble(result); | ||
} | ||
|
||
static PyMethodDef emod_a_methods[] = { | ||
{"square", square_wrapper, METH_VARARGS, "Square function"}, | ||
{NULL, NULL, 0, NULL}}; | ||
|
||
static struct PyModuleDef emod_a_module = {PyModuleDef_HEAD_INIT, "emod_a", | ||
NULL, -1, emod_a_methods}; | ||
|
||
/* name here must match extension name, with PyInit_ prefix */ | ||
PyMODINIT_FUNC PyInit_emod_a(void) { | ||
return PyModule_Create(&emod_a_module); | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could these be populated with an actual implementation. Probably: def square(x: float): -> float
... |
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 @@ | ||
def square(x): | ||
return x * x |
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,5 @@ | ||
python_add_library(emod_b MODULE emod_b.c WITH_SOABI) | ||
|
||
install(TARGETS emod_b DESTINATION pkg/sub_a) | ||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testfile" "This is the file") | ||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/testfile" DESTINATION pkg/sub_a) |
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,3 @@ | ||
from . import emod_b, pmod_b | ||
|
||
__all__ = ["emod_b", "pmod_b"] |
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,25 @@ | ||
#define PY_SSIZE_T_CLEAN | ||
#include <Python.h> | ||
|
||
float square(float x) { return x * x; } | ||
|
||
static PyObject *square_wrapper(PyObject *self, PyObject *args) { | ||
float input, result; | ||
if (!PyArg_ParseTuple(args, "f", &input)) { | ||
return NULL; | ||
} | ||
result = square(input); | ||
return PyFloat_FromDouble(result); | ||
} | ||
|
||
static PyMethodDef emod_b_methods[] = { | ||
{"square", square_wrapper, METH_VARARGS, "Square function"}, | ||
{NULL, NULL, 0, NULL}}; | ||
|
||
static struct PyModuleDef emod_b_module = {PyModuleDef_HEAD_INIT, "emod_b", | ||
NULL, -1, emod_b_methods}; | ||
|
||
/* name here must match extension name, with PyInit_ prefix */ | ||
PyMODINIT_FUNC PyInit_emod_b(void) { | ||
return PyModule_Create(&emod_b_module); | ||
} |
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 @@ | ||
def square(x): | ||
return x * x |
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,8 @@ | ||
python_add_library(emod_c MODULE emod_c.c WITH_SOABI) | ||
|
||
install(TARGETS emod_c DESTINATION pkg/sub_b) | ||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testfile" "This is the file") | ||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/testfile" DESTINATION pkg/sub_b) | ||
|
||
add_subdirectory(sub_c) | ||
add_subdirectory(sub_d) |
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,31 @@ | ||
# Don't let ruff sort imports in this file, we want to keep them with the comments as is | ||
# for clarity. | ||
# ruff: noqa: I001 | ||
|
||
# Level one pure modules | ||
from . import pmod_c | ||
|
||
# Level one extension modules | ||
from . import emod_c | ||
|
||
# Level one subpackages | ||
from . import sub_c, sub_d | ||
|
||
# Level two pure modules | ||
from .sub_c import pmod_d | ||
from .sub_d import pmod_e | ||
|
||
# Level two extension modules | ||
from .sub_c import emod_d | ||
from .sub_d import emod_e | ||
|
||
__all__ = [ | ||
"emod_c", | ||
"emod_d", | ||
"emod_e", | ||
"pmod_c", | ||
"pmod_d", | ||
"pmod_e", | ||
"sub_c", | ||
"sub_d", | ||
] |
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,25 @@ | ||
#define PY_SSIZE_T_CLEAN | ||
#include <Python.h> | ||
|
||
float square(float x) { return x * x; } | ||
|
||
static PyObject *square_wrapper(PyObject *self, PyObject *args) { | ||
float input, result; | ||
if (!PyArg_ParseTuple(args, "f", &input)) { | ||
return NULL; | ||
} | ||
result = square(input); | ||
return PyFloat_FromDouble(result); | ||
} | ||
|
||
static PyMethodDef emod_c_methods[] = { | ||
{"square", square_wrapper, METH_VARARGS, "Square function"}, | ||
{NULL, NULL, 0, NULL}}; | ||
|
||
static struct PyModuleDef emod_c_module = {PyModuleDef_HEAD_INIT, "emod_c", | ||
NULL, -1, emod_c_methods}; | ||
|
||
/* name here must match extension name, with PyInit_ prefix */ | ||
PyMODINIT_FUNC PyInit_emod_c(void) { | ||
return PyModule_Create(&emod_c_module); | ||
} |
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 @@ | ||
def square(x): | ||
return x * x |
6 changes: 6 additions & 0 deletions
6
tests/packages/importlib_editable/pkg/sub_b/sub_c/CMakeLists.txt
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 @@ | ||
python_add_library(emod_d MODULE emod_d.c WITH_SOABI) | ||
|
||
install(TARGETS emod_d DESTINATION pkg/sub_b/sub_c) | ||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testfile" "This is the file") | ||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/testfile" | ||
DESTINATION pkg/sub_b/sub_c/) |
3 changes: 3 additions & 0 deletions
3
tests/packages/importlib_editable/pkg/sub_b/sub_c/__init__.py
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,3 @@ | ||
from . import emod_d, pmod_d | ||
|
||
__all__ = ["emod_d", "pmod_d"] |
25 changes: 25 additions & 0 deletions
25
tests/packages/importlib_editable/pkg/sub_b/sub_c/emod_d.c
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,25 @@ | ||
#define PY_SSIZE_T_CLEAN | ||
#include <Python.h> | ||
|
||
float square(float x) { return x * x; } | ||
|
||
static PyObject *square_wrapper(PyObject *self, PyObject *args) { | ||
float input, result; | ||
if (!PyArg_ParseTuple(args, "f", &input)) { | ||
return NULL; | ||
} | ||
result = square(input); | ||
return PyFloat_FromDouble(result); | ||
} | ||
|
||
static PyMethodDef emod_d_methods[] = { | ||
{"square", square_wrapper, METH_VARARGS, "Square function"}, | ||
{NULL, NULL, 0, NULL}}; | ||
|
||
static struct PyModuleDef emod_d_module = {PyModuleDef_HEAD_INIT, "emod_d", | ||
NULL, -1, emod_d_methods}; | ||
|
||
/* name here must match extension name, with PyInit_ prefix */ | ||
PyMODINIT_FUNC PyInit_emod_d(void) { | ||
return PyModule_Create(&emod_d_module); | ||
} |
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 @@ | ||
def square(x): | ||
return x * x |
6 changes: 6 additions & 0 deletions
6
tests/packages/importlib_editable/pkg/sub_b/sub_d/CMakeLists.txt
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 @@ | ||
python_add_library(emod_e MODULE emod_e.c WITH_SOABI) | ||
|
||
install(TARGETS emod_e DESTINATION pkg/sub_b/sub_d/) | ||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testfile" "This is the file") | ||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/testfile" | ||
DESTINATION pkg/sub_b/sub_d/) |
3 changes: 3 additions & 0 deletions
3
tests/packages/importlib_editable/pkg/sub_b/sub_d/__init__.py
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,3 @@ | ||
from . import emod_e, pmod_e | ||
|
||
__all__ = ["pmod_e", "emod_e"] |
25 changes: 25 additions & 0 deletions
25
tests/packages/importlib_editable/pkg/sub_b/sub_d/emod_e.c
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,25 @@ | ||
#define PY_SSIZE_T_CLEAN | ||
#include <Python.h> | ||
|
||
float square(float x) { return x * x; } | ||
|
||
static PyObject *square_wrapper(PyObject *self, PyObject *args) { | ||
float input, result; | ||
if (!PyArg_ParseTuple(args, "f", &input)) { | ||
return NULL; | ||
} | ||
result = square(input); | ||
return PyFloat_FromDouble(result); | ||
} | ||
|
||
static PyMethodDef emod_e_methods[] = { | ||
{"square", square_wrapper, METH_VARARGS, "Square function"}, | ||
{NULL, NULL, 0, NULL}}; | ||
|
||
static struct PyModuleDef emod_e_module = {PyModuleDef_HEAD_INIT, "emod_e", | ||
NULL, -2, emod_e_methods}; | ||
|
||
/* name here must match extension name, with PyInit_ prefix */ | ||
PyMODINIT_FUNC PyInit_emod_e(void) { | ||
return PyModule_Create(&emod_e_module); | ||
} |
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 @@ | ||
def square(x): | ||
return x * x |
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 @@ | ||
def square(x): | ||
return x * x |
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,10 @@ | ||
[build-system] | ||
requires = ["scikit-build-core"] | ||
build-backend = "scikit_build_core.build" | ||
|
||
[project] | ||
name = "pkg" | ||
version = "0.0.1" | ||
|
||
[tool.scikit-build] | ||
build-dir = "build/{wheel_tag}" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be needed, specify the
wheel.packages
in thepyproject.toml
instead