Skip to content

Commit

Permalink
drop 39 (#74)
Browse files Browse the repository at this point in the history
* drop 39

* changelog

* Package updates

* Tweaks for wheel builds

* Another changelog
  • Loading branch information
nabobalis authored Jul 24, 2024
1 parent 20f87b8 commit c16a61e
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 90 deletions.
28 changes: 17 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,19 @@ jobs:
core:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
default_python: "3.11"
submodules: false
coverage: codecov
toxdeps: tox-pypi-filter
libraries: |
apt:
- libfftw3-dev
envs: |
- linux: py311
- linux: py312
tests:
needs: [core]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
default_python: "3.11"
submodules: false
coverage: codecov
toxdeps: tox-pypi-filter
Expand All @@ -46,7 +44,12 @@ jobs:
brew:
- fftw
envs: |
- macos: py39
# Mac Arm
#- macos: py311
# runs-on: macos-latest
# Mac Intel
- macos: py311
runs-on: macos-12
- linux: py310
conda-linux:
Expand All @@ -61,7 +64,7 @@ jobs:
with:
activate-environment: pyflct-test
environment-file: pyflct-env.yml
python-version: 3.11
python-version: 3.12
- name: Install pyflct
shell: bash -el {0}
run: |
Expand All @@ -81,7 +84,7 @@ jobs:
needs: [core]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
default_python: "3.11"
default_python: "3.12"
submodules: false
pytest: false
toxdeps: tox-pypi-filter
Expand All @@ -107,16 +110,19 @@ jobs:
needs: [tests]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish.yml@main
with:
test_extras: "dev"
test_extras: "test"
test_command: 'pytest -p no:warnings --doctest-rst -m "not mpl_image_compare" --pyargs pyflct'
submodules: false
libraries: libfftw3-dev
targets: |
- cp39-manylinux*_x86_64
- cp39-macosx_x86_64
- cp310-manylinux*_x86_64
#- cp310-macosx_arm64
- cp310-macosx_x86_64
- cp311-manylinux*_x86_64
- cp310-manylinux_x86_64
#- cp311-macosx_arm64
- cp311-macosx_x86_64
- cp311-manylinux_x86_64
#- cp312-macosx_arm64
- cp312-macosx_x86_64
- cp312-manylinux_x86_64
secrets:
pypi_token: ${{ secrets.pypi_token }}
2 changes: 2 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ build:
tools:
python: "mambaforge-4.10"
jobs:
post_checkout:
- git fetch --unshallow || true
pre_install:
- git update-index --assume-unchanged .rtd-environment.yml docs/conf.py

Expand Down
4 changes: 2 additions & 2 deletions .rtd-environment.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: pyflct
name: pyflct_rtd
channels:
- conda-forge
dependencies:
- graphviz!=2.42.*
- pip
- python=3.9
- python=3.12
- fftw
- gcc_linux-64
- pip:
Expand Down
4 changes: 4 additions & 0 deletions changelog/74.breaking.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Update to wheels:

Linux base goes from manylinux2014 to manylinux_2_28
macOS base goes from 10.9 to 12.0
1 change: 1 addition & 0 deletions changelog/74.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dropped Python 3.9 support.
1 change: 1 addition & 0 deletions changelog/74.feature.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Build with numpy 2.0.0 as the base.
1 change: 1 addition & 0 deletions changelog/74.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added Python 3.12 wheels.
34 changes: 5 additions & 29 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,12 @@
"""
Configuration file for the Sphinx documentation builder.
isort:skip_file
"""

# flake8: NOQA: E402

# -- stdlib imports ------------------------------------------------------------
import os
import sys
import datetime
from pkg_resources import get_distribution
from packaging.version import Version

# -- Check for dependencies ----------------------------------------------------

doc_requires = get_distribution("pyflct").requires(extras=("docs",))
missing_requirements = []
for requirement in doc_requires:
try:
get_distribution(requirement)
except Exception as e:
missing_requirements.append(requirement.name)
if missing_requirements:
print(
f"The {' '.join(missing_requirements)} package(s) could not be found and "
"is needed to build the documentation, please install the 'docs' requirements."
)
sys.exit(1)

# -- Read the Docs Specific Configuration --------------------------------------

# This needs to be done before sunpy is imported
Expand All @@ -41,7 +19,7 @@
os.environ["HIDE_PARFIVE_PROGESS"] = "True"

# -- Non stdlib imports --------------------------------------------------------
from pyflct import __version__ # NOQA
from pyflct import __version__

# -- Project information -------------------------------------------------------
project = "pyflct"
Expand Down Expand Up @@ -168,8 +146,9 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "sunpy"

from sunpy_sphinx_theme.conf import * # NOQA
from sunpy_sphinx_theme import PNG_ICON

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand All @@ -189,16 +168,13 @@
]

