Skip to content

Commit

Permalink
Will APPROVE THIS PR (#80)
Browse files Browse the repository at this point in the history
* Random changes

* failing ci runs

* Update setup_package.py

* changelog

* refactor of brew

* add more CI
  • Loading branch information
nabobalis authored Jul 31, 2024
1 parent ff5d610 commit 3e617cc
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 26 deletions.
74 changes: 67 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ jobs:
brew:
- fftw
envs: |
# Mac Arm
#- macos: py311
# runs-on: macos-latest
# Mac Intel
- macos: py311
runs-on: macos-12
Expand Down Expand Up @@ -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]
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
0.3.1 (2024-07-31)
==================

Bugfixes
--------

- Tried to fix builds on conda-forge. (`#80 <https://github.com/sunpy/pyflct/pull/80>`__)

0.3.0 (2024-07-23)
==================

Expand Down
2 changes: 0 additions & 2 deletions pyflct-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ dependencies:
- packaging
- pip
- pytest
- pytest-cov
- python_abi
- setuptools
- setuptools-scm
35 changes: 23 additions & 12 deletions pyflct/setup_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python

import os
from itertools import chain

from setuptools import setup # isort:skip
Expand Down Expand Up @@ -30,6 +29,5 @@

setup(
extras_require=extras,
use_scm_version={"write_to": os.path.join("pyflct", "_version.py")},
ext_modules=get_extensions(),
)

0 comments on commit 3e617cc

Please sign in to comment.