Skip to content

Commit ca30e02

Browse files
committed
improving robustness with new builds
1 parent ce06cc9 commit ca30e02

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

meson.build

+6-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ endif
2121
# Here we differentiate from the python used by meson, py3_command, and that python target, py3_target. This is useful
2222
# when cross compiling like on conda-forge
2323
py_mod = import('python')
24-
py3_command = py_mod.find_installation()
2524
if get_option('python_target') != ''
26-
py3_target = py_mod.find_installation(get_option('python_target'))
25+
py3 = py_mod.find_installation(get_option('python_target'))
2726
else
28-
py3_target = py3_command
27+
py3 = py_mod.find_installation('python')
2928
endif
30-
py3_dep = py3_target.dependency()
29+
py3_dep = py3.dependency()
30+
31+
message(py3.path())
32+
message(py3.get_install_dir())
3133

3234
subdir('pyframe3dd')
3335

meson_options.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ option('incdir_numpy', type: 'string', value: '',
22
description: 'Include directory for numpy. If left empty Meson will try to find it on its own.')
33

44
option('python_target', type: 'string', value: '',
5-
description: '''Target python path. This is used in the case that the Python installation that pyFrame3DD is intended
5+
description: '''Target python path. This is used in the case that the Python installation that PyOptSparse is intended
66
to be built for is different than the Python installation that is used to run Meson. For example, Meson may be installed
7-
on the user's system which is run using the system Python installation, but the user may want build pyFrame3DD for
7+
on the user's system which is run using the system Python installation, but the user may want build PyOptSparse for
88
a Python installation in a virtual environment. Leave as an empty string to build for Python installation running
99
Meson.''')

setup.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
# only if building in place: ``python setup.py build_ext --inplace``
33
import os
44
import re
5+
import platform
56
import shutil
67
import setuptools
78
import subprocess
89

910

10-
def run_meson_build():
11+
def run_meson_build(staging_dir):
1112
prefix = os.path.join(os.getcwd(), staging_dir)
1213
purelibdir = "."
1314

@@ -16,6 +17,12 @@ def run_meson_build():
1617
if "MESON_ARGS" in os.environ:
1718
meson_args = os.environ["MESON_ARGS"]
1819

20+
if platform.system() == "Windows":
21+
if not "FC" in os.environ:
22+
os.environ["FC"] = "gfortran"
23+
if not "CC" in os.environ:
24+
os.environ["CC"] = "gcc"
25+
1926
# configure
2027
meson_path = shutil.which("meson")
2128
meson_call = (
@@ -24,7 +31,9 @@ def run_meson_build():
2431
)
2532
sysargs = meson_call.split(" ")
2633
sysargs = [arg for arg in sysargs if arg != ""]
34+
print(sysargs)
2735
p1 = subprocess.run(sysargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
36+
os.makedirs(staging_dir, exist_ok=True)
2837
setup_log = os.path.join(staging_dir, "setup.log")
2938
with open(setup_log, "wb") as f:
3039
f.write(p1.stdout)
@@ -36,6 +45,8 @@ def run_meson_build():
3645
# build
3746
meson_call = f"{meson_path} compile -vC {staging_dir}"
3847
sysargs = meson_call.split(" ")
48+
sysargs = [arg for arg in sysargs if arg != ""]
49+
print(sysargs)
3950
p2 = subprocess.run(sysargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
4051
compile_log = os.path.join(staging_dir, "compile.log")
4152
with open(compile_log, "wb") as f:
@@ -70,9 +81,9 @@ def copy_shared_libraries():
7081
staging_dir = "meson_build"
7182

7283
# this keeps the meson build system from running more than once
73-
if "dist" not in str(os.path.abspath(__file__)) and not os.path.isdir(staging_dir):
84+
if "dist" not in str(os.path.abspath(__file__)):
7485
cwd = os.getcwd()
75-
run_meson_build()
86+
run_meson_build(staging_dir)
7687
os.chdir(cwd)
7788
copy_shared_libraries()
7889

@@ -101,8 +112,9 @@ def copy_shared_libraries():
101112
extras_require={
102113
"testing": ["pytest"],
103114
},
104-
python_requires=">=3.7",
115+
python_requires=">=3.8",
105116
packages=["pyframe3dd"],
117+
package_data={"": ["*.yaml", "*.so", "*.lib", "*.pyd", "*.pdb", "*.dylib", "*.dll"]},
106118
license='Apache License, Version 2.0',
107119
zip_safe=False,
108120
)

0 commit comments

Comments
 (0)