Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v2.3.1

### Fixed

- linux: `_zstd` could fail to import (`undefined symbol: ZSTD_defaultCLevel`) when the build host has an older libzstd: zstd is now built static-only, as mpdecimal is, so that `_zstd` doesn't link against (and load at runtime) the host's `libzstd.so.1`
- linux: zstd and mpdecimal were reported as broken without their debian dev package (`libzstd-dev`, `libmpdec-dev`), even though they compile from source without it (they were auto-selected for 3.14+, then failed the build report)

## v2.3.0

### Added
Expand Down
1 change: 0 additions & 1 deletion docs/configuration/portable-python-yml.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Replace `{module}` with the lowercased module name (e.g. `openssl`):
| `{module}-configure` | **Replace** the default configure args (space-separated, shell-style quoting; `$lib_dir` and `$lib64_dir` substituted). |
| `{module}-http-headers` | Headers for the download (env vars expanded). |
| `{module}-patches` | Source patches to apply before compiling. |
| `{module}-debian` | Debian package name for dependency detection. |

The `cpython-clean*` globs can also be given per platform, with a `-{platform}` suffix (eg: `cpython-clean-1st-pass-linux`), applied in addition to the generic ones.

Expand Down
2 changes: 2 additions & 0 deletions docs/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 2026-12-03

* **Update**: [Configuration](/configuration/portable-python-yml.md): removed the `{module}-debian` key, which doesn't exist (the debian package of a module is declared in code, via `m_debian`).
* **Update**: [External modules](/modules/external-modules.md): `Zstd` and `Mpdec` have no Linux dev package constraint (they compile from source without it).
* **Update**: [Module checks](/concepts/module-checks.md) and [configuration](/configuration/portable-python-yml.md): the build-info manifest records compiled sub-modules and `required-modules`, used by `inspect`.
* **Update**: [Module checks](/concepts/module-checks.md) and [inspect](/cli/inspect.md): smoke test markers in the `inspect` report, strict checks for pythons built by portable-python (via their manifest), `-m` replaces the default module list.
* **Creation**: Added [module checks](/concepts/module-checks.md): python modules of a fresh build are smoke tested, strictly for what the build provides (`m_provides`, `cpython-required-modules`), with a warning for the rest.
Expand Down
6 changes: 3 additions & 3 deletions docs/modules/external-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Default versions are intentionally **not** listed here, to avoid drifting from t
|--------|-----------------|--------------------------|----------------|
| `LibFFI` | `ctypes` | `ffi.h`, `ffi/ffi.h` | `!libffi-dev` |
| `Zlib` | `zlib` | `zlib.h` | `!zlib1g-dev` |
| `Zstd` | compression (zstd) | `zstd.h` | `!libzstd-dev` |
| `Zstd` | compression (zstd) | `zstd.h` | — |
| `Xz` | `lzma` | `lzma.h` | — |
| `Bzip2` | `bz2` | `bzlib.h` | — |
| `Readline` | `readline` | `readline/readline.h` | `-libreadline-dev` |
Expand All @@ -28,15 +28,15 @@ Default versions are intentionally **not** listed here, to avoid drifting from t
| `Gdbm` | `dbm.gnu` | `gdbm.h` | `libgdbm-dev` |
| `Uuid` | `uuid` | `uuid/uuid.h` | `+uuid-dev` |
| `TkInter` | `tkinter` | `tk`, `tk.h` | `-tk-dev` |
| `Mpdec` | `decimal` | `mpdecimal.h` | `!libmpdec-dev` |
| `Mpdec` | `decimal` | `mpdecimal.h` | — |

## Linux dev-package sigils

The leading character on the Debian package encodes a build constraint (see [telltale detection](/concepts/telltale-detection.md)):

