8000 Merge remote-tracking branch 'origin/main' into jwiltse/add_lib64_dir · solvingj/portable-python@fc50025 · GitHub
[go: up one dir, main page]

Skip to content

Commit fc50025

Browse files
author
jwiltse
committed
Merge remote-tracking branch 'origin/main' into jwiltse/add_lib64_dir
2 parents abadbf2 + 28bcf94 commit fc50025

File tree

9 files changed

+216
-117
lines changed

9 files changed

+216
-117
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
17-
18-
steps:
19-
- uses: actions/checkout@v4
20-
- uses: actions/setup-python@v5
21-
with:
22-
python-version: ${{ matrix.python-version }}
23-
24-
- run: pip install -U pip tox
25-
- run: tox -e py
26-
- uses: codecov/codecov-action@v3
27-
with:
28-
files: .tox/test-reports/coverage.xml
29-
30-
test-eol:
31-
# EOL-ed versions of python are exercised on older linux distros for a while longer
32-
# Testing against these versions will eventually be retired
33-
runs-on: ubuntu-20.04
34-
35-
strategy:
36-
matrix:
37-
python-version: ["3.6", "3.7"]
16+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
3817

3918
steps:
4019
- uses: actions/checkout@v4

portable-python.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,38 @@ folders:
1919
cpython-additional-packages:
2020
# - Pillow==10.0.0
2121
# - flake8==6.0.0
22+
23+
# Uncomment to download, compile and statically link Python module dependencies
24+
# cpython-modules: libffi zlib xz bzip2 openssl uuid sqlite
25+
26+
# Uncomment to override a dependency version
27+
# libffi-version: 3.3
28+
29+
# Uncomment to override cpython or a dependency source URL
30+
# Note: string "$version" will be replaced with version string (e.g. 1.2.3)
31+
# cpython-url: https://my-cpython-mirror/cpython-$version.tar.gz
32+
# zlib-url: https://my-zlib-mirror/zlib-$version.tar.gz
33+
34+
# Uncomment to override the ./configure arguments for a dependency
35+
# Note: this will replace the default arguments, not extend them
36+
# Note: the string "$deps_lib" will be replaced with the output libs directory for the module
37+
# openssl-configure: -v --openssldir=/etc/ssl no-shared no-idea no-tests no-dso
38+
39+
# Note: It's also possible to set configure args per platform/arch
40+
# linux:
41+
# openssl-configure: --with-terminfo-dirs=/etc/terminfo:/lib/terminfo:/usr/share/terminfo
42+
# macos:
43+
# openssl-configure: --with-terminfo-dirs=/usr/share/terminfo
44+
45+
# Note: you can also use one argument per line syntax
46+
# openssl-configure:
47+
# - -v
48+
# - --openssldir=/etc/ssl
49+
50+
51+
# Uncomment if you need to patch the source code of a module before compiling it
52+
#cpython-modules: zlib
53+
#zlib-patches:
54+
# - file: configure
55+
# regex: "# start off configure.log"
56+
# replacement: "echo starting zlib configure script with patches"

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
author="Zoran Simic zoran@simicweb.com",
88
keywords="python, portable, binary",
99
url="https://github.com/codrsquad/portable-python",
10-
python_requires=">=3.6",
10+
python_requires=">=3.8",
1111
entry_points={
1212
"console_scripts": [
1313
"portable-python = portable_python.__main__:main",
@@ -22,13 +22,12 @@
2222
"Operating System :: Unix",
2323
"Programming Language :: Python",
2424
"Programming Language :: Python :: 3",
25-
"Programming Language :: Python :: 3.6",
26-
"Programming Language :: Python :: 3.7",
2725
"Programming Language :: Python :: 3.8",
2826
"Programming Language :: Python :: 3.9",
2927
"Programming Language :: Python :: 3.10",
3028
"Programming Language :: Python :: 3.11",
3129
"Programming Language :: Python :: 3.12",
30+
"Programming Language :: Python :: 3.13",
3231
"Programming Language :: Python :: Implementation :: CPython",
3332
"Topic :: Software Development :: Build Tools",
3433
"Topic :: System :: Installation/Setup",

src/portable_python/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import os
1616
import pathlib
1717
import re
18+
from string import Template
1819
from typing import ClassVar, List
1920

2021
import runez
@@ -491,6 +492,19 @@ def is_usable_module(self, name):
491492
def cfg_version(self, default):
492493
return PPG.config.get_value("%s-version" % self.m_name) or default
493494

495+
def cfg_url(self, version):
496+
if config_url := PPG.config.get_value("%s-url" % self.m_name):
497+
url_template = Template(config_url)
498+
return url_template.substitute(version=version)
499+
500+
def cfg_configure(self, deps_lib):
501+
if configure := PPG.config.get_value("%s-configure" % self.m_name):
502+
configure_template = Template(configure)
503+
return configure_template.substitute(deps_lib=deps_lib)
504+
505+
def cfg_patches(self):
506+
return PPG.config.get_value("%s-patches" % self.m_name)
507+
494508
@property
495509
def url(self):
496510
"""Url of source tarball, if any"""
@@ -650,6 +664,7 @@ def compile(self):
650664
folder = folder / self.m_build_cwd
651665

652666
with runez.CurrentFolder(folder):
667+
self._apply_patches()
653668
self._prepare()
654669
func()
655670
self._finalize()
@@ -663,6 +678,15 @@ def compile(self):
663678
else:
664679
os.environ[k] = v
665680

681+
def _apply_patches(self):
682+
if patches := self.cfg_patches():
683+
for patch in patches:
684+
if runez.DRYRUN:
685+
print(f"Would apply patch: {patch}")
686+
else:
687+
print(f"Applying patch: {patch}")
688+
patch_file(patch["file"], patch["regex"], patch["replacement"])
689+
666690
def _get_env_vars(self):
667691
"""Yield all found env vars, first found wins"""
668692
result = {}

src/portable_python/cpython.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from runez.pyenv import Version
99

1010
from portable_python import LOG, patch_file, patch_folder, PPG, PythonBuilder
11-
from portable_python.external.tkinter import TkInter
1211
from portable_python.external.xcpython import Bdb, Bzip2, Gdbm, LibFFI, Openssl, Readline, Sqlite, Uuid, Xz, Zlib
12+
from portable_python.external.xtkinter import TkInter
1313
from portable_python.inspector import LibAutoCorrect, PythonInspector
1414

1515
# https://github.com/docker-library/python/issues/160
@@ -104,6 +104,9 @@ def url(self):
104104
if PPG.config.get_value("cpython-use-github"):
105105
return f"https://github.com/python/cpython/archive/refs/tags/v{self.version}.tar.gz"
106106

107+
if cfg_url := self.cfg_url(self.version):
108+
return cfg_url
109+
107110
return f"https://www.python.org/ftp/python/{self.version.main}/Python-{self.version}.tar.xz"
108111

109112
def xenv_LDFLAGS_NODIST(self):
@@ -231,7 +234,7 @@ def _finalize(self):
231234

232235
self.run_python(cmd)
233236

234-
self.run_python("-mpip", "install", *runez.flattened(additional))
237+
self.run_python("-mpip", "install", "--no-cache-dir", "--upgrade", *runez.flattened(additional))
235238

236239
runez.abort_if(not runez.DRYRUN and not self.bin_python, f"Can't find bin/python in {self.bin_folder}")
237240
PPG.config.ensure_main_file_symlinks(self)

0 commit comments

Comments
 (0)
0