diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index 5ba0043..5f86e1f 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -42,7 +42,7 @@ jobs: - name: Setup Fortran compiler for Windows if: ${{ matrix.os == 'Windows' }} run: | - echo "[build]`ncompiler=mingw32" | Out-File -Encoding ASCII ~/pydistutils.cfg + echo "[build]`ncompiler=flang" | Out-File -Encoding ASCII ~/pydistutils.cfg - name: Build and install run: | python -m pip install --no-deps . diff --git a/.github/workflows/conda-build.yaml b/.github/workflows/conda-build.yaml index 34c95db..c7af295 100644 --- a/.github/workflows/conda-build.yaml +++ b/.github/workflows/conda-build.yaml @@ -1,6 +1,13 @@ name: Conda-build -on: push +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + schedule: + - cron: '35 4 * * TUE' # Tuesday at 04:35 UTC” jobs: @@ -13,17 +20,14 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8"] + python-version: ["3.12"] os: [Ubuntu, macOS, Windows] include: - os: Ubuntu - environment-file: ci/requirements-linux.yaml shell: bash -l {0} - os: macOS - environment-file: ci/requirements-macos.yaml shell: bash -l {0} - os: Windows - environment-file: ci/requirements-windows.yaml shell: powershell steps: @@ -33,13 +37,9 @@ jobs: miniconda-version: "latest" python-version: ${{ matrix.python-version }} channels: conda-forge - - name: Setup Fortran compiler for Windows - if: ${{ matrix.os == 'Windows' }} - run: | - echo "[build]`ncompiler=mingw32" | Out-File -Encoding ASCII ~/pydistutils.cfg - name: Install conda-build run: | - conda install conda-build + conda install -c conda-forge conda-build - name: Run conda-build run: | conda-build -c conda-forge conda-recipe diff --git a/conda-recipe/bld.bat b/conda-recipe/bld.bat deleted file mode 100644 index 21360ac..0000000 --- a/conda-recipe/bld.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo on - -dir %RECIPE_DIR% - -echo %LIB% - -"%PYTHON%" -m pip install . --no-deps -vv - -if errorlevel 1 exit 1 diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh deleted file mode 100644 index 15eee86..0000000 --- a/conda-recipe/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -$PYTHON -m pip install . --no-deps -vv diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 824953f..5699dad 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -1,5 +1,5 @@ {% set name = "minimalf2py" %} -{% set version = "0.1" %} +{% set version = "0.2" %} package: name: {{ name|lower }} @@ -9,24 +9,35 @@ source: path: ../ build: - skip: True # [win and py<30] - number: 0 + script: {{ PYTHON }} -m pip install . --no-deps -vv + number: 1 requirements: build: - - {{ compiler('fortran') }} - - {{ compiler('m2w64_fortran') }} # [win] + - ninja + - pkg-config # [unix] + - clang # [win] + # use flang as fortran compiler on windows (uses clang driver) + - flang <18 # [win] + # use llvm linker for both of the above + - lld # [win] - {{ compiler('c') }} + - {{ stdlib("c") }} + - {{ compiler('fortran') }} # [unix] host: - - libpython # [win] + - compiler-rt # [win] + - meson-python + # limit this for now because incompatible changes + # have accumulated in meson_dev channel for 1.4+ + - meson <1.4 # [win] - python - - setuptools - - pip + - python-build - numpy + - pip + - packaging >=20.0 run: - python - - {{ pin_compatible('numpy') }} - #- scipy # uncommenting this line causes conda-build to hang forever on Mac OS + - numpy test: requires: @@ -34,7 +45,7 @@ test: imports: - minimalf2py commands: - - pytest -v --pyargs minimalf2py.tests + - pytest -v --pyargs minimalf2py extra: recipe-maintainers: diff --git a/environment.yml b/environment.yml index 5e0d7c9..26b600e 100644 --- a/environment.yml +++ b/environment.yml @@ -6,4 +6,4 @@ dependencies: - numpy - fortran-compiler - pytest - - meson-python \ No newline at end of file + - meson-python diff --git a/minimalf2py/setup.py b/minimalf2py/setup.py new file mode 100644 index 0000000..1eae03e --- /dev/null +++ b/minimalf2py/setup.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python +from __future__ import division, print_function + +def configuration(parent_package='',top_path=None): + global config + from numpy.distutils.misc_util import Configuration + # from numpy.distutils.fcompiler import get_default_fcompiler, CompilerNotFound + from numpy.distutils.fcompiler import CompilerNotFound + + compiler = get_default_fcompiler() + # set some fortran compiler-dependent flags + f90flags = [] + if compiler == 'gnu95': + f90flags.append('-fdefault-real-8') + elif compiler == 'intel' or compiler == 'intelem': + f90flags.append('-132') + f90flags.append('-r8') + # Set aggressive optimization level + f90flags.append('-O3') + # Suppress all compiler warnings (avoid huge CI log files) + f90flags.append('-w') + config = Configuration('minimalf2py', + parent_name=parent_package, + top_path=top_path) + config.add_subpackage('tests') + config.add_extension(name='add', + sources=['add.f', 'add.pyf'], + extra_f90_compile_args=f90flags,) + return config + +def get_default_fcompiler(osname=None, platform=None, requiref90=False, + c_compiler=None): + """Determine the default Fortran compiler to use for the given + platform. + This version is copied from numpy.distutils.fcompiler.__init__.py + but with a hack to prioritize flang""" + from numpy.distutils.fcompiler import available_fcompilers_for_platform, _find_existing_fcompiler + from numpy.distutils import log + + matching_compiler_types = available_fcompilers_for_platform(osname, + platform) + # Move flang to front of list so it has top priority + if 'flang' in matching_compiler_types: + matching_compiler_types.insert(0, 'flang') + log.info("get_default_fcompiler: matching types: '%s'", + matching_compiler_types) + compiler_type = _find_existing_fcompiler(matching_compiler_types, + osname=osname, + platform=platform, + requiref90=requiref90, + c_compiler=c_compiler) + return compiler_type + +if __name__ == '__main__': + print('This is the wrong setup.py file to run')