Browse Source

Merge pull request #5303 from commodo/python-source-date-epoch

python,python3: add support for SOURCE_DATE_EPOCH var
lilik-openwrt-22.03
Hannu Nyman 7 years ago
committed by GitHub
parent
commit
750f19ab26
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 2 deletions
  1. +1
    -1
      lang/python/python/Makefile
  2. +10
    -0
      lang/python/python/patches/012-add-support-source-date-epoch-pyc.patch
  3. +1
    -1
      lang/python/python3/Makefile
  4. +13
    -0
      lang/python/python3/patches/012-add-support-source-date-epoch-pyc.patch

+ 1
- 1
lang/python/python/Makefile View File

@ -14,7 +14,7 @@ PKG_NAME:=python
PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO) PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
# XXX: reset PKG_RELEASE to 1 only if Python's pip & setuptools versions have also bumped; # XXX: reset PKG_RELEASE to 1 only if Python's pip & setuptools versions have also bumped;
# otherwise, keep bumping PKG_RELEASE # otherwise, keep bumping PKG_RELEASE
PKG_RELEASE:=5
PKG_RELEASE:=6
PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://www.python.org/ftp/python/$(PKG_VERSION) PKG_SOURCE_URL:=https://www.python.org/ftp/python/$(PKG_VERSION)


+ 10
- 0
lang/python/python/patches/012-add-support-source-date-epoch-pyc.patch View File

@ -0,0 +1,10 @@
--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -108,6 +108,7 @@ def compile(file, cfile=None, dfile=None, doraise=False):
timestamp = long(os.fstat(f.fileno()).st_mtime)
except AttributeError:
timestamp = long(os.stat(file).st_mtime)
+ timestamp = long(os.getenv('SOURCE_DATE_EPOCH', timestamp))
codestring = f.read()
try:
codeobject = __builtin__.compile(codestring, dfile or file,'exec')

+ 1
- 1
lang/python/python3/Makefile View File

@ -16,7 +16,7 @@ PYTHON_VERSION_MICRO:=$(PYTHON3_VERSION_MICRO)
PKG_NAME:=python3 PKG_NAME:=python3
# XXX: reset PKG_RELEASE to 1 only if Python's pip & setuptools versions have also bumped; # XXX: reset PKG_RELEASE to 1 only if Python's pip & setuptools versions have also bumped;
# otherwise, keep bumping PKG_RELEASE # otherwise, keep bumping PKG_RELEASE
PKG_RELEASE:=11
PKG_RELEASE:=12
PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO) PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz


+ 13
- 0
lang/python/python3/patches/012-add-support-source-date-epoch-pyc.patch View File

@ -0,0 +1,13 @@
--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -137,8 +137,9 @@ def compile(file, cfile=None, dfile=None
except FileExistsError:
pass
source_stats = loader.path_stats(file)
+ mtime = int(os.getenv('SOURCE_DATE_EPOCH', source_stats['mtime']))
bytecode = importlib._bootstrap_external._code_to_bytecode(
- code, source_stats['mtime'], source_stats['size'])
+ code, mtime, source_stats['size'])
mode = importlib._bootstrap_external._calc_mode(file)
importlib._bootstrap_external._write_atomic(cfile, bytecode, mode)
return cfile

Loading…
Cancel
Save