diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e254e8..a539505 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/docs/configuration/portable-python-yml.md b/docs/configuration/portable-python-yml.md index 5605ea7..f0bf31e 100644 --- a/docs/configuration/portable-python-yml.md +++ b/docs/configuration/portable-python-yml.md @@ -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. diff --git a/docs/log.md b/docs/log.md index 6555ef7..ed449f1 100644 --- a/docs/log.md +++ b/docs/log.md @@ -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. diff --git a/docs/modules/external-modules.md b/docs/modules/external-modules.md index 2b14b2c..03fc3a0 100644 --- a/docs/modules/external-modules.md +++ b/docs/modules/external-modules.md @@ -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` | @@ -28,7 +28,7 @@ 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 @@ -36,7 +36,7 @@ The leading character on the Debian package encodes a build constraint (see [tel | 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. | diff --git a/src/portable_python/external/xcpython.py b/src/portable_python/external/xcpython.py index 93bfa20..2dfc4c5 100644 --- a/src/portable_python/external/xcpython.py +++ b/src/portable_python/external/xcpython.py @@ -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" @@ -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): @@ -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" diff --git a/tests/test_module_checks.py b/tests/test_module_checks.py index cb79d13..a30e449 100644 --- a/tests/test_module_checks.py +++ b/tests/test_module_checks.py @@ -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) diff --git a/tests/test_report.py b/tests/test_report.py index dbc3f03..6f3ee73 100644 --- a/tests/test_report.py +++ b/tests/test_report.py @@ -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