Skip to content

Commit 97e68ac

Browse files
authored
Add support for repository extract --sources. (#71)
All that remains is handling the `--use-system-time` flag.
1 parent 0dbf198 commit 97e68ac

20 files changed

Lines changed: 728 additions & 108 deletions

File tree

Cargo.lock

Lines changed: 116 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ members = [
2222
"crates/pexrs",
2323
"crates/platform",
2424
"crates/python-proxy",
25+
"crates/request",
2526
"crates/scripts",
2627
"crates/target",
2728
"crates/testing",
2829
"crates/tools",
29-
"crates/venv",
30+
"crates/venv"
3031
]
3132

3233
[package.metadata.build]
33-
zig_version = "0.15.2"
34+
zig_version = "0.16.0"
3435

3536
[package.metadata.build.cargo_binstall]
3637
version = "1.17.4"
@@ -134,6 +135,7 @@ anstream = "1.0"
134135
anyhow = "1.0"
135136
base64 = "0.22"
136137
bstr = "1.12"
138+
chrono = "0.4"
137139
clap = { version = "4.6", features = ["color", "derive", "string"] }
138140
clap-verbosity-flag = "3.0"
139141
colorchoice-clap = "1.0"
@@ -170,7 +172,6 @@ pep508_rs = "0.9"
170172
python-pkginfo = "0.6"
171173
rayon = "1.12"
172174
regex = "1.12"
173-
reqwest = { version = "0.13", features = ["blocking"] }
174175
rstest = "0.26"
175176
rust-ini = "0.21"
176177
same-file = "1.0"
@@ -190,7 +191,7 @@ url = "2.5"
190191
walkdir = "2.5"
191192
which = "8.0"
192193
xz2 = "0.1"
193-
zip = { version = "8.5", default-features = false, features = ["deflate", "zstd"] }
194+
zip = { version = "8.6", default-features = false, features = ["chrono", "deflate", "zstd"] }
194195
zstd = "0.13"
195196

196197
[build-dependencies]
@@ -226,11 +227,13 @@ pexrs = { path = "crates/pexrs" }
226227
platform = { path = "crates/platform" }
227228
python-proxy = { path = "crates/python-proxy" }
228229
rayon = { workspace = true }
230+
request = { path = "crates/request" }
229231
scripts = { path = "crates/scripts", features = ["embedded"] }
230232
sha2 = { workspace = true }
231233
strum = { workspace = true }
232234
target = { path = "crates/target" }
233235
tempfile = { workspace = true }
236+
url = { workspace = true }
234237
walkdir = { workspace = true }
235238
zip = { workspace = true }
236-
zstd = { workspace = true }
239+
zstd = { workspace = true }

crates/boot/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ pub fn sh_boot_shebang(pex: &Path, escaped: bool) -> anyhow::Result<Option<Strin
4646

4747
let interpreter_constraints =
4848
InterpreterConstraints::try_from(&pex.info.interpreter_constraints)?;
49-
let selection_strategy: SelectionStrategy = pex.info.interpreter_selection_strategy.into();
49+
let selection_strategy: SelectionStrategy = pex
50+
.info
51+
.interpreter_selection_strategy
52+
.unwrap_or(pex::InterpreterSelectionStrategy::Oldest)
53+
.into();
5054
let pythons = interpreter_constraints
5155
.calculate_compatible_binary_names(selection_strategy)
5256
.into_iter()

crates/build-system/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fs-err = { workspace = true }
1717
hex = { workspace = true }
1818
itertools = { workspace = true }
1919
platform = { path = "../platform" }
20-
reqwest = { workspace = true }
20+
request = { path = "../request" }
2121
serde = { workspace = true }
2222
sha2 = { workspace = true }
2323
strum = { workspace = true }
@@ -27,6 +27,7 @@ target = { path = "../target" }
2727
target-lexicon = { workspace = true }
2828
toml = { workspace = true }
2929
tempfile = { workspace = true }
30+
url = { workspace = true }
3031
xz2 = { workspace = true }
3132
zip = { workspace = true }
3233
which = { workspace = true }

crates/build-system/src/downloads.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use anyhow::{anyhow, bail};
99
use fs_err as fs;
1010
use fs_err::File;
1111
use sha2::{Digest, Sha256};
12+
use url::Url;
1213

1314
use crate::metadata::{Download, FileType};
1415

@@ -111,9 +112,9 @@ pub(crate) fn ensure_download(download: &Download, download_dir: &Path) -> anyho
111112
algorithm => bail!("No support for {algorithm} hashes."),
112113
};
113114

114-
let url = reqwest::Url::parse(download.url.as_ref())?;
115+
let url = Url::parse(download.url.as_ref())?;
115116

116-
let response = reqwest::blocking::get(url.as_ref())?;
117+
let response = request::get(url.as_ref())?;
117118
if let Some(actual_size) = response.content_length()
118119
&& actual_size != download.size
119120
{

crates/build-system/src/tools.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ fn get_zig_version(zig: &Path) -> Option<String> {
135135
})
136136
}
137137

138+
fn check_zig_version(version: &str, zig: &Path) -> bool {
139+
get_zig_version(zig)
140+
.map(|zig_version| zig_version == version)
141+
.unwrap_or_default()
142+
}
143+
138144
pub struct InstallDirs {
139145
bin_dir: PathBuf,
140146
pub(crate) data_dir: PathBuf,
@@ -295,6 +301,7 @@ fn install_tools<'a>(
295301
if platform::is_executable(&python_zig)
296302
.ok()
297303
.unwrap_or_default()
304+
&& check_zig_version(version, &python_zig)
298305
{
299306
return Ok(Cow::Owned(FoundTool {
300307
env_var: ZIG_TOOL_ENV_VAR,
@@ -306,6 +313,7 @@ fn install_tools<'a>(
306313
if platform::is_executable(&python_zig_exe)
307314
.ok()
308315
.unwrap_or_default()
316+
&& check_zig_version(version, &python_zig_exe)
309317
{
310318
return Ok(Cow::Owned(FoundTool {
311319
env_var: ZIG_TOOL_ENV_VAR,

0 commit comments

Comments
 (0)