diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c2389d86..76aa2db4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,151 +9,6 @@ on: jobs: - pymake_lint: - name: pymake linting - runs-on: ubuntu-latest - - if: github.repository_owner == 'modflowpy' - steps: - - name: Checkout repo - uses: actions/checkout@v2.3.4 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - - name: Setup Graphviz - uses: ts-graphviz/setup-graphviz@v1 - - - name: Install packages - run: | - pip install requests pydotplus appdirs numpy matplotlib - pip install https://github.com/modflowpy/flopy/zipball/develop - pip install pylint flake8 black - - - name: Run isort - run: | - echo "if isort check fails update isort using" - echo " pip install isort --upgrade" - echo "and run" - echo " isort ./flopy" - echo "and then commit the changes." - isort --verbose --check --diff ./pymake - - - name: Run black - run: | - echo "if black check fails update black using" - echo " pip install black --upgrade" - echo "and run" - echo " black ./flopy" - echo "and then commit the changes." - black --check --diff ./pymake - - - name: Run flake8 - run: flake8 --count --show-source ./pymake - - - name: Run pylint - run: pylint --jobs=0 --errors-only ./pymake - - pymake_setup: - name: standard installation - runs-on: ubuntu-latest - strategy: - fail-fast: false - defaults: - run: - shell: bash - - steps: - - # check out repo - - name: Checkout pymake repo - uses: actions/checkout@v2.3.4 - - - name: Setup Python - uses: actions/setup-python@v2.2.2 - with: - python-version: 3.9 - - - name: Upgrade pip and install wheel - run: | - python -m pip install --upgrade pip - pip install wheel - - - name: Base pymake installation - run: | - pip --verbose install . - - - name: Print pymake version - run: | - python -c "import pymake; print(pymake.__version__)" - - pymakeCI-os-gcc: - name: pymake CI gcc on different OSs - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] - defaults: - run: - shell: bash - - steps: - - name: Checkout repo - uses: actions/checkout@v2.3.4 - - - name: Setup Graphviz - if: runner.os == 'Linux' - uses: ts-graphviz/setup-graphviz@v1 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - - name: Install python packages - run: | - .github/common/install-python.sh - - - name: Setup symbolic link to gfortran on Linux - if: runner.os == 'Linux' - run: | - sudo ln -fs /usr/bin/gfortran-10 /usr/local/bin/gfortran - sudo ln -fs /usr/bin/gcc-10 /usr/local/bin/gcc - sudo ln -fs /usr/bin/g++-10 /usr/local/bin/g++ - - - name: Setup symbolic link to gfortran on macOS - if: runner.os == 'macOS' - run: | - sudo ln -fs /usr/local/bin/gfortran-10 /usr/local/bin/gfortran - sudo ln -fs /usr/local/bin/gcc-10 /usr/local/bin/gcc - sudo ln -fs /usr/local/bin/g++-10 /usr/local/bin/g++ - - - name: Print GNU compiler versions - run: | - gfortran --version - gcc --version - g++ --version - - - name: Download examples for pytest runs - run: | - .github/common/download-examples.sh - - - name: Run pytest - run: | - pytest -v --dist=loadfile -n=auto -m regression --durations=0 --cov=pymake --cov-report=xml autotest/ - - - name: Print coverage report before upload - run: | - coverage report - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1.0.15 - with: - file: ./coverage.xml - pymakeCI-os-intel: name: pymake CI intel on different OSs runs-on: ${{ matrix.os }} @@ -277,155 +132,3 @@ jobs: if: runner.os == 'Linux' && steps.cache-install-linux.outputs.cache-hit != 'true' run: | .github/intel-scripts/cache_exclude_linux.sh - - pymakeCI-gcc-prev: - name: pymake CI GCC 9 and 8 - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - gcc-version: [ 9, 8 ] - defaults: - run: - shell: bash - - steps: - - name: Checkout repo - uses: actions/checkout@v2.3.4 - - - name: Setup Graphviz - uses: ts-graphviz/setup-graphviz@v1 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - - name: Install python packages - run: | - .github/common/install-python.sh - - - name: Setup symbolic link to gfortran on Linux - run: | - sudo ln -fs /usr/bin/gfortran-${{ matrix.gcc-version }} /usr/local/bin/gfortran - sudo ln -fs /usr/bin/gcc-${{ matrix.gcc-version }} /usr/local/bin/gcc - sudo ln -fs /usr/bin/g++-${{ matrix.gcc-version }} /usr/local/bin/g++ - - - name: Print GNU compiler versions - run: | - gfortran --version - gcc --version - g++ --version - - - name: Download examples for pytest runs - run: | - .github/common/download-examples.sh - - - name: Run pytest - run: | - pytest -v --dist=loadfile -n=auto -m base --durations=0 --cov=pymake --cov-report=xml autotest/ - - - name: Print coverage report before upload - run: | - coverage report - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1.0.15 - with: - file: ./coverage.xml - - pymakeCI-requests: - name: pymake CI requests - runs-on: ubuntu-latest - defaults: - run: - shell: bash - - steps: - - name: Checkout repo - uses: actions/checkout@v2.3.4 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - - name: Install python packages - run: | - .github/common/install-python.sh - - - name: Run pytest - run: | - pytest -v --dist=loadfile -n=auto -m requests --durations=0 --cov=pymake --cov-report=xml autotest/ - - - name: Print coverage report before upload - run: | - coverage report - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1.0.15 - with: - file: ./coverage.xml - - pymakeCI-python-prev: - name: pymake CI with previous python versions - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: [ 3.8, 3.7 ] - defaults: - run: - shell: bash - - steps: - - name: Checkout repo - uses: actions/checkout@v2.3.4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Install python packages - run: | - .github/common/install-python.sh - - - name: Setup symbolic link to gfortran on Linux - if: runner.os == 'Linux' - run: | - sudo ln -fs /usr/bin/gfortran-10 /usr/local/bin/gfortran - sudo ln -fs /usr/bin/gcc-10 /usr/local/bin/gcc - sudo ln -fs /usr/bin/g++-10 /usr/local/bin/g++ - - - name: Print GNU compiler versions - run: | - gfortran --version - gcc --version - g++ --version - - - name: Download examples for pytest runs - run: | - .github/common/download-examples.sh - - - name: Run pytest - run: | - pytest -v --dist=loadfile -n=auto -m base --durations=0 - - pymake_rtd: - name: pymake rtd - needs: pymakeCI-os-gcc - runs-on: ubuntu-latest - if: - github.event_name == 'push' - steps: - - name: Checkout repo - uses: actions/checkout@v2.3.4 - - - name: Trigger RTDs build - if: github.ref == 'refs/heads/master' - uses: dfm/rtds-action@v1.0.2 - with: - webhook_url: ${{ secrets.RTDS_WEBHOOK_URL }} - webhook_token: ${{ secrets.RTDS_WEBHOOK_TOKEN }} - commit_ref: ${{ github.ref }} diff --git a/.github/workflows/pymake-gcc.yml b/.github/workflows/pymake-gcc.yml new file mode 100644 index 00000000..0bb20b19 --- /dev/null +++ b/.github/workflows/pymake-gcc.yml @@ -0,0 +1,176 @@ +name: pymake gcc build + +on: + schedule: + - cron: '0 3 * * 3' # run at 3 AM UTC every Wednesday + push: + branches: [ master ] + pull_request: + +jobs: + + pymakeCI-os-gcc: + name: pymake CI gcc on different OSs + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] + defaults: + run: + shell: bash + + steps: + - name: Checkout repo + uses: actions/checkout@v2.3.4 + + - name: Setup Graphviz + if: runner.os == 'Linux' + uses: ts-graphviz/setup-graphviz@v1 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Install python packages + run: | + .github/common/install-python.sh + + - name: Setup symbolic link to gfortran on Linux + if: runner.os == 'Linux' + run: | + sudo ln -fs /usr/bin/gfortran-10 /usr/local/bin/gfortran + sudo ln -fs /usr/bin/gcc-10 /usr/local/bin/gcc + sudo ln -fs /usr/bin/g++-10 /usr/local/bin/g++ + + - name: Setup symbolic link to gfortran on macOS + if: runner.os == 'macOS' + run: | + sudo ln -fs /usr/local/bin/gfortran-10 /usr/local/bin/gfortran + sudo ln -fs /usr/local/bin/gcc-10 /usr/local/bin/gcc + sudo ln -fs /usr/local/bin/g++-10 /usr/local/bin/g++ + + - name: Print GNU compiler versions + run: | + gfortran --version + gcc --version + g++ --version + + - name: Download examples for pytest runs + run: | + .github/common/download-examples.sh + + - name: Run pytest + run: | + pytest -v --dist=loadfile -n=auto -m regression --durations=0 --cov=pymake --cov-report=xml autotest/ + + - name: Print coverage report before upload + run: | + coverage report + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1.0.15 + with: + file: ./coverage.xml + + pymakeCI-gcc-prev: + name: pymake CI GCC 9 and 8 + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + gcc-version: [ 9, 8 ] + defaults: + run: + shell: bash + + steps: + - name: Checkout repo + uses: actions/checkout@v2.3.4 + + - name: Setup Graphviz + uses: ts-graphviz/setup-graphviz@v1 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Install python packages + run: | + .github/common/install-python.sh + + - name: Setup symbolic link to gfortran on Linux + run: | + sudo ln -fs /usr/bin/gfortran-${{ matrix.gcc-version }} /usr/local/bin/gfortran + sudo ln -fs /usr/bin/gcc-${{ matrix.gcc-version }} /usr/local/bin/gcc + sudo ln -fs /usr/bin/g++-${{ matrix.gcc-version }} /usr/local/bin/g++ + + - name: Print GNU compiler versions + run: | + gfortran --version + gcc --version + g++ --version + + - name: Download examples for pytest runs + run: | + .github/common/download-examples.sh + + - name: Run pytest + run: | + pytest -v --dist=loadfile -n=auto -m base --durations=0 --cov=pymake --cov-report=xml autotest/ + + - name: Print coverage report before upload + run: | + coverage report + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1.0.15 + with: + file: ./coverage.xml + + pymakeCI-python-prev: + name: pymake CI with previous python versions + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: [ 3.8, 3.7 ] + defaults: + run: + shell: bash + + steps: + - name: Checkout repo + uses: actions/checkout@v2.3.4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install python packages + run: | + .github/common/install-python.sh + + - name: Setup symbolic link to gfortran on Linux + if: runner.os == 'Linux' + run: | + sudo ln -fs /usr/bin/gfortran-10 /usr/local/bin/gfortran + sudo ln -fs /usr/bin/gcc-10 /usr/local/bin/gcc + sudo ln -fs /usr/bin/g++-10 /usr/local/bin/g++ + + - name: Print GNU compiler versions + run: | + gfortran --version + gcc --version + g++ --version + + - name: Download examples for pytest runs + run: | + .github/common/download-examples.sh + + - name: Run pytest + run: | + pytest -v --dist=loadfile -n=auto -m base --durations=0 diff --git a/.github/workflows/pymake-linting-install.yml b/.github/workflows/pymake-linting-install.yml new file mode 100644 index 00000000..7a41c9df --- /dev/null +++ b/.github/workflows/pymake-linting-install.yml @@ -0,0 +1,92 @@ +name: pymake linting/installation + +on: + schedule: + - cron: '0 3 * * 3' # run at 3 AM UTC every Wednesday + push: + branches: [ master ] + pull_request: + +jobs: + + + pymake_lint: + name: pymake linting + runs-on: ubuntu-latest + + if: github.repository_owner == 'modflowpy' + steps: + - name: Checkout repo + uses: actions/checkout@v2.3.4 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Setup Graphviz + uses: ts-graphviz/setup-graphviz@v1 + + - name: Install packages + run: | + pip install requests pydotplus appdirs numpy matplotlib + pip install https://github.com/modflowpy/flopy/zipball/develop + pip install pylint flake8 black + + - name: Run isort + run: | + echo "if isort check fails update isort using" + echo " pip install isort --upgrade" + echo "and run" + echo " isort ./flopy" + echo "and then commit the changes." + isort --verbose --check --diff ./pymake + + - name: Run black + run: | + echo "if black check fails update black using" + echo " pip install black --upgrade" + echo "and run" + echo " black ./flopy" + echo "and then commit the changes." + black --check --diff ./pymake + + - name: Run flake8 + run: flake8 --count --show-source ./pymake + + - name: Run pylint + run: pylint --jobs=0 --errors-only ./pymake + + pymake_setup: + name: standard installation + runs-on: ubuntu-latest + strategy: + fail-fast: false + defaults: + run: + shell: bash + + steps: + + # check out repo + - name: Checkout pymake repo + uses: actions/checkout@v2.3.4 + + - name: Setup Python + uses: actions/setup-python@v2.2.2 + with: + python-version: 3.9 + + - name: Upgrade pip and install wheel + run: | + python -m pip install --upgrade pip + pip install wheel + + - name: Base pymake installation + run: | + pip --verbose install . + + - name: Print pymake version + run: | + python -c "import pymake; print(pymake.__version__)" + diff --git a/.github/workflows/pymake-requests.yml b/.github/workflows/pymake-requests.yml new file mode 100644 index 00000000..640c6ba9 --- /dev/null +++ b/.github/workflows/pymake-requests.yml @@ -0,0 +1,43 @@ +name: pymake requests + +on: + schedule: + - cron: '0 3 * * 3' # run at 3 AM UTC every Wednesday + push: + branches: [ master ] + pull_request: + +jobs: + + pymakeCI-requests: + name: pymake CI requests + runs-on: ubuntu-latest + defaults: + run: + shell: bash + + steps: + - name: Checkout repo + uses: actions/checkout@v2.3.4 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Install python packages + run: | + .github/common/install-python.sh + + - name: Run pytest + run: | + pytest -v --dist=loadfile -n=auto -m requests --durations=0 --cov=pymake --cov-report=xml autotest/ + + - name: Print coverage report before upload + run: | + coverage report + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1.0.15 + with: + file: ./coverage.xml diff --git a/.github/workflows/pymake-rtd.yml b/.github/workflows/pymake-rtd.yml new file mode 100644 index 00000000..3def7697 --- /dev/null +++ b/.github/workflows/pymake-rtd.yml @@ -0,0 +1,27 @@ +name: pymake rtd + +on: + schedule: + - cron: '0 3 * * 3' # run at 3 AM UTC every Wednesday + push: + branches: [ master ] + pull_request: + +jobs: + + pymake_rtd: + name: pymake rtd + runs-on: ubuntu-latest + if: + github.event_name == 'push' + steps: + - name: Checkout repo + uses: actions/checkout@v2.3.4 + + - name: Trigger RTDs build + if: github.ref == 'refs/heads/master' + uses: dfm/rtds-action@v1.0.2 + with: + webhook_url: ${{ secrets.RTDS_WEBHOOK_URL }} + webhook_token: ${{ secrets.RTDS_WEBHOOK_TOKEN }} + commit_ref: ${{ github.ref }} diff --git a/pymake/pymake_base.py b/pymake/pymake_base.py index ff45a822..7e12de5e 100644 --- a/pymake/pymake_base.py +++ b/pymake/pymake_base.py @@ -1468,7 +1468,7 @@ def _create_makefile( f.write(line) # get path to executable - dpth = make_dir + dpth = os.path.dirname(target) if len(dpth) > 0: dpth = os.path.relpath(dpth, make_dir) else: @@ -1612,6 +1612,22 @@ def _create_makefile( line += f"\t\tFFLAGS ?= {' '.join(tfflags)}\n" line += "\t\tMODSWITCH = -module $(MODDIR)\n" line += "\tendif\n" + line += "\tifeq ($(FC), $(filter $(FC), ftn))\n" + tfflags = _get_fortran_flags( + target, + "ftn", + [], + debug, + double, + osname="linux", + sharedobject=sharedobject, + verbose=verbose, + ) + for idx, flag in enumerate(tfflags): + if "-D__" in flag: + tfflags[idx] = "$(OS_macro)" + line += f"\t\tFFLAGS ?= {' '.join(tfflags)}\n" + line += "\tendif\n" line += "endif\n\n" f.write(line) @@ -1795,6 +1811,21 @@ def _create_makefile( ) line += f"\t\tLDFLAGS ?= {' '.join(tsyslibs)}\n" line += "\tendif\n" + # ftn compiler + line += "\tifeq ($(FC), $(filter $(FC), ftn))\n" + _, tsyslibs = _get_linker_flags( + target, + "ftn", + "clang", + [], + srcfiles, + osname="linux", + sharedobject=sharedobject, + verbose=verbose, + ) + line += f"\t\tLDFLAGS ?= {' '.join(tsyslibs)}\n" + line += "\tendif\n" + line += "endif\n\n" f.write(line) diff --git a/pymake/utils/_compiler_switches.py b/pymake/utils/_compiler_switches.py index 8af00c90..ad96ae92 100644 --- a/pymake/utils/_compiler_switches.py +++ b/pymake/utils/_compiler_switches.py @@ -332,6 +332,20 @@ def _get_fortran_flags( flags += ["no-heap-arrays", "fpe0", "traceback"] if double: flags += ["r8", "autodouble"] + elif fc in ("ftn",): + if osname in ("win32", "darwin"): + raise ValueError(f"ftn compiler not supported on {osname}") + else: + if sharedobject: + flags.append("f PIC") + else: + if "f PIC" in flags: + flags.remove("f PIC") + if debug: + flags += ["g"] + flags += ["h noheap_allocate"] + if double: + flags += ["s default64"] # process passed fortran flags - check for flags with a space between # the flag and a setting @@ -613,6 +627,7 @@ def _get_linker_flags( if fc in ( "ifort", "mpiifort", + "ftn", ): gnu_compiler = False else: @@ -621,6 +636,7 @@ def _get_linker_flags( "mpiicc", "icl", "cl", + "clang", ): gnu_compiler = False if osname == "win32": @@ -789,6 +805,7 @@ def _set_fflags(target, fc="gfortran", argv=True, osname=None, verbose=False): ): if fc == "gfortran": fflags += [ + "-fall-intrinsics", "-Wtabs", "-Wline-truncation", "-Wunused-label",