# -- Sphinx Gallery ------------------------------------------------------------
from sphinx_gallery.sorting import ExampleTitleSortKey

sphinx_gallery_conf = {
"backreferences_dir": os.path.join("generated", "modules"),
"filename_pattern": "^((?!skip_).)*$",
"examples_dirs": os.path.join("..", "examples"),
"within_subsection_order": ExampleTitleSortKey,
"within_subsection_order": "ExampleTitleSortKey",
"gallery_dirs": os.path.join("generated", "gallery"),
# Comes from the theme.
"default_thumb_file": png_icon,
"default_thumb_file": PNG_ICON,
"abort_on_example_error": False,
"plot_gallery": "True",
"remove_config_comments": True,
Expand Down
6 changes: 4 additions & 2 deletions pyflct/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
from .flct import * # NOQA
from .version import version as __version__
from pyflct.flct import flct
from pyflct.version import version as __version__

__all__ = ["flct", "__version__"]
7 changes: 7 additions & 0 deletions pyflct/_dev/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
This package contains utilities that are only used when developing drms in a
copy of the source repository.
These files are not installed, and should not be assumed to exist at
runtime.
"""
2 changes: 1 addition & 1 deletion pyflct/flct.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from .utils import column_row_of_two
from pyflct.utils import column_row_of_two

try:
from pyflct import _flct as _pyflct
Expand Down
31 changes: 0 additions & 31 deletions pyflct/flct.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,76 +32,56 @@ cdef extern from "numpy/arrayobject.h":
void PyArray_ENABLEFLAGS(np.ndarray arr, int flags)

def read_two_images(file_name, transpose=0):

cdef int nx
cdef int ny
cdef double *arr
cdef double *barr
file_name = file_name.encode('utf-8')

ier = read2images(file_name, &nx, &ny, &arr, &barr, transpose)

cdef view.array cy_arr = <double[:nx, :ny]> arr
cdef view.array cy_barr = <double[:nx, :ny]> barr

a = np.array(cy_arr)
b = np.array(cy_barr)

return (ier, a, b)

def read_three_images(file_name, transpose=0):

cdef int nx
cdef int ny
cdef double *arr
cdef double *barr
cdef double *carr
file_name = file_name.encode('utf-8')

ier = read3images(file_name, &nx, &ny, &arr, &barr, &carr,transpose)

cdef view.array cy_arr = <double[:nx, :ny]> arr
cdef view.array cy_barr = <double[:nx, :ny]> barr
cdef view.array cy_carr = <double[:nx, :ny]> carr

a = np.array(cy_arr)
b = np.array(cy_barr)
c = np.array(cy_carr)

return (ier, a, b, c)


def write_two_images(file_name, arr, barr, transpose=0):

nx, ny = arr.shape

arr = arr.reshape((-1))
barr = barr.reshape((-1))

cdef np.ndarray[np.double_t, ndim=1, mode="c"] arr_c = np.ascontiguousarray(arr, dtype = np.double)
cdef np.ndarray[np.double_t, ndim=1, mode="c"] barr_c = np.ascontiguousarray(barr, dtype = np.double)

file_name = file_name.encode('utf-8')
ier = write2images(file_name, <double *> arr_c.data, <double *> barr_c.data, nx, ny, transpose)

return ier


def write_three_images(file_name, arr, barr, carr, transpose=0):

nx, ny = arr.shape

arr = arr.reshape((-1))
barr = barr.reshape((-1))
carr = carr.reshape((-1))

cdef np.ndarray[np.double_t, ndim=1, mode="c"] arr_c = np.ascontiguousarray(arr, dtype = np.double)
cdef np.ndarray[np.double_t, ndim=1, mode="c"] barr_c = np.ascontiguousarray(barr, dtype = np.double)
cdef np.ndarray[np.double_t, ndim=1, mode="c"] carr_c = np.ascontiguousarray(carr, dtype = np.double)

file_name = file_name.encode('utf-8')
ier = write3images(file_name, <double *> arr_c.data, <double *> barr_c.data, <double *> carr_c.data, nx, ny, transpose)

return ier

def pyflct_plate_carree(transpose, f1, f2, nxorig, nyorig, deltat, deltas, sigma,
Expand All @@ -113,7 +93,6 @@ def pyflct_plate_carree(transpose, f1, f2, nxorig, nyorig, deltat, deltas, sigma
cdef np.ndarray[np.double_t, ndim=1, mode="c"] vx_c = np.ascontiguousarray(vx, dtype = np.double)
cdef np.ndarray[np.double_t, ndim=1, mode="c"] vy_c = np.ascontiguousarray(vy, dtype = np.double)
cdef np.ndarray[np.double_t, ndim=1, mode="c"] vm_c = np.ascontiguousarray(vm, dtype = np.double)

ierflct = flct_pc(transpose, <double *> f1_c.data, <double *> f2_c.data, nxorig, nyorig, deltat,
deltas, sigma, <double *> vx_c.data, <double *> vy_c.data, <double *> vm_c.data,
thresh, absflag, filter, kr, skip, poffset, qoffset, interpolate, latmin, latmax,
Expand All @@ -131,34 +110,24 @@ def pyflct(transpose, f1, f2, nxorig, nyorig, deltat, deltas, sigma,
cdef np.ndarray[np.double_t, ndim=1, mode="c"] vx_c = np.ascontiguousarray(vx, dtype = np.double)
cdef np.ndarray[np.double_t, ndim=1, mode="c"] vy_c = np.ascontiguousarray(vy, dtype = np.double)
cdef np.ndarray[np.double_t, ndim=1, mode="c"] vm_c = np.ascontiguousarray(vm, dtype = np.double)

ierflct = flct(transpose, <double *> f1_c.data, <double *> f2_c.data, nxorig, nyorig, deltat,
deltas, sigma, <double *> vx_c.data, <double *> vy_c.data, <double *> vm_c.data,
thresh, absflag, filter, kr, skip, poffset, qoffset, interpolate, biascor, verbose)

return ierflct, vx_c, vy_c, vm_c

# This is created to deal with the arrays which were first read by IDL
def swap_order_two(arr, barr):

ier = write_two_images("temp.dat", arr, barr, 0)

ier, cy_arr, cy_barr = read_two_images("temp.dat", transpose=1)
os.remove("temp.dat")

a = np.array(cy_arr)
b = np.array(cy_barr)

return a, b


def swap_order_three(arr, barr, carr):

temp = np.zeros_like(arr)

arr, barr = swap_order_two(arr,barr)
carr, temp = swap_order_two(carr, temp)

del temp

return arr, barr, carr
18 changes: 13 additions & 5 deletions pyflct/setup_package.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import sys
import platform
import subprocess
from glob import glob
from collections import defaultdict
from distutils.core import Extension
Expand All @@ -18,15 +20,21 @@ def get_extensions():
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")

if get_compiler() == "msvc":
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"))
else:
cfg["libraries"].append("m")
cfg["include_dirs"].append("/usr/include/")
cfg["extra_compile_args"].extend(["-O3", "-Wall", "-fomit-frame-pointer", "-fPIC"])

# We assume we have brew installed on Mac OS to provide FFTW3
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")
cfg["extra_compile_args"].extend(["-O3", "-w", "-fomit-frame-pointer", "-fPIC"])
return [Extension("pyflct._flct", **cfg)]
1 change: 0 additions & 1 deletion pyflct/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

warnings.warn(f'could not determine {__name__.split(".")[0]} package version; this indicates a broken installation')
del warnings

version = "0.0.0"

from packaging.version import parse as _parse
Expand Down
Loading

0 comments on commit c16a61e

Please sign in to comment.