Skip to content

Commit 59794cd

Browse files
committed
Change site-packages paths
1 parent ba300c7 commit 59794cd

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

Lib/site.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,14 @@ def joinuser(*args):
265265
def _get_path(userbase):
266266
version = sys.version_info
267267

268+
# XXX RUSTPYTHON: we replace pythonx.y with rustpythonx.y
268269
if os.name == 'nt':
269-
return f'{userbase}\\Python{version[0]}{version[1]}\\site-packages'
270+
return f'{userbase}\\RustPython{version[0]}{version[1]}\\site-packages'
270271

271272
if sys.platform == 'darwin' and sys._framework:
272-
return f'{userbase}/lib/python/site-packages'
273+
return f'{userbase}/lib/rustpython/site-packages'
273274

274-
return f'{userbase}/lib/python{version[0]}.{version[1]}/site-packages'
275+
return f'{userbase}/lib/rustpython{version[0]}.{version[1]}/site-packages'
275276

276277

277278
def getuserbase():

Lib/sysconfig.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@
8080
},
8181
}
8282

83+
# XXX RUSTPYTHON: replace python with rustpython in all these paths
84+
for group in _INSTALL_SCHEMES.values():
85+
for key in group.keys():
86+
group[key] = group[key].replace("Python", "RustPython").replace("python", "rustpython")
87+
88+
8389
_SCHEME_KEYS = ('stdlib', 'platstdlib', 'purelib', 'platlib', 'include',
8490
'scripts', 'data')
8591

vm/src/stdlib/sysconfigdata.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
use crate::pyobject::{ItemProtocol, PyObjectRef};
22
use crate::VirtualMachine;
33

4+
use crate::sysmodule::MULTIARCH;
5+
46
pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
57
let vars = vm.ctx.new_dict();
68
macro_rules! hashmap {
7-
($($key:literal => $value:literal),*) => {{
8-
$(vars.set_item($key, vm.ctx.new_str($value.to_owned()), vm).unwrap();)*
9+
($($key:literal => $value:expr),*$(,)?) => {{
10+
$(vars.set_item($key, vm.ctx.new_str($value), vm).unwrap();)*
911
}};
1012
}
13+
hashmap! {
14+
// fake shared module extension
15+
"EXT_SUFFIX" => format!(".rustpython-{}", MULTIARCH),
16+
"MULTIARCH" => MULTIARCH,
17+
}
1118
include!(concat!(env!("OUT_DIR"), "/env_vars.rs"));
1219

1320
py_module!(vm, "_sysconfigdata", {

vm/src/sysmodule.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ const ABIFLAGS: &str = "";
398398
// not the same as CPython (e.g. rust's x86_x64-unknown-linux-gnu is just x86_64-linux-gnu)
399399
// but hopefully that's just an implementation detail? TODO: copy CPython's multiarch exactly,
400400
// https://github.com/python/cpython/blob/3.8/configure.ac#L725
401-
const MULTIARCH: &str = env!("RUSTPYTHON_TARGET_TRIPLE");
401+
pub(crate) const MULTIARCH: &str = env!("RUSTPYTHON_TARGET_TRIPLE");
402402

403403
pub(crate) fn sysconfigdata_name() -> String {
404404
format!("_sysconfigdata_{}_{}_{}", ABIFLAGS, PLATFORM, MULTIARCH)

0 commit comments

Comments
 (0)