Skip to content

Commit 910ba3d

Browse files
committed
Try to download get-pip script for specific python version, then fallback to default get-pip
1 parent 6eb746e commit 910ba3d

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/builder/commands/pip.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ use crate::{
2222
const PIP_HOME: &str = "/tmp/pip-install";
2323
const PYTHON_PATH: &str = PIP_HOME;
2424

25-
const PIP_MIN_PYTHON_VERSION: (u8, u8, u8) = (3, 6, 0);
26-
2725
#[derive(Serialize, Deserialize, Debug, Clone)]
2826
pub struct PipConfig {
2927
pub find_links: Vec<String>,
@@ -200,19 +198,19 @@ pub fn bootstrap(ctx: &mut Context, ver: u8) -> Result<(), String> {
200198
);
201199
args.extend_from_slice(&ctx.pip_settings.get_pip_args);
202200
let py_ver = python_version(ctx, ver)?;
203-
let _get_pip_url;
204-
let get_pip_url = if py_ver < PIP_MIN_PYTHON_VERSION {
205-
_get_pip_url = format!("https://bootstrap.pypa.io/pip/{}.{}/get-pip.py", py_ver.0, py_ver.1);
206-
&_get_pip_url
207-
} else {
208-
"https://bootstrap.pypa.io/get-pip.py"
201+
let get_pip_url = format!("https://bootstrap.pypa.io/pip/{}.{}/get-pip.py", py_ver.0, py_ver.1);
202+
// TODO: Structured downloading file error
203+
let pip_inst = match download::download_file(
204+
&mut ctx.capsule, &[get_pip_url], None, false
205+
) {
206+
Ok(get_pip_path) => get_pip_path,
207+
Err(_) => {
208+
let get_pip_default_url = "https://bootstrap.pypa.io/get-pip.py";
209+
download::download_file(
210+
&mut ctx.capsule,&[get_pip_default_url], None, false
211+
)?
212+
}
209213
};
210-
let pip_inst = download::download_file(
211-
&mut ctx.capsule,
212-
&[get_pip_url],
213-
None,
214-
false
215-
)?;
216214
copy(&pip_inst, &Path::new("/vagga/root/tmp/get-pip.py"))
217215
.map_err(|e| format!("Error copying pip: {}", e))?;
218216
run_command_at_env(ctx, &args, &Path::new("/work"), &[])

0 commit comments

Comments
 (0)