Skip to content

Commit

Permalink
Merge pull request #58 from alexfikl/update-build-system
Browse files Browse the repository at this point in the history
Use pyproject.toml and Github Actions
  • Loading branch information
Wrzlprmft authored Jan 1, 2025
2 parents cc2641d + bd18cfa commit 237281d
Show file tree
Hide file tree
Showing 7 changed files with 222 additions and 39 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI

on:
push:
branches: [ 'master' ]
pull_request:
branches: [ 'master' ]
schedule:
# at 12:00 (UTC) on the first day of the month
- cron: '0 12 1 * *'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
name: Unittest (${{ matrix.os }}-${{ matrix.compiler }}-py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
compiler: [gcc, clang]
python-version: ['3.10', '3.11', '3.x']
fail-fast: false

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install System Dependencies
if: matrix.os == 'ubuntu-latest' && matrix.compiler == 'clang'
run: |
sudo apt-get install libomp5 libomp-dev
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip setuptools setuptools-scm wheel
python -m pip install --upgrade numpy scipy jitcxde_common chspy sympy
- name: Run Tests
env:
CC: ${{ matrix.compiler }}
run: |
python -m pip install --verbose --no-build-isolation --editable .
python -m unittest discover -b -f -v tests
python tests/compare_C_and_Python_core.py 30
python tests/compare_C_and_Python_core_2.py 30
109 changes: 109 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
*~

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
version.py
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

tests/*_new.dat
56 changes: 56 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=64",
"setuptools-scm>=7",
]

[project]
name = "jitcdde"
dynamic = ["version"]
description = "Just-in-Time Compilation for Delay Differential Equations"
readme = "README.rst"
license = { text = "BSD-3-Clause" }
authors = [
{ name = "Gerrit Ansmann", email = "gansmann@uni-bonn.de" },
]
requires-python = ">=3.10"
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: BSD License",
"Operating System :: POSIX",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"Topic :: Scientific/Engineering :: Mathematics",
]
dependencies = [
"jitcxde_common>=1.3",
"chspy>=1.1",
"numpy",
"symengine>=0.3.1.dev0",
]

[project.optional-dependencies]
test = [
# NOTE: required for expr.simplify (symengine calls sympy for that)
# https://github.com/symengine/symengine.py/issues/405
"sympy",
]

[project.urls]
Documentation = "https://jitcdde.readthedocs.io"
Homepage = "http://github.com/neurophysik/jitcdde"

[tool.setuptools.packages.find]
include = [
"jitcdde*",
]

[tool.setuptools.package-data]
jitcdde = [
"jitced_template.c",
]

[tool.setuptools_scm]
write_to = "jitcdde/version.py"
35 changes: 0 additions & 35 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/compare_C_and_Python_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,4 @@ def apply_jump():
break

print("Runs with errors: %i / %i" % (errors, number_of_runs))

raise SystemExit(errors)
1 change: 1 addition & 0 deletions tests/compare_C_and_Python_core_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,4 @@ def apply_jump():
break

print("Runs with errors: %i / %i" % (errors, number_of_runs))
raise SystemExit(errors)
8 changes: 5 additions & 3 deletions tests/test_jitcdde.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
test,
input, jitcdde_input,
)
import os
import platform
import symengine
import numpy as np
from numpy.testing import assert_allclose
import unittest
from itertools import combinations

dirname = os.path.dirname(__file__)
if platform.system() == "Windows":
compile_args = None
else:
Expand All @@ -37,11 +39,11 @@
n = len(f)

def get_past_points():
data = np.loadtxt("two_Roessler_past.dat")
data = np.loadtxt(os.path.join(dirname, "two_Roessler_past.dat"))
for point in data:
yield (point[0], np.array(point[1:7]), np.array(point[7:13]))

y_10_ref = np.loadtxt("two_Roessler_y10.dat")
y_10_ref = np.loadtxt(os.path.join(dirname, "two_Roessler_y10.dat"))
T = 10

test_parameters = {
Expand Down Expand Up @@ -85,7 +87,7 @@ def assert_consistency_with_previous(self, value):
def test_integration(self):
for time in np.linspace(0,T,10,endpoint=True):
value = self.DDE.integrate(time)
np.savetxt("two_Roessler_y10_new.dat",value,fmt="%.20f")
np.savetxt(os.path.join(dirname, "two_Roessler_y10_new.dat"),value,fmt="%.20f")
assert_allclose(value, y_10_ref, **tolerance)
self.assert_consistency_with_previous(value)

Expand Down

0 comments on commit 237281d

Please sign in to comment.