Skip to content

Commit

Permalink
Merge pull request #332 from ludgerpaehler/master
Browse files Browse the repository at this point in the history
PyProject-centric Build System with Setuptools
  • Loading branch information
Jacob-Stevens-Haas committed May 13, 2023
2 parents 44f04ab + c8d640a commit ebc1984
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 129 deletions.
4 changes: 0 additions & 4 deletions setup.cfg → .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@ import-order-style = smarkets
statistics = True
count = True
verbose = 1
# format = [%(code)s] %(text)s @ %(path)s:%(row)d:%(col)d

[codespell]
ignore-words-list = pres,nd
9 changes: 5 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.8"
python-version: "3.9"
- name: Linting
run: |
pip install pre-commit
Expand All @@ -23,7 +23,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.10"]

steps:
- uses: actions/checkout@v3
Expand All @@ -33,13 +33,14 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -r requirements-dev.txt
pip install sympy # needed for notebook 9, but not required for pysindy
pip install --upgrade pip
pip install .[dev,miosr,cvxpy]
- name: Build the docs
# Not exactly how RTD does it, but close.
run: |
sudo apt-get update -y
sudo apt-get install pandoc
pip install .[docs]
cd docs
python -m sphinx -T -E -W -b html -d _build/doctrees . _build/html
cd ..
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: Install dependencies
run: pip install wheel
python-version: "3.9"
- name: Install Build
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python setup.py sdist bdist_wheel
run: python -m build .
- name: Upload package
uses: pypa/gh-action-pypi-publish@v1.8.5
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dist
*.egg-info
commit-msg
todo
poetry.lock

