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
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## 0.2.0

Add support for injecting `--layout packed` PEXes.

## 0.1.0

Initial release.
Expand Down
98 changes: 52 additions & 46 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Copyright 2026 Pex project contributors.
# SPDX-License-Identifier: Apache-2.0

[package]
name = "pexrc"
version = "0.2.0"
edition = "2024"
publish = false

[workspace]
members = [
".",
Expand All @@ -10,20 +16,14 @@ members = [
"crates/interpreter",
"crates/package",
"crates/pex",
"crates/pexrc-build-system",
"crates/build-system",
"crates/pexrs",
"crates/platform",
"crates/resources",
"crates/scripts",
"crates/testing",
"crates/venv",
]

[package]
name = "pexrc"
version = "0.1.0"
edition = "2024"
publish = false

[package.metadata.build]
zig_version = "0.15.2"

Expand Down Expand Up @@ -140,16 +140,17 @@ textwrap = "0.16"
time = "0.3"
toml = "1.0"
url = "2.5"
walkdir = "2.5"
which = "8.0"
xz2 = "0.1"
zip = { version = "8.1", default-features = false, features = ["deflate", "zstd"] }
zstd = "0.13"

[build-dependencies]
anyhow = { workspace = true }
build-system = { path = "crates/build-system" }
bstr = { workspace = true }
fs-err = { workspace = true }
pexrc-build-system = { path = "crates/pexrc-build-system" }
env_logger = { workspace = true }
itertools = { workspace = true }
zstd = { workspace = true }
Expand All @@ -173,9 +174,10 @@ owo-colors = { workspace = true }
pex = { path = "crates/pex" }
pexrs = { path = "crates/pexrs" }
platform = { path = "crates/platform" }
resources = { path = "crates/resources", features = ["embedded"] }
scripts = { path = "crates/scripts", features = ["embedded"] }
sha2 = { workspace = true }
strum = { workspace = true }
tempfile = { workspace = true }
walkdir = { workspace = true }
zip = { workspace = true }
zstd = { workspace = true }
9 changes: 5 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@
use std::ffi::OsStr;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::{env, fs, io, iter};
use std::{env, io, iter};

use anyhow::{anyhow, bail};
use bstr::ByteSlice;
use fs_err::File;
use itertools::Itertools;
use pexrc_build_system::{
use build_system::{
ClassifiedTargets,
ClibConfiguration,
FoundTool,
Target,
classify_targets,
ensure_tools_installed,
};
use fs_err as fs;
use fs_err::File;
use itertools::Itertools;

fn main() -> anyhow::Result<()> {
println!("cargo::rerun-if-changed=crates");
Expand Down
42 changes: 29 additions & 13 deletions crates/boot/src/boot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2026 Pex project contributors.
# SPDX-License-Identifier: Apache-2.0
# -*- coding: utf-8 -*-

from __future__ import print_function

Expand Down Expand Up @@ -437,22 +437,38 @@ def boot(
def _load_pexrc():
# type: () -> Pexrc

dll = None # type: Optional[Pexrc]
prefix = ".clib" if __name__ == "__pex__" else os.path.join("__pex__", ".clib")
target_triple = CURRENT_OS.target_triple(arch=CURRENT_ARCH, abi=CURRENT_ABI)
library_file_name = CURRENT_OS.library_file_name(lib_name="pexrc")
library_file_relpath = os.path.join(
prefix,
"{target_triple}.{library_file_name}".format(
target_triple=target_triple, library_file_name=library_file_name
),
)
if __file__ and os.path.isfile(__file__):
# We're in a either a loose or packed PEX.
library_file_path = os.path.join(os.path.dirname(__file__), library_file_relpath)
if not os.path.exists(library_file_path):
raise RuntimeError(
"Pexrc is not supported on {target_triple}: no pexrc library found.".format(
target_triple=target_triple,
)
)
try:
return cdll.LoadLibrary(library_file_path) # type: Pexrc
except OSError as e:
raise RuntimeError(
"Failed to load pexrc library from {library_file_path}: {err}".format(
library_file_path=library_file_path, err=e
)
)

dll = None # type: Optional[Pexrc]
tmp_dir = tempfile.mkdtemp()
library_file_path = os.path.join(tmp_dir, os.path.basename(library_file_name))
library_file_path = os.path.join(tmp_dir, library_file_name)
try:
prefix = ".clib" if __name__ == "__pex__" else os.path.join("__pex__", ".clib")
pexrc_data = pkgutil.get_data(
__name__,
os.path.join(
prefix,
"{target_triple}.{library_file_name}".format(
target_triple=target_triple, library_file_name=library_file_name
),
),
)
pexrc_data = pkgutil.get_data(__name__, library_file_relpath)
if pexrc_data is None:
raise RuntimeError(
"Pexrc is not supported on {target_triple}: no pexrc library found.".format(
Expand Down
8 changes: 6 additions & 2 deletions crates/boot/src/boot.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright 2026 Pex project contributors.
# SPDX-License-Identifier: Apache-2.0
# --- split --- #

# N.B.: This script should stick to syntax defined for POSIX `sh` and avoid non-builtins.
# See: https://pubs.opengroup.org/onlinepubs/9699919799/idx/shell.html
set -eu

# --- vars --- #
# --- split --- #
# N.B.: These vars are templated in by pexrc when it injects a PEX with its runtime.
RAW_DEFAULT_PEXRC_ROOT="{pexrc_root}"
VENV_RELPATH="{venv_relpath}"
PYTHONS="{pythons}"
# --- vars --- #
# --- split --- #

# N.B.: The SC2116 warning suppressions below are in place to ensure tilde-expansion of the
# DEFAULT_PEX_ROOT value which is necessary for the -x check of the venv pex to succeed when it
Expand Down
Loading