There are two more things to do before you can use your new extension: compiling and linking it with the Python system. If you use dynamic loading, the details may depend on the style of dynamic loading your system uses; see the chapters about building extension modules (chapter 3) and additional information that pertains only to building on Windows (chapter 4) for more information about this.
在使用我们的新扩展前我们还需要做两件事:编译和与python系统连接。如果你使用动态载入,那么细节将主要取决于你的系统动态载入的方式。
If you can't use dynamic loading, or if you want to make your module a permanent part of the Python interpreter, you will have to change the configuration setup and rebuild the interpreter. Luckily, this is very simple on Unix: just place your file (spammodule.c for example) in the Modules/ directory of an unpacked source distribution, add a line to the file Modules/Setup.local describing your file:
如果你不是使用动态载入,或者你希望你的模块成为python编译器永久的一部分,你需要改变的你的启动设置并且重新编译你的编译器。幸运的是,这项工作在Unix环境下非常简单:只要将spammodule.c文件放入Modules/ directory 目录,并且在Modules/Setup.local文件中加入一行来描述你的文件:
and rebuild the interpreter by running make in the toplevel directory. You can also run make in the Modules/ subdirectory, but then you must first rebuild Makefile there by running `make Makefile'. (This is necessary each time you change the Setup file.)
If your module requires additional libraries to link with, these can be listed on the line in the configuration file as well, for instance:
分享到:
相关推荐
It is a companion to Extending and Embedding the Python Interpreter (in Extending and Embedding Python), which describes the general principles of extension writing but does not document the API ...
Welcome! This is the ...Extending and embedding the python interpreter Python /C API reference Manual Installing python modules Documenting Python Python HOWTOs Python Frequently Asked questions
Finally, the manual entitled Extending and Embedding the Python Interpreter describes how to add new extensions to Python and how to embed it in other applications. 本手册的读者要对Python 有基本的...
The book focuses on Python’s cross-platform capabilities and covers the basics of extending Python and embedding it in other applications. How This Book Is Organized This book has five parts, as ...
Finally, the manual entitled Extending and Embedding the Python Interpreter describes how to add new extensions to Python and how to embed it in other applications. 本手册的读者要对Python 有基本的认识...
而关于使用C或C++扩展Python功能,建议阅读《Extending and Embedding the Python Interpreter》和《Python/C API Reference》。 Python不仅适合处理大型项目,提供比shell脚本更强的结构和错误检查,而且它的高阶...
对于使用C或C++扩展Python功能,"Extending and Embedding the Python Interpreter"和"Python/C API Reference"是重要的参考资料。 教程中的“开胃菜”部分指出,Python特别适合那些需要在shell脚本的基础上增加...
3. **Extending and Embedding the Python Interpreter**:这部分内容主要针对想要在Python之外的环境中使用Python或扩展Python功能的开发者。它讲解了如何用C或C++编写Python扩展模块,以及如何在其他应用程序中...
如果你计划用C或C++来扩展Python,需要阅读《Extending and Embedding the Python Interpreter》以及《Python/C API Reference》。此外,市面上还有许多专门涵盖Python编程的书籍,这些资源能够进一步提升你的技能和...
对于希望使用C或C++扩展Python解释器的开发者,《Extending and Embedding the Python Interpreter》与《Python/C API Reference》是必读之选。这两份文档详细介绍了如何利用C语言增强Python的功能,以及如何将...
PEP 486: Make the Python Launcher aware of virtual environments PEP 488: Elimination of PYO files PEP 489: Multi-phase extension module initialization Other Language Changes New Modules typing ...
The embedded Python interpreter Recording Mayavi actions to a script Command line arguments mlab: Python scripting for 3D plotting A demo 3D Plotting functions for numpy arrays 0D and 1D data 2D ...