-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access sysconfig
paths through pyodide config
CLI
#14
base: main
Are you sure you want to change the base?
Changes from all commits
23045dc
46efb6b
47b35e2
5784a0f
d5582ce
fc23181
57ef6f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,6 @@ | ||||||||||||
import os | ||||||||||||
import subprocess | ||||||||||||
import sysconfig | ||||||||||||
from collections.abc import Mapping | ||||||||||||
from pathlib import Path | ||||||||||||
from types import MappingProxyType | ||||||||||||
|
@@ -29,8 +30,15 @@ def __init__(self, pyodide_root: Path): | |||||||||||
**self._load_makefile_envs(), | ||||||||||||
**self._load_config_file(Path.cwd(), os.environ), | ||||||||||||
**self._load_config_from_env(os.environ), | ||||||||||||
**self._load_sysconfig_paths(), | ||||||||||||
} | ||||||||||||
|
||||||||||||
def _load_sysconfig_paths(self) -> Mapping[str, str]: | ||||||||||||
# Load the values of sysconfig.get_paths() with a | ||||||||||||
# "pyodide_sysconfig_" prefix to differentiate them | ||||||||||||
# from other configuration variables | ||||||||||||
return {f"pyodide_sysconfig_{k}": v for k, v in sysconfig.get_paths().items()} | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would retrieve the host Python's sysconfig values, not those in the cross build env. We should parse these values from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where should I retrieve this file from the cross-build environment? I have noted that I can get the file when I do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the code we locate the sysconfig file. Since it uses the variables in the Makefile.envs, you'll need to modify it a bit to use it in the config manager to prevent cyclic import. pyodide-build/pyodide_build/pypabuild.py Lines 98 to 102 in fac0109
I think you'll also need to read the sysconfig.py and how it retrieves the value from the sysconfig file, as we cannot directly use |
||||||||||||
|
||||||||||||
def _load_default_config(self) -> Mapping[str, str]: | ||||||||||||
return { | ||||||||||||
k: _environment_substitute_str( | ||||||||||||
|
@@ -173,6 +181,10 @@ def to_env(self) -> dict[str, str]: | |||||||||||
"_f2c_fixes_wrapper": "_F2C_FIXES_WRAPPER", | ||||||||||||
} | ||||||||||||
|
||||||||||||
BUILD_KEY_TO_VAR.update( | ||||||||||||
{f"pyodide_sysconfig_{k}": v for k, v in sysconfig.get_paths().items()} | ||||||||||||
) | ||||||||||||
|
||||||||||||
BUILD_VAR_TO_KEY = {v: k for k, v in BUILD_KEY_TO_VAR.items()} | ||||||||||||
|
||||||||||||
# Configuration keys that can be overridden by the user. | ||||||||||||
|
@@ -205,6 +217,10 @@ def to_env(self) -> dict[str, str]: | |||||||||||
"_f2c_fixes_wrapper": "", | ||||||||||||
} | ||||||||||||
|
||||||||||||
DEFAULT_CONFIG.update( | ||||||||||||
{f"pyodide_sysconfig_{k}": v for k, v in sysconfig.get_paths().items()} | ||||||||||||
) | ||||||||||||
|
||||||||||||
# Default configs that are computed from other values (often from Makefile.envs) | ||||||||||||
# TODO: Remove dependency on Makefile.envs | ||||||||||||
DEFAULT_CONFIG_COMPUTED: dict[str, str] = { | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are only eight values in
sysconfig.get_paths()
, so, I think it is okay to list all of them, which will be more explicit and make the code more readable.