Skip to content

Commit

Permalink
installation code update; wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
gplepage committed Oct 13, 2023
1 parent 7e86c84 commit 0d662bc
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 19 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on: [workflow_dispatch]
# push:
# branches: [ "master" ]
# pull_request:
# branches: [ "master" ]

jobs:
build:

runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install pytest
python -m pip install .
# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
39 changes: 39 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build wheels

on: [workflow_dispatch]

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
# matrix:
# os: [ubuntu-20.04]
matrix:
os: [ubuntu-22.04, windows-2022, macos-11]
# see https://github.com/actions/runner-images
steps:
- uses: actions/checkout@v4

# Used to host cibuildwheel
- uses: actions/setup-python@v3

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.16.2

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
# to supply options, put them in 'env', like:
env:
CIBW_SKIP: pp* cp36-* cp37-* cp38-*
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_ARCHS_WINDOWS: auto64
CIBW_ARCHS_LINUX: auto64
# CIBW_ARCHS_LINUX: x86_64 aarch64
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: "pytest {project}/tests"
CIBW_TEST_SKIP: "*_arm64 *_universal2:arm64"

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ outputfile.p
README.html
multi/
src/lsqfit/_gsl.c
src/lsqfit/_utilities.c
src/lsqfit/_utilities.c
gsl
8 changes: 5 additions & 3 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Version 13.0.1
=================
Version 13.0.3 2023-10-13
===========================
- New installation code so that it works on Python3.11 even when numpy
is not installed.
is not installed, and on systems with old versions of numpy.

- Adds Python wheels to PyPi distribution.


Version 13 2022-11-01
Expand Down
Binary file modified doc/html/.doctrees/environment.pickle
Binary file not shown.
Binary file modified doc/html/.doctrees/lsqfit.doctree
Binary file not shown.
Binary file modified doc/html/.doctrees/scipy.doctree
Binary file not shown.
6 changes: 3 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ install install-sys :
$(PIP) install . --no-cache-dir

update:
rm src/lsqfit/*.c
rm -rf src/lsqfit/*.c
make uninstall install

rebuild:
rm src/lsqfit/*.c
rm -rf src/lsqfit/*.c
make update

uninstall : # mostly works (may leave some empty directories)
Expand Down Expand Up @@ -72,7 +72,7 @@ run run-examples:
$(MAKE) -C examples PYTHON=$(PYTHON) run

upload-twine:
twine upload dist/lsqfit-$(VERSION).tar.gz
twine upload dist/lsqfit-$(VERSION)*

upload-git:
echo "version $(VERSION)"
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ requires = [
"wheel",

# see https://github.com/scipy/oldest-supported-numpy/tree/main
"oldest-supported-numpy>=2023.8.3; python_version>='3.7'",
"oldest-supported-numpy>=2023.8.3; python_version>='3.8'",
"numpy==1.16.6; python_version=='3.7'",
"numpy; python_version<'3.7'",

"Cython>=0.29.33",
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = lsqfit
version = 13.0.2
version = 13.0.3
author = G. Peter Lepage
author_email = g.p.lepage@cornell.edu
license = GPLv3
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from setuptools import setup, Extension
from Cython.Build import cythonize
import numpy
import subprocess
import sys
Expand Down Expand Up @@ -48,11 +49,11 @@
)

try:
setup(ext_modules=ext_modules)
setup(ext_modules=cythonize(ext_modules))
except:
print("*** can't find gsl; re-install without it")
if len(ext_modules) > 1:
setup(ext_modules=ext_modules[:1])
setup(ext_modules=cythonize(ext_modules[:1]))
else:
raise RuntimeError("can't find gsl or scipy")

16 changes: 8 additions & 8 deletions src/lsqfit/_gsl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ cdef extern from "gsl/gsl_multifit_nlinear.h":
GSL_MULTIFIT_NLINEAR_CTRDIFF

ctypedef struct gsl_multifit_nlinear_fdf:
int (* f) (const gsl_vector * x, void * params, gsl_vector * f)
int (* df) (const gsl_vector * x, void * params, gsl_matrix * df)
int (* f) (const gsl_vector * x, void * params, gsl_vector * f) noexcept
int (* df) (const gsl_vector * x, void * params, gsl_matrix * df) noexcept
int (* fvv) (const gsl_vector * x, const gsl_vector * v, void * params,
gsl_vector * fvv)
gsl_vector * fvv) noexcept
size_t n # number of functions
size_t p # number of independent variables
void * params # user parameters
Expand Down Expand Up @@ -349,7 +349,7 @@ cdef extern from "gsl/gsl_multifit_nlin.h":
# for v1 of gsl multifit
cdef extern from "gsl/gsl_multimin.h":
ctypedef struct gsl_multimin_function:
double (*f) (gsl_vector* x, void* p)
double (*f) (gsl_vector* x, void* p) noexcept
int n
void * params

Expand Down Expand Up @@ -726,7 +726,7 @@ class gsl_multifit(object):


# wrappers for multifit's python function #
cdef int _c_f(gsl_vector* vx, void* params, gsl_vector* vf):
cdef int _c_f(gsl_vector* vx, void* params, gsl_vector* vf) noexcept:
global _p_f, _pyerr
cdef numpy.ndarray f
# can't do numpy.ndarray[object,ndim=1] because might be numbers
Expand All @@ -741,7 +741,7 @@ cdef int _c_f(gsl_vector* vx, void* params, gsl_vector* vf):
_pyerr = sys.exc_info()
return GSL_EBADFUNC

cdef int _c_df(gsl_vector* vx, void* params, gsl_matrix* mJ):
cdef int _c_df(gsl_vector* vx, void* params, gsl_matrix* mJ) noexcept:
global _p_f, _pyerr, _valder
cdef gvar.GVar fi
cdef gvar.svec fi_d
Expand All @@ -761,7 +761,7 @@ cdef int _c_df(gsl_vector* vx, void* params, gsl_matrix* mJ):
_pyerr = sys.exc_info()
return GSL_EBADFUNC

cdef int _c_fdf(gsl_vector* vx, void* params, gsl_vector* vf, gsl_matrix* mJ):
cdef int _c_fdf(gsl_vector* vx, void* params, gsl_vector* vf, gsl_matrix* mJ) noexcept:
global _p_f, _pyerr, _valder
cdef gvar.GVar fi
cdef gvar.svec f_i_d
Expand Down Expand Up @@ -1096,7 +1096,7 @@ class gsl_multiminex(object):
return str(self.x)

# wrapper for multiminex's python function #
cdef double _c_fs(gsl_vector* vx, void* p):
cdef double _c_fs(gsl_vector* vx, void* p) noexcept:
global _p_fs, _pyerr
if _pyerr is not None:
return GSL_NAN
Expand Down

0 comments on commit 0d662bc

Please sign in to comment.