forked from actions/setup-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make link.exe find PyPy's
python*.lib
Point `LIB` environment variable to `libs` directory of extracted PyPy on Windows, so that `link.exe` find it while building Python extensions: https://learn.microsoft.com/en-us/cpp/build/reference/linking?view=msvc-170#link-environment-variables Add a test for building Python extension.
- Loading branch information
Showing
7 changed files
with
97 additions
and
1 deletion.
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,41 @@ | ||
name: e2e-extension | ||
|
||
on: | ||
pull_request: | ||
paths-ignore: | ||
- '**.md' | ||
push: | ||
branches: | ||
- main | ||
- releases/* | ||
paths-ignore: | ||
- '**.md' | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
jobs: | ||
python-extension: | ||
name: Test building extensions (Python ${{ matrix.python-version}}, ${{ matrix.os }}) | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
python-version: ['3.9', 'pypy-3.9-v7.x'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Python | ||
uses: ./ | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: 'pip' | ||
- name: Install dependencies | ||
run: pip install setuptools | ||
- name: Build extension | ||
run: pip install . | ||
working-directory: __tests__/data/extension/ | ||
- name: Check output | ||
run: | | ||
output=$(python3 -c "import helloworld; helloworld.say_hello('world')") | ||
test "$output" == "Hello, world!" |
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,27 @@ | ||
#include <Python.h> | ||
|
||
static PyObject * say_hello(PyObject *self, PyObject *args) { | ||
const char *name; | ||
if (!PyArg_ParseTuple(args, "s", &name)) | ||
return NULL; | ||
PySys_WriteStdout("Hello, %s!", name); | ||
Py_RETURN_NONE; | ||
} | ||
|
||
static PyMethodDef HelloWorldMethods[] = { | ||
{"say_hello", say_hello, METH_VARARGS, "Say hello"}, | ||
{NULL, NULL, 0, NULL} | ||
}; | ||
|
||
static struct PyModuleDef hello_world_module = { | ||
PyModuleDef_HEAD_INIT, | ||
"helloworld", | ||
NULL, | ||
-1, | ||
HelloWorldMethods | ||
}; | ||
|
||
PyMODINIT_FUNC PyInit_helloworld(void) | ||
{ | ||
return PyModule_Create(&hello_world_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,7 @@ | ||
[build-system] | ||
requires = ["setuptools"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "helloworld" | ||
version = "1.0" |
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 @@ | ||
from setuptools import Extension, setup | ||
|
||
setup( | ||
ext_modules=[ | ||
Extension( | ||
name="helloworld", | ||
sources=["hello_world.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
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