diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8dd960..dcb035d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,9 +44,6 @@ jobs: brew: - fftw envs: | - # Mac Arm - #- macos: py311 - # runs-on: macos-latest # Mac Intel - macos: py311 runs-on: macos-12 @@ -74,11 +71,74 @@ jobs: run: | conda list cd /tmp - pytest -vvv -r a --pyargs pyflct --cov-report=xml --cov=pyflct --cov-config=$GITHUB_WORKSPACE/setup.cfg $GITHUB_WORKSPACE/docs - - uses: codecov/codecov-action@v4 + pytest -vvv -r a --pyargs pyflct + + # This checks that the package can be installed and run on a Mac + # without using brew + conda-mac: + needs: [core] + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + lfs: true + - uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: pyflct-test + environment-file: pyflct-env.yml + python-version: 3.12 + - name: Install pyflct + shell: bash -el {0} + run: | + pip install --no-deps --no-build-isolation . + - name: Run tests + shell: bash -el {0} + run: | + conda list + cd /tmp + pytest -vvv -r a --pyargs pyflct + + failing_mac_arm: + needs: [core] + uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main + with: + submodules: false + coverage: codecov + toxdeps: tox-pypi-filter + libraries: | + brew: + - fftw + envs: | + # Mac Arm + - macos: py312 + runs-on: macos-latest + # Linux Arm + # TODO: Workout how to add + + conda-windows: + needs: [core] + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./coverage.xml + fetch-depth: 0 + lfs: true + - uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: pyflct-test + environment-file: pyflct-env.yml + python-version: 3.12 + - name: Install pyflct + shell: bash -el {0} + run: | + pip install --no-deps --no-build-isolation . + - name: Run tests + shell: bash -el {0} + run: | + conda list + cd /tmp + pytest -vvv -r a --pyargs pyflct docs: needs: [core] diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6d94c4d..bd159aa 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,11 @@ +0.3.1 (2024-07-31) +================== + +Bugfixes +-------- + +- Tried to fix builds on conda-forge. (`#80 `__) + 0.3.0 (2024-07-23) ================== diff --git a/pyflct-env.yml b/pyflct-env.yml index f7aff56..4c92944 100644 --- a/pyflct-env.yml +++ b/pyflct-env.yml @@ -8,7 +8,5 @@ dependencies: - packaging - pip - pytest - - pytest-cov - - python_abi - setuptools - setuptools-scm diff --git a/pyflct/setup_package.py b/pyflct/setup_package.py index 9783d93..50a1377 100644 --- a/pyflct/setup_package.py +++ b/pyflct/setup_package.py @@ -11,30 +11,41 @@ ROOT = os.path.dirname(__file__) +BREW_PATHS = ["brew", "/usr/local/conda_mangled/sbin/brew"] + def get_extensions(): cfg = defaultdict(list) cfg["include_dirs"].append(np.get_include()) - cfg["include_dirs"].append(os.path.join(sys.prefix, "include")) cfg["include_dirs"].append(os.path.join("cextern")) cfg["sources"].extend(sorted(glob(os.path.join("cextern", "*.c")))) cfg["sources"].extend(sorted(glob(os.path.join(ROOT, "*.c")))) cfg["sources"].extend(sorted(glob(os.path.join(ROOT, "flct.pyx")))) - + cfg["libraries"].append("fftw3") + # Conda paths + cfg["include_dirs"].append(os.path.join(sys.base_prefix, "Library", "include")) + cfg["library_dirs"].append(os.path.join(sys.base_prefix, "Library", "lib")) if get_compiler().lower() == "msvc": - # Anaconda paths - cfg["include_dirs"].append(os.path.join(sys.prefix, "Library", "include")) - cfg["library_dirs"].append(os.path.join(sys.prefix, "Library", "lib")) + cfg["extra_compile_args"].extend(["/w"]) else: cfg["libraries"].append("m") # We assume we have brew installed on Mac OS to provide FFTW3 + # If not, we add system paths as well as the conda-forge paths + # hoping that the user has installed FFTW3 there. if platform.system().lower() == "darwin": - brew_path = ( - subprocess.run(["brew", "--prefix"], stdout=subprocess.PIPE).stdout.decode("utf-8").replace("\n", "") - ) - cfg["include_dirs"].append(f"{brew_path}/include") - cfg["libraries"].append("fftw3") - cfg["include_dirs"].append("/usr/include") - cfg["include_dirs"].append("/usr/local/include") + for brew_path in BREW_PATHS: + try: + brew_path = ( + subprocess.run([brew_path, "--prefix"], stdout=subprocess.PIPE) + .stdout.decode("utf-8") + .replace("\n", "") + ) + cfg["include_dirs"].append(f"{brew_path}/include") + break + except FileNotFoundError: + continue + # System paths + cfg["include_dirs"].append(os.path.join(sys.prefix, "include")) + cfg["include_dirs"].append(os.path.join(sys.prefix, "local", "include")) cfg["extra_compile_args"].extend(["-O3", "-w", "-fomit-frame-pointer", "-fPIC"]) return [Extension("pyflct._flct", **cfg)] diff --git a/pyproject.toml b/pyproject.toml index 4ac817b..d7ad376 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,9 @@ requires = [ ] build-backend = 'setuptools.build_meta' +[tool.setuptools_scm] +write_to = "pyflct/_version.py" + [tool.cibuildwheel] manylinux-x86_64-image = "manylinux_2_28" @@ -17,7 +20,7 @@ before-all = "yum -y install fftw-devel; git clean -xfd -e dist" [tool.cibuildwheel.macos] before-all = "brew install fftw; git clean -xfd -e dist" -environment = {MACOSX_DEPLOYMENT_TARGET=12.0} +environment = { MACOSX_DEPLOYMENT_TARGET="12.0" } [tool.black] line-length = 120 diff --git a/setup.cfg b/setup.cfg index 32b388d..52bcf85 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,8 +45,6 @@ docs = sphinx-changelog sphinx-gallery sunpy-sphinx-theme - # Remove next line when fixed in towncrier; see https://github.com/twisted/towncrier/issues/528 - importlib-resources<6 [options.packages.find] exclude = pyflct._dev diff --git a/setup.py b/setup.py index 1ae1435..3700f84 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import os from itertools import chain from setuptools import setup # isort:skip @@ -30,6 +29,5 @@ setup( extras_require=extras, - use_scm_version={"write_to": os.path.join("pyflct", "_version.py")}, ext_modules=get_extensions(), )