# Environments
.env
Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
rev: 5.0.4
hooks:
- id: flake8
args: ["--config=setup.cfg"]
args: ["--config=.flake8"]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
Expand All @@ -34,11 +34,12 @@ repos:
hooks:
- id: sphinx-lint
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: v2.2.4
hooks:
- id: codespell
types_or: [python, rst, markdown]
args: ["-L hist"]
additional_dependencies: [tomli]
args: ["--toml", "pyproject.toml"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
Expand Down
62 changes: 49 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,41 @@ Then, to install the package, run
pip install .
If you do not have pip you can instead use
If you do not have root access, you should add the ``--user`` option to the above lines.

Caveats
^^^^^^^

To run the unit tests, or example notebooks, you should install the dev-dependencies with:

.. code-block:: bash
python setup.py install
pip install pysindy[dev]
If you do not have root access, you should add the ``--user`` option to the above lines.
or if you are installing from a local copy

Caveats
^^^^^^^
If you would like to use the ``SINDy-PI`` optimizer, the ``Trapping SINDy`` optimizer (TrappingSR3), or the other SR3 optimizations with inequality constraints, you will also need to install the cvxpy package, e.g. with ``pip install cvxpy``.
.. code-block:: bash
pip install .[dev]
To build a local copy of the documentation, you should install the docs-dependencies with:

.. code-block:: bash
pip install pysindy[docs]
If you are looking to use convex optimization provided by `cvxpy <https://github.com/cvxpy/cvxpy>`__, then you have to install

To run the unit tests, example notebooks, or build a local copy of the documentation, you should install the additional dependencies in ``requirements-dev.txt``
.. code-block:: bash
pip install pysindy[cvxpy]
to utilize Mixed-Integer Optimized Sparse Regression (MIOSR) via `GurobiPy <https://pypi.org/project/gurobipy/>`__, you
require

.. code-block:: bash
pip install -r requirements-dev.txt
pip install pysindy[miosr]
Documentation
Expand Down Expand Up @@ -178,33 +196,51 @@ You can optimize your notebook for testing by checking ``__name__``. When our t
Contributing code
^^^^^^^^^^^^^^^^^
We welcome contributions to PySINDy. To contribute a new feature please submit a pull request. To get started we recommend installing the packages in ``requirements-dev.txt`` via
We welcome contributions to PySINDy. To contribute a new feature please submit a pull request. To get started we recommend installing an editable ``dev`` version from a local clone via

.. code-block:: bash
pip install -r requirements-dev.txt
pip install -e .[dev]
This will allow you to run unit tests and automatically format your code. To be accepted your code should conform to PEP8 and pass all unit tests. Code can be tested by invoking

.. code-block:: bash
pytest
We recommend using ``pre-commit`` to format your code. Once you have staged changes to commit
We recommend using ``pre-commit`` to format your code. The easiest approach is to install pre-commit via

.. code-block:: bash
pre-commit install
After which pre-commit will automatically check all future commits. Once you have staged changes to commit

.. code-block:: bash
git add path/to/changed/file.py
you can run the following to automatically reformat your staged code
Pre-commit will then automatically run all checks against your committed code. If you want to trigger this manually, you can run the following to automatically reformat your staged code

.. code-block:: bash
pre-commit
Note that you will then need to re-stage any changes ``pre-commit`` made to your code.

Building documentation requires [pandoc](https://pandoc.org/installing.html) as a separate install. Once installed, run
Building documentation requires the ``docs`` dependencies, which can be installed with either

.. code-block:: bash
pip install pysindy[docs]
or with

.. code-block:: bash
pip install .[docs]
for a local clone of the repository. Once installed, run

.. code-block:: bash
Expand Down
2 changes: 1 addition & 1 deletion examples/data/vonKarman_pod/neksuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def readnek(fname):
# compute total number of points per element
npel = lr1[0] * lr1[1] * lr1[2]

# get number of pysical dimensions
# get number of physical dimensions
ndim = 2 + (lr1[2] > 1)

# get number of elements
Expand Down
91 changes: 77 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,77 @@
[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4", "setuptools_scm_git_archive"]
build-backend = "setuptools.build_meta:__legacy__"
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "pysindy/version.py"
[project]
name = "pysindy"
description = "Sparse Identification of Nonlinear Dynamics"
authors = [
{name="Brian de Silva", email="bdesilva@uw.edu"},
{name="Kathleen Champion", email="kpchamp@uw.edu"},
{name="Markus Quade", email="info@markusqua.de"},
{name="Alan Kaptanoglu", email="akaptano@uw.edu"}
]
license = {text = "MIT"}
requires-python = ">=3.8"
dynamic = ["version"]
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Topic :: Scientific/Engineering :: Mathematics",
]
readme = "README.rst"
dependencies = [
"scikit-learn>=0.23",
"derivative",
]

[project.optional-dependencies]
dev = [
"matplotlib",
"seaborn",
"pytest>=6.2.4",
"black",
"build",
"pytest-cov",
"pytest-lazy-fixture",
"flake8-builtins-unleashed",
"jupyter",
"jupytext",
"pre-commit",
"hypothesis",
"jupyter-contrib-nbextensions"
]
docs = [
"pandoc",
"sphinx-rtd-theme",
"sphinx==5.3.0",
"sphinxcontrib-apidoc",
"nbsphinx"
]
miosr = [
"gurobipy>=9.5.1,<10.0"
]
cvxpy = [
"cvxpy",
"scs>=2.1, !=2.1.4"
]

[tool.black]
line-length = 88
extend-exclude = '''
/(
force-exclude = '''
\.git
| \.mypy_cache
| \.venv
| .vscode
| version.py
| build
| dist
| env
)/
\.mypy_cache
\.venv
.vscode
version.py
build
dist
env
'''

[tool.pytest.ini_options]
Expand All @@ -26,3 +80,12 @@ filterwarnings = [
"ignore::UserWarning",]
addopts = '-m "not slow"'
markers = ["slow"]

[tool.codespell]
ignore-words-list = "pres,nd,hist"

[tool.setuptools]
packages = ["pysindy"]

[tool.setuptools_scm]
write_to = "pysindy/version.py"
25 changes: 0 additions & 25 deletions requirements-dev.txt

This file was deleted.

7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

0 comments on commit ebc1984

Please sign in to comment.