- 
                Notifications
    You must be signed in to change notification settings 
- Fork 74
Add more tests of package traversal #906
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
          
     Merged
      
        
      
            henryiii
  merged 17 commits into
  scikit-build:main
from
vyasr:test/editable_package_traversal
  
      
      
   
  Apr 1, 2025 
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            17 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      3e258f4
              
                Add full set of new tests
              
              
                vyasr bd7d853
              
                Move assert into subprocess
              
              
                vyasr f1717f4
              
                Also import all extension modules in __init__.py files
              
              
                vyasr c413257
              
                Remove now duplicative imports
              
              
                vyasr 37d39cf
              
                Differentiate module and package names
              
              
                vyasr 7081389
              
                Add more nested imports
              
              
                vyasr 0acee29
              
                Consolidate and simplify package names
              
              
                vyasr 29c47a9
              
                Update test_importlib_resources
              
              
                vyasr c73d62e
              
                Add top-level modules
              
              
                vyasr 94effd3
              
                Add navigation checks to top-level
              
              
                LecrisUT 33f41fd
              
                De-duplicate some import checks
              
              
                LecrisUT 7407a8c
              
                Populate the stub file contents
              
              
                LecrisUT 861d6b0
              
                Change the import targets to the functions
              
              
                LecrisUT a463286
              
                Add sibling navigation
              
              
                LecrisUT e39cf5a
              
                Add cousin navigation
              
              
                LecrisUT cc63b29
              
                Simplify and fix test_importlib_resources
              
              
                LecrisUT 007966b
              
                Merge branch 'main' into test/editable_package_traversal
              
              
                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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
| def square(x: float) -> float: ... | 
  
    
      This file contains hidden or 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 hidden or 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,32 @@ | ||
| # Don't let ruff sort imports in this file, we want to keep them with the comments as is | ||
| # for clarity. | ||
| # ruff: noqa: I001, F401 | ||
| # mypy: ignore-errors | ||
|  | ||
| # Level zero import global modules | ||
| from pmod import square as psquare | ||
| from emod import square as esquare | ||
|  | ||
| # Level one pure modules | ||
| from .pmod_a import square as psquare_a | ||
|  | ||
| # Level one extension modules | ||
| from .emod_a import square as esquare_a | ||
|  | ||
| # Level one subpackages | ||
| from . import sub_a | ||
|  | ||
| # Level two pure modules | ||
| from .sub_a.pmod_b import square as psquare_b | ||
|  | ||
| # Level two extension modules | ||
| from .sub_a.emod_b import square as esquare_b | ||
|  | ||
| # Level two subpackages | ||
| from .sub_b import sub_c | ||
|  | ||
| # Level three pure modules | ||
| from .sub_b.sub_c.pmod_d import square as psquare_d | ||
|  | ||
| # Level three extension modules | ||
| from .sub_b.sub_c.emod_d import square as esquare_d | 
  
    
      This file contains hidden or 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); | ||
| } | 
  
    
      This file contains hidden or 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 @@ | ||
| def square(x: float) -> float: ... | 
  
    
      This file contains hidden or 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 @@ | ||
| # ruff: noqa: I001, F401 | ||
| # mypy: ignore-errors | ||
|  | ||
| # Level one import sibling | ||
| from .emod_a import square as esquare | ||
|  | ||
|  | ||
| def square(x): | ||
| return x * x | 
  
    
      This file contains hidden or 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 hidden or 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,15 @@ | ||
| # ruff: noqa: I001, F401 | ||
| # mypy: ignore-errors | ||
|  | ||
| from .pmod_b import square as psquare | ||
| from .emod_b import square as esquare | ||
|  | ||
| # Level one import cousin | ||
| from .. import sub_b | ||
| from ..sub_b.pmod_c import square as psquare_c | ||
| from ..sub_b.emod_c import square as esquare_c | ||
|  | ||
| # Level one import distant cousin | ||
| from ..sub_b import sub_c | ||
| from ..sub_b.sub_c.pmod_d import square as psquare_d | ||
| from ..sub_b.sub_c.emod_d import square as esquare_d | 
  
    
      This file contains hidden or 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); | ||
| } | 
  
    
      This file contains hidden or 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 @@ | ||
