|
@@ -242,9 +242,7 @@ def get_install_package_manager(on_failure_return_none: bool = False) -> str | N
|
|
The path to the package manager.
|
|
The path to the package manager.
|
|
"""
|
|
"""
|
|
if constants.IS_WINDOWS and (
|
|
if constants.IS_WINDOWS and (
|
|
- not is_windows_bun_supported()
|
|
|
|
- or windows_check_onedrive_in_path()
|
|
|
|
- or windows_npm_escape_hatch()
|
|
|
|
|
|
+ windows_check_onedrive_in_path() or windows_npm_escape_hatch()
|
|
):
|
|
):
|
|
return get_package_manager(on_failure_return_none)
|
|
return get_package_manager(on_failure_return_none)
|
|
return str(get_config().bun_path)
|
|
return str(get_config().bun_path)
|
|
@@ -1064,17 +1062,11 @@ def install_bun():
|
|
Raises:
|
|
Raises:
|
|
SystemPackageMissingError: If "unzip" is missing.
|
|
SystemPackageMissingError: If "unzip" is missing.
|
|
"""
|
|
"""
|
|
- win_supported = is_windows_bun_supported()
|
|
|
|
one_drive_in_path = windows_check_onedrive_in_path()
|
|
one_drive_in_path = windows_check_onedrive_in_path()
|
|
- if constants.IS_WINDOWS and (not win_supported or one_drive_in_path):
|
|
|
|
- if not win_supported:
|
|
|
|
- console.warn(
|
|
|
|
- "Bun for Windows is currently only available for x86 64-bit Windows. Installation will fall back on npm."
|
|
|
|
- )
|
|
|
|
- if one_drive_in_path:
|
|
|
|
- console.warn(
|
|
|
|
- "Creating project directories in OneDrive is not recommended for bun usage on windows. This will fallback to npm."
|
|
|
|
- )
|
|
|
|
|
|
+ if constants.IS_WINDOWS and one_drive_in_path:
|
|
|
|
+ console.warn(
|
|
|
|
+ "Creating project directories in OneDrive is not recommended for bun usage on windows. This will fallback to npm."
|
|
|
|
+ )
|
|
|
|
|
|
# Skip if bun is already installed.
|
|
# Skip if bun is already installed.
|
|
if get_bun_version() == version.parse(constants.Bun.VERSION):
|
|
if get_bun_version() == version.parse(constants.Bun.VERSION):
|
|
@@ -1176,12 +1168,7 @@ def install_frontend_packages(packages: set[str], config: Config):
|
|
get_package_manager(on_failure_return_none=True)
|
|
get_package_manager(on_failure_return_none=True)
|
|
if (
|
|
if (
|
|
not constants.IS_WINDOWS
|
|
not constants.IS_WINDOWS
|
|
- or (
|
|
|
|
- constants.IS_WINDOWS
|
|
|
|
- and (
|
|
|
|
- is_windows_bun_supported() and not windows_check_onedrive_in_path()
|
|
|
|
- )
|
|
|
|
- )
|
|
|
|
|
|
+ or (constants.IS_WINDOWS and not windows_check_onedrive_in_path())
|
|
)
|
|
)
|
|
else None
|
|
else None
|
|
)
|
|
)
|
|
@@ -1926,24 +1913,23 @@ def format_address_width(address_width: str | None) -> int | None:
|
|
return None
|
|
return None
|
|
|
|
|
|
|
|
|
|
-@functools.lru_cache(maxsize=None)
|
|
|
|
-def get_cpu_info() -> CpuInfo | None:
|
|
|
|
- """Get the CPU info of the underlining host.
|
|
|
|
|
|
+def _retrieve_cpu_info() -> CpuInfo | None:
|
|
|
|
+ """Retrieve the CPU info of the host.
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
- The CPU info.
|
|
|
|
|
|
+ The CPU info.
|
|
"""
|
|
"""
|
|
platform_os = platform.system()
|
|
platform_os = platform.system()
|
|
cpuinfo = {}
|
|
cpuinfo = {}
|
|
try:
|
|
try:
|
|
if platform_os == "Windows":
|
|
if platform_os == "Windows":
|
|
- cmd = "wmic cpu get addresswidth,caption,manufacturer /FORMAT:csv"
|
|
|
|
|
|
+ cmd = 'powershell -Command "Get-CimInstance Win32_Processor | Select-Object -First 1 | Select-Object AddressWidth,Manufacturer,Name | ConvertTo-Json"'
|
|
output = processes.execute_command_and_return_output(cmd)
|
|
output = processes.execute_command_and_return_output(cmd)
|
|
if output:
|
|
if output:
|
|
- val = output.splitlines()[-1].split(",")[1:]
|
|
|
|
- cpuinfo["manufacturer_id"] = val[2]
|
|
|
|
- cpuinfo["model_name"] = val[1].split("Family")[0].strip()
|
|
|
|
- cpuinfo["address_width"] = format_address_width(val[0])
|
|
|
|
|
|
+ cpu_data = json.loads(output)
|
|
|
|
+ cpuinfo["address_width"] = cpu_data["AddressWidth"]
|
|
|
|
+ cpuinfo["manufacturer_id"] = cpu_data["Manufacturer"]
|
|
|
|
+ cpuinfo["model_name"] = cpu_data["Name"]
|
|
elif platform_os == "Linux":
|
|
elif platform_os == "Linux":
|
|
output = processes.execute_command_and_return_output("lscpu")
|
|
output = processes.execute_command_and_return_output("lscpu")
|
|
if output:
|
|
if output:
|
|
@@ -1983,21 +1969,20 @@ def get_cpu_info() -> CpuInfo | None:
|
|
|
|
|
|
|
|
|
|
@functools.lru_cache(maxsize=None)
|
|
@functools.lru_cache(maxsize=None)
|
|
-def is_windows_bun_supported() -> bool:
|
|
|
|
- """Check whether the underlining host running windows qualifies to run bun.
|
|
|
|
- We typically do not run bun on ARM or 32 bit devices that use windows.
|
|
|
|
|
|
+def get_cpu_info() -> CpuInfo | None:
|
|
|
|
+ """Get the CPU info of the underlining host.
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
- Whether the host is qualified to use bun.
|
|
|
|
|
|
+ The CPU info.
|
|
"""
|
|
"""
|
|
- cpu_info = get_cpu_info()
|
|
|
|
- return (
|
|
|
|
- constants.IS_WINDOWS
|
|
|
|
- and cpu_info is not None
|
|
|
|
- and cpu_info.address_width == 64
|
|
|
|
- and cpu_info.model_name is not None
|
|
|
|
- and "ARM" not in cpu_info.model_name
|
|
|
|
- )
|
|
|
|
|
|
+ cpu_info_file = environment.REFLEX_DIR.get() / "cpu_info.json"
|
|
|
|
+ if cpu_info_file.exists() and (cpu_info := json.loads(cpu_info_file.read_text())):
|
|
|
|
+ return CpuInfo(**cpu_info)
|
|
|
|
+ cpu_info = _retrieve_cpu_info()
|
|
|
|
+ if cpu_info:
|
|
|
|
+ cpu_info_file.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
+ cpu_info_file.write_text(json.dumps(dataclasses.asdict(cpu_info)))
|
|
|
|
+ return cpu_info
|
|
|
|
|
|
|
|
|
|
def is_generation_hash(template: str) -> bool:
|
|
def is_generation_hash(template: str) -> bool:
|