Skip to content

Update p02_write_simple_c_extension_module.rst #345

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
merged 1 commit into from
Feb 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions source/c15/p02_write_simple_c_extension_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
有了这些,下面我们演示下编写扩展函数的一个简单例子:

::

/* pysample.c */
#include "Python.h"
#include "sample.h"

Expand Down Expand Up @@ -103,20 +103,16 @@
# setup.py
from distutils.core import setup, Extension

setup(name='sample',
setup(name="sample",
ext_modules=[
Extension('sample',
['pysample.c'],
include_dirs = ['/some/dir'],
define_macros = [('FOO','1')],
undef_macros = ['BAR'],
library_dirs = ['/usr/local/lib'],
libraries = ['sample']
Extension("sample",
["../sample.c", "pysample.c"],
include_dirs = ['..'],
)
]
)

为了构建最终的函数库,只需简单的使用 ``python3 buildlib.py build_ext --inplace`` 命令即可:
为了构建最终的函数库,只需简单的使用 ``python3 setup.py build_ext --inplace`` 命令即可:

::

Expand Down