| def square(x: float) -> float: ... | 
  
    
      This file contains hidden or 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 @@ | ||
| # ruff: noqa: I001, F401 | ||
| # mypy: ignore-errors | ||
|  | ||
| # Level two import sibling | ||
| from .emod_b import square as esquare | ||
|  | ||
|  | ||
| def square(x): | ||
| return x * x | 
  
    
      This file contains hidden or 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 hidden or 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,19 @@ | ||
| # Don't let ruff sort imports in this file, we want to keep them with the comments as is | ||
| # for clarity. | ||
| # ruff: noqa: I001, F401 | ||
| # mypy: ignore-errors | ||
|  | ||
| # Level one pure modules | ||
| from .pmod_c import square as psquare_c | ||
|  | ||
| # Level one extension modules | ||
| from .emod_c import square as esquare_c | ||
|  | ||
| # Level one subpackages | ||
| from . import sub_c | ||
|  | ||
| # Level two pure modules | ||
| from .sub_c.pmod_d import square as psquare_d | ||
|  | ||
| # Level two extension modules | ||
| from .sub_c.emod_d import square as esquare_d | 
  
    
      This file contains hidden or 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); | ||
| } | 
  
    
      This file contains hidden or 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 @@ | ||
| def square(x: float) -> float: ... | 
  
    
      This file contains hidden or 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 @@ | ||
| # ruff: noqa: I001, F401 | ||
| # mypy: ignore-errors | ||
|  | ||
| # Level two import sibling | ||
| from .emod_c import square as esquare | ||
|  | ||
|  | ||
| 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 hidden or 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/) | 
        
          
          
            10 changes: 10 additions & 0 deletions
          
          10 
        
  tests/packages/importlib_editable/pkg/sub_b/sub_c/__init__.py
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or 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 @@ | ||
| # ruff: noqa: I001, F401 | ||
| # mypy: ignore-errors | ||
|  | ||
| from .pmod_d import square as psquare_d | ||
| from .emod_d import square as esquare_d | ||
|  | ||
| # Level one import cousin | ||
| from .. import sub_d | ||
| from ..sub_d.pmod_e import square as psquare_e | ||
| from ..sub_d.emod_e import square as esquare_e | 
        
          
          
            25 changes: 25 additions & 0 deletions
          
          25 
        
  tests/packages/importlib_editable/pkg/sub_b/sub_c/emod_d.c
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or 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); | ||
| } | 
  
    
      This file contains hidden or 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 @@ | ||
| def square(x: float) -> float: ... | 
  
    
      This file contains hidden or 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 @@ | ||
| # ruff: noqa: I001, F401 | ||
| # mypy: ignore-errors | ||
|  | ||
| # Level three import sibling | ||
| from .emod_d import square as esquare | ||
|  | ||
|  | ||
| 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 hidden or 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/) | 
        
          
          
            5 changes: 5 additions & 0 deletions
          
          5 
        
  tests/packages/importlib_editable/pkg/sub_b/sub_d/__init__.py
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or 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 @@ | ||
| # ruff: noqa: I001, F401 | ||
| # mypy: ignore-errors | ||
|  | ||
| from .pmod_e import square as psquare_e | ||
| from .emod_e import square as esquare_e | 
        
          
          
            25 changes: 25 additions & 0 deletions
          
          25 
        
  tests/packages/importlib_editable/pkg/sub_b/sub_d/emod_e.c
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or 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); | ||
| } | 
  
    
      This file contains hidden or 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 @@ | ||
| def square(x: float) -> float: ... | 
  
    
      This file contains hidden or 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 @@ | ||
| # ruff: noqa: I001, F401 | ||
| # mypy: ignore-errors | ||
|  | ||
| # Level three import sibling | ||
| from .emod_e import square as esquare | ||
|  | ||
|  | ||
| def square(x): | ||
| return x * x | 
  
    
      This file contains hidden or 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 @@ | ||
| # ruff: noqa: I001, F401 | ||
| # mypy: ignore-errors | ||
|  | ||
| # Level zero import global sibling | ||
| from emod import square as esquare | ||
|  | ||
|  | ||
| def square(x): | ||
| return x * x | 
  
    
      This file contains hidden or 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.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.