| Sigil | Meaning |
|-------|---------|
| `!` | Required to compile **at all** (`LibFFI`, `Zlib`, `Zstd`, `Mpdec`). |
| `!` | Required to compile **at all** (`LibFFI`, `Zlib`). |
| `+` | Required when the module is **selected** for static compile (`Sqlite`, `Uuid`). |
| `-` | Dev package's presence **breaks** static compilation (`Readline`, `TkInter`). |
| (none) | Detection/reporting only. |
Expand Down
16 changes: 7 additions & 9 deletions src/portable_python/external/xcpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,7 @@ class Zstd(ModuleBuilder):
Newer compression format present in most 3.14+ builds
"""

m_debian = "!libzstd-dev"
m_telltale = "{include}/zstd.h"
m_telltale = "{include}/zstd.h" # No m_debian: libzstd-dev is not needed to compile zstd, and doesn't get in the way
m_provides = "_zstd"

xenv_CFLAGS = "-fPIC"
Expand All @@ -497,12 +496,12 @@ def version(self):
return self.cfg_version("1.6.0")

def _do_linux_compile(self):
# Static library only: with a shared one in deps/lib, `-lzstd` would link it, and `_zstd` would then load whatever
# libzstd.so.1 the host has at runtime (possibly older, eg: 1.4.8 lacks ZSTD_defaultCLevel, and `_zstd` fails to import)
# Notably, this does not build when given a relative path.
self.run_make(f"prefix={os.path.abspath(self.deps)}")
# the libdir on the resulting .dylib on Mac is wrong, but as long as we
# staticly compile this doesn't need a fixup. I got as far as:
# "libdir=\\$(executable_path)/../lib")
self.run_make("install", f"prefix={os.path.abspath(self.deps)}")
prefix = f"prefix={os.path.abspath(self.deps)}"
self.run_make("-C", "lib", "libzstd.a-release", prefix)
self.run_make("-C", "lib", "install-static", "install-includes", "install-pc", prefix)


class Mpdec(ModuleBuilder):
Expand All @@ -511,8 +510,7 @@ class Mpdec(ModuleBuilder):
3.14 still falls back, but to a deprecated (and older) bundled copy, so we build it there too
"""

m_debian = "!libmpdec-dev"
m_telltale = "{include}/mpdecimal.h"
m_telltale = "{include}/mpdecimal.h" # No m_debian: libmpdec-dev is not needed to compile mpdecimal, and doesn't get in the way
m_provides = "_decimal"

xenv_CFLAGS = "-fPIC"
Expand Down
14 changes: 14 additions & 0 deletions tests/test_module_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,17 @@ def test_version_mismatch_marker():
info = module_info("_zstd", version="1.6.1", version_field="zstd_version", smoke="passed")
ModuleExpectation.annotate(expectations, {"_zstd": info})
assert list(info.report_rows()) == [("_zstd", "✅ 1.6.1")]


def test_linux_static_only_modules(temp_folder):
# zstd and mpdec compile from source without their debian dev package (and its presence doesn't get in the way)
PPG.grab_config(target="linux-x86_64")
builder = python_builder()
for name in ("zstd", "mpdec"):
module = builder.modules.module_by_name[name]
module.resolved_telltale = None # No dev package installed
assert module.linker_outcome(is_selected=True) == (LinkerOutcome.static, None)
assert module.linker_outcome(is_selected=False) == (LinkerOutcome.absent, None)
module.resolved_telltale = "/usr/include/foo.h" # Dev package installed
assert module.linker_outcome(is_selected=True) == (LinkerOutcome.static, None)
assert module.linker_outcome(is_selected=False) == (LinkerOutcome.shared, None)
5 changes: 3 additions & 2 deletions tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ def test_scan(cli):

with patch.object(PPG, "find_telltale", return_value=None): # Simulate a host without any system headers
cli.run("-tlinux-x86_64", "build-report", "3.14.0")
assert "zstd 1.6.0 static* broken, can't compile without libzstd-dev" in cli.logged # Auto-selected ('*')
assert "mpdec 4.0.1 static* broken, can't compile without libmpdec-dev" in cli.logged
# Auto-selected ('*'), and compiled from source (no need for their debian dev package)
assert "zstd 1.6.0 static* [auto-selected] Required for 3.14 and up" in cli.logged
assert "mpdec 4.0.1 static* [auto-selected] Required for 3.14 and up" in cli.logged

cli.run("-tmacos-arm64", "build-report", "3.14.0")
assert "mpdec 4.0.1 static* [auto-selected] Required for 3.14 and up" in cli.logged