portable-python 2.1.0__py3-none-any.whl → 2.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,7 @@ from string import Template
21
21
 
22
22
  import runez
23
23
  from runez.http import RestClient
24
- from runez.pyenv import PythonSpec
24
+ from runez.pyenv import PythonSpec, Version
25
25
  from runez.render import Header, PrettyTable
26
26
 
27
27
  from portable_python.versions import PPG
@@ -506,8 +506,9 @@ class ModuleBuilder:
506
506
  """Is module with name either selected or usable as a shared lib, as determined via its telltale"""
507
507
  return self.modules.is_usable_module(name)
508
508
 
509
- def cfg_version(self, default):
510
- return PPG.config.get_value("%s-version" % self.m_name) or default
509
+ def cfg_version(self, default: str) -> Version:
510
+ # str(): a version in yaml config may have been parsed as a float (eg: `gdbm-version: 1.26`)
511
+ return Version(str(PPG.config.get_value("%s-version" % self.m_name) or default))
511
512
 
512
513
  def cfg_http_headers(self):
513
514
  if config_http_headers := PPG.config.get_value("%s-http-headers" % self.m_name):
@@ -554,9 +555,12 @@ class ModuleBuilder:
554
555
  return self.cfg_src_suffix()
555
556
 
556
557
  @property
557
- def version(self):
558
- """Version to use"""
559
- return self.parent_module and self.parent_module.version
558
+ def version(self) -> Version:
559
+ """Version to use, sub-modules (such as tcl/tk/tix) share the version of their parent module by default"""
560
+ if self.parent_module is None:
561
+ return self.setup.python_spec.version # Top of the module tree: the python being built
562
+
563
+ return self.parent_module.version
560
564
 
561
565
  @property
562
566
  def deps(self):
@@ -822,10 +826,6 @@ class PythonBuilder(ModuleBuilder):
822
826
 
823
827
  return self._bin_python
824
828
 
825
- @property
826
- def version(self):
827
- return self.setup.python_spec.version
828
-
829
829
  def xenv_LDFLAGS(self):
830
830
  """Python builder does not reuse the common setting"""
831
831
  yield from ()
@@ -2,10 +2,10 @@ import configparser
2
2
  import datetime
3
3
  import os
4
4
  import re
5
+ import shutil
5
6
 
6
7
  import runez
7
8
  import yaml
8
- from runez.pyenv import Version
9
9
 
10
10
  from portable_python import LOG, patch_file, patch_folder, PPG, PythonBuilder
11
11
  from portable_python.external.xcpython import Bdb, Bzip2, Gdbm, LibFFI, Mpdec, Openssl, Readline, Sqlite, Uuid, Xz, Zlib, Zstd
@@ -20,6 +20,11 @@ test_hashlib test_io test_iter test_json test_long test_math test_memoryview tes
20
20
  test_struct test_threading test_time test_traceback test_unicode
21
21
  """
22
22
 
23
+ # Compiler commands that ./configure records in the Makefile end up in sysconfig, and are used to build C/C++ extensions
24
+ RX_MAKEFILE_COMPILER = re.compile(r"^(CC|CXX|LDSHARED|LDCXXSHARED)=[ \t]*(.*?)[ \t]*$", flags=re.MULTILINE)
25
+ # Compiler wrappers that may exist on the build host only, recording them in sysconfig is worth a warning
26
+ RX_COMPILER_WRAPPER = re.compile(r"\b(ccache|sccache|distcc)\b")
27
+
23
28
 
24
29
  def represented_yaml(key_value_pairs):
25
30
  """
@@ -164,7 +169,7 @@ class Cpython(PythonBuilder):
164
169
  tkinter = self.active_module(TkInter)
165
170
  if tkinter:
166
171
  # TODO: this doesn't seem to be enough, on macos cpython's ./configure still picks up the shared macos tcl/tk libs
167
- version = Version(tkinter.version)
172
+ version = tkinter.version
168
173
  yield f"--with-tcltk-includes=-I{self.deps}/include"
