Extending and Embedding Python, Release 3.9.5 Chapter 2. Creating extensions without third party tools 56 python setup.py bdist_wininst python setup.py bdist_rpm python setup.py bdist_dumb In this example, setup() is called with additional meta-information, which is recommended when distribution packages have to be built. For the extension itself, it specifies preprocessor defines, include directories, library direc- tories, and libraries. Depending on the compiler, distutils passes this information in different ways to the compiler. For example, on Unix, this may result in the compilation commands gcc -DNDEBUG -g -O3-Wall-Wstrict-prototypes -fPIC -DMAJOR_VERSION =1-DMINOR_ ↪ → VERSION =0-I/usr/local/include-I/usr/local/include/python2.2-c demo.c-o build/ ↪ → temp.linux -i686 -2.2 /demo.o gcc -shared build/temp.linux -i686 -2.2 /demo.o-L /usr/local/lib -ltcl83 -o build/lib. ↪ → linux-i686 -2.2 /demo.so 2.4.2 Distributing your extension modules When an extension has been successfully built, there are three ways to use it. End-users will typically want to install the module, they do so by running python setup.py install Module maintainers should produce source packages; to do so, they run python setup.py sdist In some cases, additional files need to be included in a source distribution; this is done through a$_{MANIFEST.in}$ file; see manifest for details. If the source distribution has been built successfully, maintainers can also create binary distributions. Depending on the platform, one of the following commands can be used to do so. These lines are for demonstration purposes only; distutils users should trust that distutils gets the invocations right. (continued from previous page) define_macros=[('MAJOR_VERSION ','1'), ('MINOR_VERSION ','0')], include_dirs=['/usr/local/include '], libraries =['tcl83 '], library_dirs =['/usr/local/lib '], sources =['demo.c']) setup (name='PackageName', version ='1.0 ', description ='This is a demo package', author ='Martin v. Loewis', author_email='martin@v.loewis.de ', url ='https://docs.python.org/extending/building ', long_description=''' This is really just a demo package. ''' , ext_modules=[module1])