Skip to content

Commit d80ac64

Browse files
committed
windows: support building shared library distributions
Up until this point we produced a special Python distribution that was statically linked. This can be useful in some scenarios. But it can be very limiting because Python extensions need to be built specifically against this distribution. This rules out reusing existing binary extensions published on PyPI and externalizes a lot of hardship on downstream consumers. This commit teaches our build system to produce a more traditional Python distribution. We have a pythonXY.dll for the core library and .pyd files for extensions. There are also .dlls for various dependencies instead of static libraries. Closes #22.
1 parent d278f55 commit d80ac64

File tree

3 files changed

+304
-110
lines changed

3 files changed

+304
-110
lines changed

README.rst

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ without having to resort to heuristics.
277277
The file contains a JSON map. This map has the following keys:
278278

279279
version
280-
Version number of the file format. Currently ``3``.
280+
Version number of the file format. Currently ``4``.
281281

282282
os
283283
Target operating system for the distribution. e.g. ``linux``, ``macos``,
@@ -304,6 +304,18 @@ python_stdlib
304304
Relative path to Python's standard library (where ``.py`` and resource
305305
files are located).
306306

307+
link_mode
308+
How `libpython` is linked. Values can be one of the following:
309+
310+
`static`
311+
Statically linked.
312+
313+
`shared`
314+
Dynamically linked. (A `libpythonXY` shared library will be part
315+
of the distribution.)
316+
317+
(Version 4 or above only.)
318+
307319
build_info
308320
A map describing build configuration and artifacts for this distribution.
309321

@@ -340,7 +352,7 @@ custom set of built-in extension modules.
340352
This map has the following keys:
341353

342354
core
343-
A map describing the core Python distribution (essentially libpython).
355+
A map describing the core Python distribution (essentially `libpython`).
344356

345357
objs
346358
An array of paths to object files constituting the Python core distribution.
@@ -351,6 +363,14 @@ core
351363
links
352364
An array of linking requirement maps. (See below for data format.)
353365

366+
shared_lib
367+
Path to a shared library representing `libpython`. May not be defined.
368+
(Version 4 or above only.)
369+
370+
static_lib
371+
Path to a static library representing `libpython`. May not be defined.
372+
(Version 4 or above only.)
373+
354374
extensions
355375
A map of extension names to an array of maps describing candidate extensions.
356376

@@ -425,6 +445,10 @@ extensions
425445
Boolean indicating if this extension is required to initialize the Python
426446
interpreter.
427447

448+
shared_lib
449+
The path to a shared library defining this extension module. May not
450+
be defined. (Version 4 or above only.)
451+
428452
static_lib
429453
The path to a static library defining this extension module. May not
430454
be defined.

cpython-unix/build.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ def build_cpython(
649649
"python_exe": "install/bin/%s" % fully_qualified_name,
650650
"python_include": "install/include/%s" % fully_qualified_name,
651651
"python_stdlib": "install/lib/python%s" % entry["version"][0:3],
652+
"link_mode": "static",
652653
"build_info": python_build_info(
653654
build_env,
654655
platform,

0 commit comments

Comments
 (0)