Skip to content

Commit 9c14e67

Browse files
committed
Enable ssl by default for linux/macos
1 parent d87921c commit 9c14e67

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
target: aarch64-apple-darwin
153153
if: runner.os == 'macOS'
154154
- name: Check compilation for Apple Silicon
155-
run: cargo check --target aarch64-apple-darwin
155+
run: cargo check --target aarch64-apple-darwin --features=ssl-vendor
156156
if: runner.os == 'macOS'
157157
- name: prepare iOS build
158158
uses: dtolnay/rust-toolchain@stable
@@ -183,7 +183,7 @@ jobs:
183183
- name: Install gcc-multilib and musl-tools
184184
run: sudo apt-get update && sudo apt-get install gcc-multilib musl-tools
185185
- name: Check compilation for x86 32bit
186-
run: cargo check --target i686-unknown-linux-gnu
186+
run: cargo check --target i686-unknown-linux-gnu --features=ssl-vendor
187187

188188
- uses: dtolnay/rust-toolchain@stable
189189
with:
@@ -197,7 +197,7 @@ jobs:
197197
target: i686-unknown-linux-musl
198198

199199
- name: Check compilation for musl
200-
run: cargo check --target i686-unknown-linux-musl
200+
run: cargo check --target i686-unknown-linux-musl --features=ssl-vendor
201201

202202
- uses: dtolnay/rust-toolchain@stable
203203
with:

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ ssl-vendor = ["rustpython-stdlib/ssl-vendor"]
7575
rustpython-compiler = { path = "compiler", version = "0.2.0" }
7676
rustpython-parser = { path = "compiler/parser", version = "0.2.0" }
7777
rustpython-pylib = { path = "pylib", optional = true, default-features = false }
78-
rustpython-stdlib = { path = "stdlib", optional = true, default-features = false }
7978
rustpython-vm = { path = "vm", version = "0.2.0", default-features = false, features = ["compiler"] }
8079

8180
atty = { workspace = true }
@@ -88,6 +87,12 @@ dirs = { package = "dirs-next", version = "2.0.0" }
8887
env_logger = { version = "0.9.0", default-features = false, features = ["atty", "termcolor"] }
8988
flamescope = { version = "0.1.2", optional = true }
9089

90+
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
91+
rustpython-stdlib = {path = "stdlib", optional = true, default-features = false, features = ["ssl"]}
92+
93+
[target.'cfg(not(any(target_os = "linux", target_os = "macos")))'.dependencies]
94+
rustpython-stdlib = {path = "stdlib", optional = true, default-features = false}
95+
9196
[target.'cfg(windows)'.dependencies]
9297
libc = { workspace = true }
9398

src/lib.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ fn setup_main_module(vm: &VirtualMachine) -> PyResult<Scope> {
113113
Ok(scope)
114114
}
115115

116-
#[cfg(feature = "ssl")]
117116
fn get_pip(scope: Scope, vm: &VirtualMachine) -> PyResult<()> {
118117
let get_getpip = rustpython_vm::py_compile!(
119118
source = r#"\
@@ -133,26 +132,23 @@ __import__("io").TextIOWrapper(
133132
Ok(())
134133
}
135134

136-
#[cfg(feature = "ssl")]
137135
fn ensurepip(_: Scope, vm: &VirtualMachine) -> PyResult<()> {
138136
vm.run_module("ensurepip")
139137
}
140138

141139
fn install_pip(_installer: &str, _scope: Scope, vm: &VirtualMachine) -> PyResult<()> {
142-
#[cfg(feature = "ssl")]
143-
{
140+
if vm.state.module_inits.contains_key("_ssl") {
144141
match _installer {
145142
"ensurepip" => ensurepip(_scope, vm),
146143
"get-pip" => get_pip(_scope, vm),
147144
_ => unreachable!(),
148145
}
146+
} else {
147+
Err(vm.new_exception_msg(
148+
vm.ctx.exceptions.system_error.to_owned(),
149+
"install-pip requires rustpython be build with '--features=ssl'".to_owned(),
150+
))
149151
}
150-
151-
#[cfg(not(feature = "ssl"))]
152-
Err(vm.new_exception_msg(
153-
vm.ctx.exceptions.system_error.to_owned(),
154-
"install-pip requires rustpython be build with '--features=ssl'".to_owned(),
155-
))
156152
}
157153

158154
fn run_rustpython(vm: &VirtualMachine, run_mode: RunMode, quiet: bool) -> PyResult<()> {

0 commit comments

Comments
 (0)