你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 15:10:13 +08:00
Updated with ruff formatter
这个提交包含在:
41
setup.py
41
setup.py
@@ -33,11 +33,15 @@ from setuptools import Extension, find_packages, setup
|
||||
# Check Python version
|
||||
MIN_PYTHON_VERSION = (3, 7)
|
||||
if sys.version_info[:2] < MIN_PYTHON_VERSION:
|
||||
sys.exit("\nExited: Requires Python {MIN_PYTHON_VERSION[0]}.{MIN_PYTHON_VERSION[1]} or newer!\n")
|
||||
sys.exit(
|
||||
"\nExited: Requires Python {MIN_PYTHON_VERSION[0]}.{MIN_PYTHON_VERSION[1]} or newer!\n"
|
||||
)
|
||||
|
||||
# Importing gprMax _version__.py before building can cause issues.
|
||||
with open("gprMax/_version.py", "r") as fd:
|
||||
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE)[1]
|
||||
version = re.search(
|
||||
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE
|
||||
)[1]
|
||||
|
||||
|
||||
def build_dispersive_material_templates():
|
||||
@@ -108,7 +112,9 @@ def build_dispersive_material_templates():
|
||||
]
|
||||
)
|
||||
|
||||
with open(os.path.join("gprMax", "cython", "fields_updates_dispersive.pyx"), "w") as f:
|
||||
with open(
|
||||
os.path.join("gprMax", "cython", "fields_updates_dispersive.pyx"), "w"
|
||||
) as f:
|
||||
f.write(r)
|
||||
|
||||
|
||||
@@ -144,9 +150,9 @@ if "cleanall" in sys.argv:
|
||||
except OSError:
|
||||
print(f"Could not remove: {filebase}.c")
|
||||
# Remove compiled Cython modules
|
||||
libfile = glob.glob(os.path.join(os.getcwd(), os.path.splitext(file)[0]) + "*.pyd") + glob.glob(
|
||||
os.path.join(os.getcwd(), os.path.splitext(file)[0]) + "*.so"
|
||||
)
|
||||
libfile = glob.glob(
|
||||
os.path.join(os.getcwd(), os.path.splitext(file)[0]) + "*.pyd"
|
||||
) + glob.glob(os.path.join(os.getcwd(), os.path.splitext(file)[0]) + "*.so")
|
||||
if libfile:
|
||||
libfile = libfile[0]
|
||||
try:
|
||||
@@ -182,7 +188,11 @@ else:
|
||||
elif sys.platform == "darwin":
|
||||
# Check for Intel or Apple M series CPU
|
||||
cpuID = (
|
||||
subprocess.check_output("sysctl -n machdep.cpu.brand_string", shell=True, stderr=subprocess.STDOUT)
|
||||
subprocess.check_output(
|
||||
"sysctl -n machdep.cpu.brand_string",
|
||||
shell=True,
|
||||
stderr=subprocess.STDOUT,
|
||||
)
|
||||
.decode("utf-8")
|
||||
.strip()
|
||||
)
|
||||
@@ -196,7 +206,11 @@ else:
|
||||
# Use newest gcc found
|
||||
os.environ["CC"] = gccpath[-1].split(os.sep)[-1]
|
||||
if "Apple" in cpuID:
|
||||
rpath = "/opt/homebrew/opt/gcc/lib/gcc/" + gccpath[-1].split(os.sep)[-1][-1] + "/"
|
||||
rpath = (
|
||||
"/opt/homebrew/opt/gcc/lib/gcc/"
|
||||
+ gccpath[-1].split(os.sep)[-1][-1]
|
||||
+ "/"
|
||||
)
|
||||
else:
|
||||
raise (
|
||||
f"Cannot find gcc in {gccbasepath}. gprMax requires gcc "
|
||||
@@ -214,7 +228,13 @@ else:
|
||||
pass
|
||||
os.environ["MIN_SUPPORTED_MACOSX_DEPLOYMENT_TARGET"] = MIN_MACOS_VERSION
|
||||
# Sometimes worth testing with '-fstrict-aliasing', '-fno-common'
|
||||
compile_args = ["-O3", "-w", "-fopenmp", "-march=native", f"-mmacosx-version-min={MIN_MACOS_VERSION}"]
|
||||
compile_args = [
|
||||
"-O3",
|
||||
"-w",
|
||||
"-fopenmp",
|
||||
"-march=native",
|
||||
f"-mmacosx-version-min={MIN_MACOS_VERSION}",
|
||||
]
|
||||
linker_args = ["-fopenmp", f"-mmacosx-version-min={MIN_MACOS_VERSION}"]
|
||||
libraries = ["gomp"]
|
||||
|
||||
@@ -261,7 +281,8 @@ else:
|
||||
version=version,
|
||||
author="Craig Warren, Antonis Giannopoulos, and John Hartley",
|
||||
url="http://www.gprmax.com",
|
||||
description="Electromagnetic Modelling Software based on the " + "Finite-Difference Time-Domain (FDTD) method",
|
||||
description="Electromagnetic Modelling Software based on the "
|
||||
+ "Finite-Difference Time-Domain (FDTD) method",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/x-rst",
|
||||
license="GPLv3+",
|
||||
|
在新工单中引用
屏蔽一个用户