169
174
 
170
175
  lib_dir_flags = " ".join(f"-L{lib_dir}" for lib_dir in self.deps_lib_dirs)
@@ -246,6 +251,7 @@ class Cpython(PythonBuilder):
246
251
 
247
252
  def _do_linux_compile(self):
248
253
  self.run_configure("./configure", self.c_configure_args(), prefix=self.c_configure_prefix)
254
+ self.groom_makefile_compilers()
249
255
  make_args = []
250
256
  if self.version < "3.8":
251
257
  pgo_tests = runez.joined(runez.flattened(PGO_TESTS, split=True))
@@ -255,6 +261,48 @@ class Cpython(PythonBuilder):
255
261
  # Don't parallelize `make install`, see https://github.com/python/cpython/issues/109796
256
262
  self.run_make("install", f"DESTDIR={self.destdir}")
257
263
 
264
+ def groom_makefile_compilers(self):
265
+ """
266
+ Keep the compiler commands that end up in sysconfig usable on hosts other than the build host.
267
+
268
+ ./configure looks up the C++ compiler on PATH (so that a missing one is noticed at configure time),
269
+ and records it by the absolute path where it found it, a path that is specific to the build host.
270
+ For example `/usr/lib/ccache/g++`, when a compiler cache masquerade folder is first on PATH.
271
+ A portable python builds extensions on other hosts: refer to the compiler by name (as for the C compiler),
272
+ to be found on that host's PATH. The build is unchanged: on the build host, that name resolves to the same path.
273
+ A `CXX` explicitly provided by the user is left alone.
274
+ """
275
+ makefile = "Makefile"
276
+ if not os.path.exists(makefile):
277
+ return # Not configured (dryrun mode)
278
+
279
+ with open(makefile) as fh:
280
+ compilers = dict(RX_MAKEFILE_COMPILER.findall(fh.read()))
281
+
282
+ cxx = compilers.get("CXX")
283
+ if cxx and not self._is_cxx_preset():
284
+ program, _, flags = cxx.partition(" ")
285
+ bare_name = os.path.basename(program)
286
+ if program != bare_name and shutil.which(bare_name) == program:
287
+ # Makefile.pre first: Makefile is generated from it, and must not end up older than it
288
+ for path in ("Makefile.pre", makefile):
289
+ patch_file(path, rf"^(CXX=[ \t]*){re.escape(program)}(?=[ \t]|$)", rf"\g<1>{bare_name}")
290
+
291
+ compilers["CXX"] = runez.joined(bare_name, flags)
292
+
293
+ for name, command in sorted(compilers.items()):
294
+ if RX_COMPILER_WRAPPER.search(command):
295
+ LOG.warning(
296
+ "sysconfig will record compiler wrapper '%s=%s', extensions won't build on hosts without it"
297
+ " (a wrapper masquerade folder on PATH applies to the build only)",
298
+ name,
299
+ command,
300
+ )
301
+
302
+ def _is_cxx_preset(self):
303
+ """Did the user explicitly provide which C++ compiler to use? (via env var, or `CXX=` in `cpython-configure`)"""
304
+ return bool(os.environ.get("CXX")) or any(x.startswith("CXX=") for x in self.c_configure_args_from_config)
305
+
258
306
  def _finalize(self):
259
307
  is_shared = self.setup.prefix or self.has_configure_opt("--enable-shared", "yes")
260
308
  if is_shared:
@@ -136,8 +136,9 @@ class LibFFI(ModuleBuilder):
136
136
  @property
137
137
  def version(self):
138
138
  # python-build-standalone moved from 3.4.8 straight to 3.8.0 in Oct 2026 (their PR #1302), follow their lead
139
+ # 3.8.x patch releases carry security fixes (3.8.2: GHSA advisories), keep current within the line
139
140
  # Check https://github.com/libffi/libffi/releases
140
- return self.cfg_version("3.8.0")
141
+ return self.cfg_version("3.8.2")
141
142
 
