Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
606313ee
Commit
606313ee
authored
May 05, 2020
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename embedding tests in docs to make it easier to find and select in the test suite.
parent
97689343
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
+11
-11
docs/examples/tutorial/embedding/embedded.pyx
docs/examples/tutorial/embedding/embedded.pyx
+2
-2
docs/examples/tutorial/embedding/embedded_main.c
docs/examples/tutorial/embedding/embedded_main.c
+5
-5
docs/src/tutorial/embedding.rst
docs/src/tutorial/embedding.rst
+4
-4
No files found.
docs/examples/tutorial/embedding/
spam
.pyx
→
docs/examples/tutorial/embedding/
embedded
.pyx
View file @
606313ee
#
spam
.pyx
#
embedded
.pyx
# The following two lines are for test purposed only, please ignore them.
# distutils: sources =
spam
_main.c
# distutils: sources =
embedded
_main.c
# tag: py3only
TEXT_TO_SAY
=
'Hello from Python!'
...
...
docs/examples/tutorial/embedding/
spam
_main.c
→
docs/examples/tutorial/embedding/
embedded
_main.c
View file @
606313ee
/*
spam
_main.c */
/*
embedded
_main.c */
/* This include file is automatically generated by Cython for 'public' functions. */
#include "
spam
.h"
#include "
embedded
.h"
int
main
(
int
argc
,
char
*
argv
[])
...
...
@@ -16,7 +16,7 @@ main(int argc, char *argv[])
}
/* Add a built-in module, before Py_Initialize */
if
(
PyImport_AppendInittab
(
"
spam"
,
PyInit_spam
)
==
-
1
)
{
if
(
PyImport_AppendInittab
(
"
embedded"
,
PyInit_embedded
)
==
-
1
)
{
fprintf
(
stderr
,
"Error: could not extend in-built modules table
\n
"
);
exit
(
1
);
}
...
...
@@ -31,10 +31,10 @@ main(int argc, char *argv[])
/* Optionally import the module; alternatively,
import can be deferred until the embedded script
imports it. */
pmodule
=
PyImport_ImportModule
(
"
spam
"
);
pmodule
=
PyImport_ImportModule
(
"
embedded
"
);
if
(
!
pmodule
)
{
PyErr_Print
();
fprintf
(
stderr
,
"Error: could not import module '
spam
'
\n
"
);
fprintf
(
stderr
,
"Error: could not import module '
embedded
'
\n
"
);
goto
exit_with_error
;
}
...
...
docs/src/tutorial/embedding.rst
View file @
606313ee
...
...
@@ -50,18 +50,18 @@ Embedding example code
======================
The following is a simple example that shows the main steps for embedding a
Cython module (``
spam
.pyx``) in Python 3.x.
Cython module (``
embedded
.pyx``) in Python 3.x.
First, here is a Cython module that exports a C function to be called by external
code. Note that the ``say_hello_from_python()`` function is declared as ``public``
to export it as a linker symbol that can be used by other C files, which in this
case is ``
spam
_main.c``.
case is ``
embedded
_main.c``.
.. literalinclude:: ../../examples/tutorial/embedding/
spam
.pyx
.. literalinclude:: ../../examples/tutorial/embedding/
embedded
.pyx
The C ``main()`` function of your program could look like this:
.. literalinclude:: ../../examples/tutorial/embedding/
spam
_main.c
.. literalinclude:: ../../examples/tutorial/embedding/
embedded
_main.c
:linenos:
:language: c
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment