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
148 changes: 148 additions & 0 deletions relenv/_resources/xz/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/* config.h for compiling liblzma (*not* the whole XZ Utils) with MSVC 2019 */

/* Prefix for symbols exported by tuklib_*.c files */
#define TUKLIB_SYMBOL_PREFIX lzma_

/* How many MiB of RAM to assume if the real amount cannot be determined. */
#define ASSUME_RAM 128

/* Define to 1 if crc32 integrity check is enabled. */
#define HAVE_CHECK_CRC32 1

/* Define to 1 if crc64 integrity check is enabled. */
#define HAVE_CHECK_CRC64 1

/* Define to 1 if sha256 integrity check is enabled. */
#define HAVE_CHECK_SHA256 1

/* Define to 1 if any of HAVE_DECODER_foo have been defined. */
#define HAVE_DECODERS 1

/* Define to 1 if arm decoder is enabled. */
#define HAVE_DECODER_ARM 1

/* Define to 1 if armthumb decoder is enabled. */
#define HAVE_DECODER_ARMTHUMB 1

/* Define to 1 if delta decoder is enabled. */
#define HAVE_DECODER_DELTA 1

/* Define to 1 if ia64 decoder is enabled. */
#define HAVE_DECODER_IA64 1

/* Define to 1 if lzma1 decoder is enabled. */
#define HAVE_DECODER_LZMA1 1

/* Define to 1 if lzma2 decoder is enabled. */
#define HAVE_DECODER_LZMA2 1

/* Define to 1 if powerpc decoder is enabled. */
#define HAVE_DECODER_POWERPC 1

/* Define to 1 if sparc decoder is enabled. */
#define HAVE_DECODER_SPARC 1

/* Define to 1 if x86 decoder is enabled. */
#define HAVE_DECODER_X86 1

/* Define to 1 if any of HAVE_ENCODER_foo have been defined. */
#define HAVE_ENCODERS 1

/* Define to 1 if arm encoder is enabled. */
#define HAVE_ENCODER_ARM 1

/* Define to 1 if armthumb encoder is enabled. */
#define HAVE_ENCODER_ARMTHUMB 1

/* Define to 1 if delta encoder is enabled. */
#define HAVE_ENCODER_DELTA 1

/* Define to 1 if ia64 encoder is enabled. */
#define HAVE_ENCODER_IA64 1

/* Define to 1 if lzma1 encoder is enabled. */
#define HAVE_ENCODER_LZMA1 1

/* Define to 1 if lzma2 encoder is enabled. */
#define HAVE_ENCODER_LZMA2 1

/* Define to 1 if powerpc encoder is enabled. */
#define HAVE_ENCODER_POWERPC 1

/* Define to 1 if sparc encoder is enabled. */
#define HAVE_ENCODER_SPARC 1

/* Define to 1 if x86 encoder is enabled. */
#define HAVE_ENCODER_X86 1

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1

/* Define to 1 to enable bt2 match finder. */
#define HAVE_MF_BT2 1

/* Define to 1 to enable bt3 match finder. */
#define HAVE_MF_BT3 1

/* Define to 1 to enable bt4 match finder. */
#define HAVE_MF_BT4 1

/* Define to 1 to enable hc3 match finder. */
#define HAVE_MF_HC3 1

/* Define to 1 to enable hc4 match finder. */
#define HAVE_MF_HC4 1

/* Define to 1 if stdbool.h conforms to C99. */
#define HAVE_STDBOOL_H 1

/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1

/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1

/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1

/* Define to 1 or 0, depending whether the compiler supports simple visibility
declarations. */
#define HAVE_VISIBILITY 0

/* Define to 1 if the system has the type `_Bool'. */
#define HAVE__BOOL 1

#ifdef _M_IX86
/* Define to 1 when using Windows 95 (and thus XP) compatible threads. This
avoids use of features that were added in Windows Vista.
This is used for 32-bit x86 builds for compatibility reasons since it
makes no measurable difference in performance compared to Vista threads. */
#define MYTHREAD_WIN95 1
#else
/* Define to 1 when using Windows Vista compatible threads. This uses features
that are not available on Windows XP. */
#define MYTHREAD_VISTA 1
#endif

/* Define to 1 to disable debugging code. */
#define NDEBUG 1

/* Define to the full name of this package. */
#define PACKAGE_NAME "XZ Utils"

/* Define to the home page for this package. */
#define PACKAGE_URL "https://tukaani.org/xz/"

/* The size of `size_t', as computed by sizeof. */
#ifdef _WIN64
#define SIZEOF_SIZE_T 8
#else
#define SIZEOF_SIZE_T 4
#endif

/* Define to 1 if the system supports fast unaligned access to 16-bit and
32-bit integers. */
#define TUKLIB_FAST_UNALIGNED_ACCESS 1
4 changes: 4 additions & 0 deletions relenv/_resources/xz/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The config.h file was removed from XZ-Utils tarting with version 5.5.0.
XZ-Utils seems to build just fine with the config.h file from 5.4.7, so we're
including it here. This will be copied into the src/windows directory in the
extracted source for XZ-Utils.
98 changes: 98 additions & 0 deletions relenv/build/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
runcmd,
work_dirs,
fetch_url,
Version,
)
import relenv.relocate

Expand Down Expand Up @@ -358,6 +359,99 @@ def build_sqlite(env, dirs, logfp):
runcmd(["make", "install"], env=env, stderr=logfp, stdout=logfp)


def update_ensurepip(directory):
"""
Update bundled dependencies for ensurepip (pip & setuptools).
"""
# ensurepip bundle location
bundle_dir = directory / "ensurepip" / "_bundled"

# Make sure the destination directory exists
bundle_dir.mkdir(parents=True, exist_ok=True)

# Detect existing whl. Later versions of python don't include setuptools. We
# only want to update whl files that python expects to be there
pip_version = "25.2"
setuptools_version = "80.9.0"
update_pip = False
update_setuptools = False
for file in bundle_dir.glob("*.whl"):

log.debug("Checking whl: %s", str(file))
if file.name.startswith("pip-"):
found_version = file.name.split("-")[1]
log.debug("Found version %s", found_version)
if Version(found_version) >= Version(pip_version):
log.debug("Found correct pip version or newer: %s", found_version)
else:
file.unlink()
update_pip = True
if file.name.startswith("setuptools-"):
found_version = file.name.split("-")[1]
log.debug("Found version %s", found_version)
if Version(found_version) >= Version(setuptools_version):
log.debug(
"Found correct setuptools version or newer: %s", found_version
)
else:
file.unlink()
update_setuptools = True

# Download whl files and update __init__.py
init_file = directory / "ensurepip" / "__init__.py"
if update_pip:
whl = f"pip-{pip_version}-py3-none-any.whl"
whl_path = "b7/3f/945ef7ab14dc4f9d7f40288d2df998d1837ee0888ec3659c813487572faa"
url = f"https://files.pythonhosted.org/packages/{whl_path}/{whl}"
download_url(url=url, dest=bundle_dir)
assert (bundle_dir / whl).exists()

# Update __init__.py
old = "^_PIP_VERSION.*"
new = f'_PIP_VERSION = "{pip_version}"'
patch_file(path=init_file, old=old, new=new)

# setuptools
if update_setuptools:
whl = f"setuptools-{setuptools_version}-py3-none-any.whl"
whl_path = "a3/dc/17031897dae0efacfea57dfd3a82fdd2a2aeb58e0ff71b77b87e44edc772"
url = f"https://files.pythonhosted.org/packages/{whl_path}/{whl}"
download_url(url=url, dest=bundle_dir)
assert (bundle_dir / whl).exists()

# setuptools
old = "^_SETUPTOOLS_VERSION.*"
new = f'_SETUPTOOLS_VERSION = "{setuptools_version}"'
patch_file(path=init_file, old=old, new=new)

log.debug("ensurepip __init__.py contents:")
log.debug(init_file.read_text())


def patch_file(path, old, new):
"""
Search a file line by line for a string to replace.

:param path: Location of the file to search
:type path: str
:param old: The value that will be replaced
:type path: str
:param new: The value that will replace the 'old' value.
:type path: str
"""
log.debug("Patching file: %s", path)
import re

with open(path, "r") as fp:
content = fp.read()
new_content = ""
for line in content.splitlines():
line = re.sub(old, new, line)
new_content += line + "\n"
with open(path, "w") as fp:
fp.write(new_content)


def tarball_version(href):
if href.endswith("tar.gz"):
try:
Expand Down Expand Up @@ -1457,6 +1551,9 @@ def find_pythonlib(libdir):

pymodules = libdir / find_pythonlib(libdir)

# update ensurepip
update_ensurepip(pymodules)

cwd = os.getcwd()
modname = find_sysconfigdata(pymodules)
path = sys.path
Expand All @@ -1474,6 +1571,7 @@ def find_pythonlib(libdir):
bindir = pathlib.Path(dirs.prefix) / "bin"
sitepackages = pymodules / "site-packages"
install_runtime(sitepackages)

# Install pip
python = dirs.prefix / "bin" / "python3"
if env["RELENV_HOST_ARCH"] != env["RELENV_BUILD_ARCH"]:
Expand Down
8 changes: 4 additions & 4 deletions relenv/build/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,11 @@ def build_python(env, dirs, logfp):
)

if pathlib.Path("setup.py").exists():
with tempfile.NamedTemporaryFile(mode="w", suffix="_patch") as patch_file:
patch_file.write(PATCH)
patch_file.flush()
with tempfile.NamedTemporaryFile(mode="w", suffix="_patch") as p_file:
p_file.write(PATCH)
p_file.flush()
runcmd(
["patch", "-p0", "-i", patch_file.name],
["patch", "-p0", "-i", p_file.name],
env=env,
stderr=logfp,
stdout=logfp,
Expand Down
Loading
Loading