142
143
  def c_configure_args(self):
143
144
  if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
@@ -170,9 +171,9 @@ class Openssl(ModuleBuilder):
170
171
 
171
172
  @property
172
173
  def url(self):
173
- if self.version and self.version.startswith("1.1.1"):
174
+ if self.version.text.startswith("1.1.1"):
174
175
  # Not sure why URL suddenly changed for this on github...
175
- vfolder = self.version.replace(".", "_")
176
+ vfolder = self.version.text.replace(".", "_")
176
177
  return (
177
178
  self.cfg_url(self.version)
178
179
  or f"https://github.com/openssl/openssl/releases/download/OpenSSL_{vfolder}/openssl-{self.version}.tar.gz"
@@ -186,7 +187,7 @@ class Openssl(ModuleBuilder):
186
187
  # Stay on the 3.5 LTS line: 3.6.x and 4.0.x have shipped but are not verified for cpython builds
187
188
  # (python-build-standalone pins 3.5.x as well)
188
189
  # Check https://github.com/openssl/openssl/releases and https://endoflife.date/openssl
189
- return self.cfg_version("3.5.9")
190
+ return self.cfg_version("3.5.10")
190
191
 
191
192
  def c_configure_args(self):
192
193
  if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
@@ -320,9 +321,10 @@ class Sqlite(ModuleBuilder):
320
321
 
321
322
  @property
322
323
  def version(self):
323
- # 3.53.x gets frequent fix-only releases, keep current within the line
324
+ # Fix-only releases are frequent within a line, keep current; move to a new line once its .1 is out
325
+ # (3.54.1, also used by python-build-standalone)
324
326
  # Check https://sqlite.org/changes.html (avoid withdrawn releases like 3.52.0)
325
- return self.cfg_version("3.53.4")
327
+ return self.cfg_version("3.54.1")
326
328
 
327
329
  def c_configure_args(self):
328
330
  if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
@@ -389,8 +391,9 @@ class Xz(ModuleBuilder):
389
391
 
390
392
  @property
391
393
  def version(self):
394
+ # 5.8.x patch releases carry security fixes (5.8.5), keep current within the line
392
395
  # Check https://github.com/tukaani-project/xz/releases
393
- return self.cfg_version("5.8.4")
396
+ return self.cfg_version("5.8.5")
394
397
 
395
398
  def c_configure_args(self):
396
399
  if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
@@ -433,8 +436,10 @@ class Zlib(ModuleBuilder):
433
436
 
434
437
  @property
435
438
  def version(self):
439
+ # 1.4 fixes several CVEs, its breaking changes are CMake/MSVC/Cygwin only (we use ./configure)
440
+ # python-build-standalone moved to 1.4 as well
436
441
  # Check https://zlib.net/ and https://github.com/madler/zlib/releases
437
- return self.cfg_version("1.3.2")
442
+ return self.cfg_version("1.4")
438
443
 
439
444
  def c_configure_args(self):
440
445
  if config_args := self.cfg_configure(self.deps_lib_dir, self.deps_lib64_dir):
@@ -474,8 +479,10 @@ class Zstd(ModuleBuilder):
474
479
 
475
480
  @property
476
481
  def version(self):
482
+ # 1.6.0 was released early as a CVE fix (CVE-2026-124851), upstream "highly recommends" it
483
+ # python-build-standalone moved to 1.6.0 as well
477
484
  # Check https://github.com/facebook/zstd/releases
478
- return self.cfg_version("1.5.7")
485
+ return self.cfg_version("1.6.0")
479
486
 
480
487
  def _do_linux_compile(self):
481
488
  # Notably, this does not build when given a relative path.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: portable-python
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
4
  Summary: Portable python binaries
5
5
  Author-email: Zoran Simic <zoran@simicweb.com>
6
6
  License-Expression: MIT
@@ -1,18 +1,18 @@
1
- portable_python/__init__.py,sha256=exNghs63434mkR4a4_D3hv8doAl8iDXPAu-aFEHRrj0,32535
1
+ portable_python/__init__.py,sha256=6Uy2t99YRVQdhUGx9OUGx5hR-CZDGneCI7d9MfhOZFM,32805
2
2
  portable_python/__main__.py,sha256=fjtkudRFxLSLTSqzkWYnQLMGRG0BRUc6GeqY201taCE,149
3
3
  portable_python/cli.py,sha256=q68tsim0LL-VfVKEA_UgOXySWliwTh04548iozqzmzM,7735
4
4
  portable_python/config.py,sha256=MMFKSmZFWxG4poceUkuEtkjOumQ8lnc-79JsZ8pdBPI,13442
5
- portable_python/cpython.py,sha256=5Bm5hXFXzkTEDfjRi8AcgYpsyOxS55a5n3R1y3coy3A,19245
5
+ portable_python/cpython.py,sha256=jOTfLMqh5sGDiUZ5b1PJcavIyh_-EBAm3pO635LuuzM,21943
6
6
  portable_python/inspector.py,sha256=Jxtc2tfkyK5oAM3NOPHAlwoykE902KxJkf_uaOTXrjU,20879
7
7
  portable_python/tracking.py,sha256=7eHlM8zxAy7K25-hNMSZxvbJs_3qm7mrWwKokRoB53U,2186
8
8
  portable_python/versions.py,sha256=TpGjius0GFhgzu6O4PKCpe4pckoK6JNpxLCiBZo-xr8,7870
9
9
  portable_python/external/__init__.py,sha256=bjfcopayRyz_1Z_DLig-BmX6qlhqR7mnrnfwYyP3kzU,893
10
10
  portable_python/external/_inspect.py,sha256=ASminI7HBuHAuFcvX3mkBYf7lCDILqiPrKkhKkQ8w94,3744
11
- portable_python/external/xcpython.py,sha256=Z01ORLQ8fgeZ3XXf5XGtfvnfi5UJgcF2JBhRtTyD8hU,17180
11
+ portable_python/external/xcpython.py,sha256=M1wFLRIJZQABX4jnE9l9O3EmymxCm42e6WyOTQzwTOQ,17769
12
12
  portable_python/external/xtkinter.py,sha256=7GyXG4FVf7LKC_ojKe7j9N_YJUjYYT6eNpf5-zNtpZk,3692
13
- portable_python-2.1.0.dist-info/licenses/LICENSE,sha256=BB27gUWIcmc-bauY_M6COCMtiy4hN2mou1RdadlbXbs,1068
14
- portable_python-2.1.0.dist-info/METADATA,sha256=BKRHM2myDmJspKDeTtye7kZUUZilOii2g01xAdISfuQ,9894
15
- portable_python-2.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
16
- portable_python-2.1.0.dist-info/entry_points.txt,sha256=Zo8HR39evgAgm4e2UhenD7kkpJvEXp_VB4aIrL_3_VY,66
17
- portable_python-2.1.0.dist-info/top_level.txt,sha256=S203pfaAC8FDZvrHsCWWua_9ZfSDEDCD1w90zzYFhOU,16
18
- portable_python-2.1.0.dist-info/RECORD,,
13
+ portable_python-2.2.0.dist-info/licenses/LICENSE,sha256=BB27gUWIcmc-bauY_M6COCMtiy4hN2mou1RdadlbXbs,1068
14
+ portable_python-2.2.0.dist-info/METADATA,sha256=KYTRg4BFcQHfFPMD-Er6DYRy3Sb70hC9kdIqtGROVtA,9894
15
+ portable_python-2.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
16
+ portable_python-2.2.0.dist-info/entry_points.txt,sha256=Zo8HR39evgAgm4e2UhenD7kkpJvEXp_VB4aIrL_3_VY,66
17
+ portable_python-2.2.0.dist-info/top_level.txt,sha256=S203pfaAC8FDZvrHsCWWua_9ZfSDEDCD1w90zzYFhOU,16
18
+ portable_python-2.2.0.dist-info/RECORD,,