Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/conda-build.yaml
Original file line number Diff line number Diff line change
@@ -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:

Expand All @@ -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:
Expand All @@ -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
9 changes: 0 additions & 9 deletions conda-recipe/bld.bat

This file was deleted.

3 changes: 0 additions & 3 deletions conda-recipe/build.sh

This file was deleted.

33 changes: 22 additions & 11 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "minimalf2py" %}
{% set version = "0.1" %}
{% set version = "0.2" %}

package:
name: {{ name|lower }}
Expand All @@ -9,32 +9,43 @@ 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:
- pytest
imports:
- minimalf2py
commands:
- pytest -v --pyargs minimalf2py.tests
- pytest -v --pyargs minimalf2py

extra:
recipe-maintainers:
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ dependencies:
- numpy
- fortran-compiler
- pytest
- meson-python
- meson-python
55 changes: 55 additions & 0 deletions minimalf2py/setup.py
Original file line number Diff line number Diff line change
@@ -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')
Loading