Skip to content
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

Replace os.uname by more universal platform.system #38914

Merged
merged 2 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sage/doctest/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
#*****************************************************************************

import multiprocessing
import os
import platform

# With OS X, Python 3.8 defaults to use 'spawn' instead of 'fork' in
# multiprocessing, and Sage doctesting doesn't work with 'spawn'. See
# trac #27754.
if os.uname().sysname == 'Darwin':
if platform.system() == 'Darwin':
multiprocessing.set_start_method('fork', force=True)
Array = multiprocessing.Array

Expand Down
3 changes: 2 additions & 1 deletion src/sage/doctest/forker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@


import os
import platform
import sys
import time
import signal
Expand Down Expand Up @@ -80,7 +81,7 @@
# With OS X, Python 3.8 defaults to use 'spawn' instead of 'fork' in
# multiprocessing, and Sage doctesting doesn't work with 'spawn'. See
# trac #27754.
if os.uname().sysname == 'Darwin':
if platform.system() == 'Darwin':
multiprocessing.set_start_method('fork', force=True)


Expand Down
2 changes: 1 addition & 1 deletion src/sage/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

from typing import Optional
import sage
import platform
import os
import socket
import sys
Expand Down Expand Up @@ -165,7 +166,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st


# system info
UNAME = var("UNAME", os.uname()[0])
HOSTNAME = var("HOSTNAME", socket.gethostname())
LOCAL_IDENTIFIER = var("LOCAL_IDENTIFIER", "{}.{}".format(HOSTNAME, os.getpid()))

Expand Down
3 changes: 2 additions & 1 deletion src/sage/interfaces/singular.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@
# ****************************************************************************

import os
import platform
import re
import sys
import pexpect
Expand Down Expand Up @@ -407,7 +408,7 @@ def __init__(self, maxread=None, script_subdirectory=None,
restart_on_ctrlc=True,
verbose_start=False,
logfile=logfile,
eval_using_file_cutoff=100 if os.uname()[0] == "SunOS" else 1000)
eval_using_file_cutoff=100 if platform.system() == "SunOS" else 1000)
self.__libs = []
self._prompt_wait = prompt
self.__to_clear = [] # list of variable names that need to be cleared.
Expand Down
3 changes: 2 additions & 1 deletion src/sage/misc/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
---------------------
"""

import platform
from sage.structure.sage_object import SageObject


Expand Down Expand Up @@ -66,7 +67,7 @@ def default_viewer(viewer=None):
PDF_VIEWER = BROWSER
PNG_VIEWER = BROWSER

elif os.uname()[0] == 'Darwin':
elif platform.system() == 'Darwin':
# Simple on OS X, since there is an open command that opens
# anything, using the user's preferences.
BROWSER = 'open -W'
Expand Down
3 changes: 2 additions & 1 deletion src/sage_docbuild/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import errno
import os
import platform
import traceback
from typing import Optional

Expand Down Expand Up @@ -193,7 +194,7 @@ def build_many(target, args, processes=None):
# With OS X, Python 3.8 defaults to use 'spawn' instead of 'fork'
# in multiprocessing, and Sage docbuilding doesn't work with
# 'spawn'. See trac #27754.
if os.uname().sysname == "Darwin":
if platform.system() == "Darwin":
set_start_method("fork", force=True)
from queue import Empty

Expand Down
6 changes: 3 additions & 3 deletions src/sage_setup/setenv.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Set some environment variables in the running process

import os
import sage.env
import platform
from pathlib import Path

def _environ_prepend(var, value, separator=':'):
Expand All @@ -12,7 +12,7 @@ def _environ_prepend(var, value, separator=':'):
os.environ[var] = value

def setenv():
from sage.env import UNAME, SAGE_LOCAL, SAGE_VENV, SAGE_ARCHFLAGS, SAGE_PKG_CONFIG_PATH
from sage.env import SAGE_LOCAL, SAGE_VENV, SAGE_ARCHFLAGS, SAGE_PKG_CONFIG_PATH

##
## from sage-env:
Expand All @@ -32,7 +32,7 @@ def setenv():
_environ_prepend('CPATH', f'{SAGE_LOCAL}/include')
_environ_prepend('LDFLAGS', f'-L{SAGE_LOCAL}/lib -Wl,-rpath,{SAGE_LOCAL}/lib',
separator=' ')
if UNAME == 'Linux':
if platform.system() == 'Linux':
_environ_prepend('LDFLAGS', f'-Wl,-rpath-link,{SAGE_LOCAL}/lib',
separator=' ')
if Path(SAGE_VENV).resolve() != Path(SAGE_LOCAL).resolve():
Expand Down
Loading