From 719ac95bd3f13e85cdd6e28a23ce71ef2278a432 Mon Sep 17 00:00:00 2001 From: Garrett Barter Date: Sun, 7 Jan 2024 10:37:25 -0700 Subject: [PATCH 1/3] try this one --- .github/workflows/CI_CCBlade.yml | 4 ++-- setup.py | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/CI_CCBlade.yml b/.github/workflows/CI_CCBlade.yml index 6ef5137..9aa696f 100644 --- a/.github/workflows/CI_CCBlade.yml +++ b/.github/workflows/CI_CCBlade.yml @@ -17,11 +17,11 @@ jobs: fail-fast: False matrix: os: ["ubuntu-latest", "windows-latest"] - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.9", "3.10", "3.11"] steps: - name: checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 # Official way to do miniconda, but it messes with the worker environment and shell - name: Install miniconda diff --git a/setup.py b/setup.py index db3be24..11942e3 100644 --- a/setup.py +++ b/setup.py @@ -22,13 +22,13 @@ def has_ext_modules(foo): return True ####### this_dir = os.path.abspath(os.path.dirname(__file__)) +staging_dir = os.path.join(this_dir, "meson_build") build_dir = os.path.join(this_dir, "build") def copy_shared_libraries(): build_path = os.path.join(build_dir, "ccblade") for root, _dirs, files in os.walk(build_path): for file in files: - # move ccblade libraries to just under staging_dir if file.endswith((".so", ".lib", ".pyd", ".pdb", ".dylib", ".dll")): if ".so.p" in root or ".pyd.p" in root: # excludes intermediate object files continue @@ -80,22 +80,23 @@ def build_extension(self, ext): os.environ["CC"] = "gcc" purelibdir = "." - configure_call = ["meson", "setup", build_dir, "--wipe", + configure_call = ["meson", "setup", staging_dir, "--wipe", f"-Dpython.purelibdir={purelibdir}", f"--prefix={build_dir}", f"-Dpython.platlibdir={purelibdir}"] + meson_args.split() configure_call = [m for m in configure_call if m.strip() != ""] print(configure_call) - build_call = ["meson", "compile", "-vC", build_dir] + build_call = ["meson", "compile", "-vC", staging_dir] print(build_call) - self.build_temp = build_dir + install_call = ["meson", "install", "-C", staging_dir] + print(install_call) - # Need fresh build directory for CMake - os.makedirs(self.build_temp, exist_ok=True) + self.build_temp = build_dir self.spawn(configure_call) self.spawn(build_call) + self.spawn(install_call) copy_shared_libraries() From 16cfe7697d0cb3c2a2c2db122a9981616f8ccf52 Mon Sep 17 00:00:00 2001 From: Garrett Barter Date: Mon, 8 Jan 2024 05:05:49 -0700 Subject: [PATCH 2/3] fix windows, expand CI --- .github/workflows/CI_CCBlade.yml | 123 +++++++++++++++++++------------ setup.py | 19 ++--- 2 files changed, 79 insertions(+), 63 deletions(-) diff --git a/.github/workflows/CI_CCBlade.yml b/.github/workflows/CI_CCBlade.yml index 9aa696f..e8e414f 100644 --- a/.github/workflows/CI_CCBlade.yml +++ b/.github/workflows/CI_CCBlade.yml @@ -5,85 +5,110 @@ on: [push, pull_request] # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - build_conda: - name: Build (${{ matrix.os }} Python ${{ matrix.python-version }}) + build_pip: + name: Pip Build (${{ matrix.os }}) - ${{ matrix.python-version }} runs-on: ${{ matrix.os }} - defaults: run: shell: bash -l {0} strategy: - fail-fast: False + fail-fast: false #true matrix: - os: ["ubuntu-latest", "windows-latest"] + os: ["ubuntu-latest", "macOS-latest", "windows-latest"] python-version: ["3.9", "3.10", "3.11"] steps: + - name: Setup GNU Fortran + # if: false == contains( matrix.os, 'windows') + uses: awvwgk/setup-fortran@v1 #modflowpy/install-intelfortran-action@v1 # + - name: checkout repository uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + id: cp + with: + python-version: ${{ matrix.python-version }} + update-environment: true + + #- name: Setup tmate session + # if: contains( matrix.os, 'windows') + # uses: mxschmitt/action-tmate@v3 - # Official way to do miniconda, but it messes with the worker environment and shell - - name: Install miniconda - uses: conda-incubator/setup-miniconda@v2 + - name: Pip Install CCBlade + env: + MESON_ARGS: -Dpython_target=${{ steps.cp.outputs.python-path }} + run: | + '${{ steps.cp.outputs.python-path }}' -m pip install -v -e .[test] + + - name: Test run + run: | + cd test + '${{ steps.cp.outputs.python-path }}' -m pytest . + + + build_conda: + name: Conda Build (${{ matrix.os }}) - ${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash -el {0} + + strategy: + fail-fast: false #true + matrix: + os: ["ubuntu-latest", "macOS-latest", "windows-latest"] + python-version: ["3.9", "3.10", "3.11"] + + steps: + - name: checkout repository + uses: actions/checkout@v4 + + - uses: conda-incubator/setup-miniconda@v2 # https://github.com/marketplace/actions/setup-miniconda with: - miniconda-version: "latest" - channels: conda-forge + #mamba-version: "*" + miniforge-version: "latest" auto-update-conda: true python-version: ${{ matrix.python-version }} environment-file: environment.yml activate-environment: test auto-activate-base: false - # This is a less official, but more lightweight way to do miniconda - #- name: Install miniconda - # uses: s-weigand/setup-conda@v1 - # # https://github.com/marketplace/actions/setup-conda - # with: - # update-conda: true - # python-version: ${{ matrix.python-version }} - # conda-channels: conda-forge - # activate-conda: true - # - #- name: Update environment - # run: | - # conda env update --file environment.yml - - # Install compilers - #- name: Add compilers - # run: | - # conda install compilers - - # Install dependencies of WISDEM specific to linux/mac - #- name: Add dependencies linux specific - # if: false == contains( matrix.os, 'windows') - # run: | - # conda install ninja - # conda init bash - - # Install dependencies of WISDEM specific to windows - name: Add dependencies windows specific if: contains( matrix.os, 'windows') run: | conda install -y m2w64-toolchain libpython + + - name: Add dependencies mac specific + if: contains( matrix.os, 'mac') + run: | + conda install -y compilers + gfortran --version + # Install + - name: Debug + run: | + conda list + printenv + + #- name: Setup tmate session + # uses: mxschmitt/action-tmate@v3 + # with: + # detached: true + # if: contains( matrix.os, 'windows') + # Install - name: Conda Install CCBlade + env: + MESON_ARGS: "" run: | python setup.py develop - # Peek - #- name: Library name - # run: | - # ls - # echo "BREAK" - # ls ccblade - # echo "BREAK" - # ls meson_build/ccblade - - # Run tests - - name: Conda Run pytest + - name: Test run run: | - pytest test + cd test + pytest . diff --git a/setup.py b/setup.py index 11942e3..603d211 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ #!/usr/bin/env python import os -import re import shutil import platform import setuptools @@ -26,16 +25,12 @@ def has_ext_modules(foo): build_dir = os.path.join(this_dir, "build") def copy_shared_libraries(): - build_path = os.path.join(build_dir, "ccblade") + build_path = os.path.join(staging_dir, "pyframe3dd") for root, _dirs, files in os.walk(build_path): - for file in files: - if file.endswith((".so", ".lib", ".pyd", ".pdb", ".dylib", ".dll")): - if ".so.p" in root or ".pyd.p" in root: # excludes intermediate object files - continue - file_path = os.path.join(root, file) - new_path = str(file_path) - match = re.search(build_dir, new_path) - new_path = new_path[match.span()[1] + 1 :] + for f in files: + if f.endswith((".so", ".lib", ".pyd", ".pdb", ".dylib", ".dll")): + file_path = os.path.join(root, f) + new_path = str(file_path).replace(staging_dir + os.sep, "") print(f"Copying build file {file_path} -> {new_path}") shutil.copy(file_path, new_path) @@ -89,14 +84,10 @@ def build_extension(self, ext): build_call = ["meson", "compile", "-vC", staging_dir] print(build_call) - install_call = ["meson", "install", "-C", staging_dir] - print(install_call) - self.build_temp = build_dir self.spawn(configure_call) self.spawn(build_call) - self.spawn(install_call) copy_shared_libraries() From 58f34b5a1ba7f006053d6a348b544af50274d64b Mon Sep 17 00:00:00 2001 From: Garrett Barter Date: Mon, 8 Jan 2024 05:08:55 -0700 Subject: [PATCH 3/3] fix copy paste error --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 603d211..538130d 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ def has_ext_modules(foo): build_dir = os.path.join(this_dir, "build") def copy_shared_libraries(): - build_path = os.path.join(staging_dir, "pyframe3dd") + build_path = os.path.join(staging_dir, "ccblade") for root, _dirs, files in os.walk(build_path): for f in files: if f.endswith((".so", ".lib", ".pyd", ".pdb", ".dylib", ".dll")):