Skip to content

Commit

Permalink
Merge pull request #11 from WISDEM/develop
Browse files Browse the repository at this point in the history
move libraries instead of copy them
  • Loading branch information
gbarter committed Jul 6, 2023
2 parents b3d29f4 + b5fa8f6 commit ebbd35a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 29 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/CI_pyHAMS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,30 +87,34 @@ jobs:
- uses: conda-incubator/setup-miniconda@v2
# https://github.com/marketplace/actions/setup-miniconda
with:
mamba-version: "*"
miniconda-version: "latest"
auto-update-conda: true
#auto-update-conda: true
python-version: ${{ matrix.python-version }}
environment-file: environment.yml
channels: conda-forge
channel-priority: true
activate-environment: test
auto-activate-base: false

# Install dependencies of WISDEM specific to windows
- name: Add dependencies windows specific
if: contains( matrix.os, 'windows')
run: |
conda install -y m2w64-toolchain libpython
conda list
mamba install -y m2w64-toolchain libpython
mamba list
# Install dependencies of WISDEM specific to windows
- name: Add dependencies mac specific
if: contains( matrix.os, 'mac')
run: |
conda install -y compilers
mamba install -y compilers
gfortran --version
# Install
- name: Conda Install pyHAMS
env:
MESON_ARGS: ""
run: |
python setup.py develop
Expand Down
41 changes: 16 additions & 25 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def run_meson_build(staging_dir):
meson_args = ""
if "MESON_ARGS" in os.environ:
meson_args = os.environ["MESON_ARGS"]
# A weird add-on on mac github action runners needs to be removed
if meson_args.find("buildtype") >= 0: meson_args = ""

if platform.system() == "Windows":
if not "FC" in os.environ:
Expand All @@ -47,38 +49,33 @@ def run_meson_build(staging_dir):
if meson_path is None:
raise OSError("The meson command cannot be found on the system")

meson_call = (
f"{meson_path} setup {staging_dir} --wipe --prefix={prefix} "
+ f"-Dpython.purelibdir={purelibdir} -Dpython.platlibdir={purelibdir} {meson_args}"
)
sysargs = meson_call.split(" ")
sysargs = [arg for arg in sysargs if arg != ""]
print(sysargs)
p1 = subprocess.run(sysargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
meson_call = [meson_path, "setup", staging_dir, "--wipe",
f"--prefix={prefix}", f"-Dpython.purelibdir={purelibdir}",
f"-Dpython.platlibdir={purelibdir}", meson_args]
meson_call = [m for m in meson_call if m != ""]
print(meson_call)
p1 = subprocess.run(meson_call, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
os.makedirs(staging_dir, exist_ok=True)
setup_log = os.path.join(staging_dir, "setup.log")
with open(setup_log, "wb") as f:
f.write(p1.stdout)
if p1.returncode != 0:
with open(setup_log, "r") as f:
print(f.read())
raise OSError(sysargs, f"The meson setup command failed! Check the log at {setup_log} for more information.")
raise OSError(meson_call, f"The meson setup command failed! Check the log at {setup_log} for more information.")

# build
meson_call = f"{meson_path} compile -vC {staging_dir}"
sysargs = meson_call.split(" ")
sysargs = [arg for arg in sysargs if arg != ""]
print(sysargs)
p2 = subprocess.run(sysargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
meson_call = [meson_path, "compile", "-vC", staging_dir]
meson_call = [m for m in meson_call if m != ""]
print(meson_call)
p2 = subprocess.run(meson_call, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
compile_log = os.path.join(staging_dir, "compile.log")
with open(compile_log, "wb") as f:
f.write(p2.stdout)
if p2.returncode != 0:
with open(compile_log, "r") as f:
print(f.read())
raise OSError(
sysargs, f"The meson compile command failed! Check the log at {compile_log} for more information."
)
raise OSError(meson_call, f"The meson compile command failed! Check the log at {compile_log} for more information.")


def copy_shared_libraries():
Expand All @@ -94,27 +91,21 @@ def copy_shared_libraries():
match = re.search(staging_dir, new_path)
new_path = new_path[match.span()[1] + 1 :]
print(f"Copying build file {file_path} -> {new_path}")
shutil.copy(file_path, new_path)
shutil.move(file_path, new_path)


if __name__ == "__main__":
# This is where the meson build system will install to, it is then
# used as the sources for setuptools
staging_dir = "meson_build"

# If on Windows, use the compiled exe from Yingyi
# this keeps the meson build system from running more than once
if "dist" not in str(os.path.abspath(__file__)):
cwd = os.getcwd()
run_meson_build(staging_dir)
os.chdir(cwd)
copy_shared_libraries()

#docs_require = ""
#req_txt = os.path.join("doc", "requirements.txt")
#if os.path.isfile(req_txt):
# with open(req_txt) as f:
# docs_require = f.read().splitlines()

init_file = os.path.join("pyhams", "__init__.py")
#__version__ = re.findall(
# r"""__version__ = ["']+([0-9\.]*)["']+""",
Expand Down

0 comments on commit ebbd35a

Please sign in to comment.