diff --git a/src/sage/doctest/external.py b/src/sage/doctest/external.py index 56727bd79f6..bf0309d3131 100644 --- a/src/sage/doctest/external.py +++ b/src/sage/doctest/external.py @@ -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 diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py index b69c842836c..bf6d49906de 100644 --- a/src/sage/doctest/forker.py +++ b/src/sage/doctest/forker.py @@ -48,6 +48,7 @@ import os +import platform import sys import time import signal @@ -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) diff --git a/src/sage/env.py b/src/sage/env.py index 2be366c6f3e..0cfe6dfe8c4 100644 --- a/src/sage/env.py +++ b/src/sage/env.py @@ -36,6 +36,7 @@ from typing import Optional import sage +import platform import os import socket import sys @@ -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())) diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py index fdb4d093c55..d02ae43149f 100644 --- a/src/sage/interfaces/singular.py +++ b/src/sage/interfaces/singular.py @@ -335,6 +335,7 @@ # **************************************************************************** import os +import platform import re import sys import pexpect @@ -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. diff --git a/src/sage/misc/viewer.py b/src/sage/misc/viewer.py index badc70a963a..3be9d14609d 100644 --- a/src/sage/misc/viewer.py +++ b/src/sage/misc/viewer.py @@ -26,6 +26,7 @@ --------------------- """ +import platform from sage.structure.sage_object import SageObject @@ -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' diff --git a/src/sage_docbuild/utils.py b/src/sage_docbuild/utils.py index 50b54b2aa6b..f34c65b10e1 100644 --- a/src/sage_docbuild/utils.py +++ b/src/sage_docbuild/utils.py @@ -4,6 +4,7 @@ import errno import os +import platform import traceback from typing import Optional @@ -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 diff --git a/src/sage_setup/setenv.py b/src/sage_setup/setenv.py index b868360d612..48a38afad74 100644 --- a/src/sage_setup/setenv.py +++ b/src/sage_setup/setenv.py @@ -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=':'): @@ -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: @@ -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():