Skip to content

Commit

Permalink
Merge pull request #32 from LabForComputationalVision/pyprojecttoml
Browse files Browse the repository at this point in the history
Switch all metadata to pyproject.toml
  • Loading branch information
billbrod authored Feb 13, 2024
2 parents 8955baf + 9aceae5 commit 5582f77
Show file tree
Hide file tree
Showing 40 changed files with 85 additions and 136 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ docs/_build
docs/api

.idea

# created automatically by setuptools.scm, don't track
version.py
6 changes: 3 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "mambaforge-4.10"
python: "3.10"

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand All @@ -24,9 +24,9 @@ formats:
- htmlzip

# Optionally set the version of Python and requirements required to build your docs
conda:
environment: docs/environment.yml
python:
install:
- method: pip
path: .
extra_requirements:
- docs
3 changes: 1 addition & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ authors:
given-names: Nikhil
- family-names: Ward
given-names: Brian
orcid: https://orcid.org/0000-0000-0000-0000
title: "Pyrtools: tools for multi-scale image processing"
version: v1.0.3
version: v1.0.4
date-released: 2023-11-20
doi: 10.5281/zenodo.10161031
url: "https://github.com/LabForComputationalVision/pyrtools"
79 changes: 17 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Build Status](https://github.com/LabForComputationalVision/pyrtools/workflows/build/badge.svg)](https://github.com/LabForComputationalVision/pyrtools/actions?query=workflow%3Abuild)
[![Documentation Status](https://readthedocs.org/projects/pyrtools/badge/?version=latest)](https://pyrtools.readthedocs.io/en/latest/?badge=latest)
[![DOI](https://zenodo.org/badge/137527035.svg)](https://zenodo.org/doi/10.5281/zenodo.10161031)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.3?filepath=TUTORIALS%2F)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.4?filepath=TUTORIALS%2F)
[![codecov](https://codecov.io/gh/LabForComputationalVision/pyrtools/branch/main/graph/badge.svg?token=Ei9TYftdYi)](https://codecov.io/gh/LabForComputationalVision/pyrtools)

Briefly, the tools include:
Expand All @@ -20,10 +20,11 @@ Briefly, the tools include:
auto-scaling options, rounding to integer zoom factors to avoid
resampling artifacts, and useful labeling (dimensions and gray-range).

This is a python 3 port of Eero Simoncelli's matlabPyrTools, but it
does not attempt to recreate all of the matlab code from
matlabPyrTools. The goal is to create a Python interface for the C
code at the heart of matlabPyrTools.
This is a python 3 port of Eero Simoncelli's
[matlabPyrTools](https://github.com/LabForComputationalVision/matlabPyrTools),
but it does not attempt to recreate all of the matlab code from matlabPyrTools.
The goal is to create a Python interface for the C code at the heart of
matlabPyrTools.

**NOTE**: If you are only interested in the complex steerable pyramid, we have a
pytorch implementation in the
Expand All @@ -49,19 +50,6 @@ want the changes you make in the directory to be reflected in your
install) from the root directory of this project. The core of this
code is the C code, and the pip install will compile it nicely.

## Dependencies

Dependencies are documented in `setup.py`.

IPython is optional. If it's not installed,
`pyrtools.display_tools.animshow` must be called with `as_html5=False`
(but since this is for displaying the animated image in a Jupyter /
IPython notebook, you probably won't need that functionality).

For the C code to compile, we require `gcc` version >= 6, because of
[this
issue](https://stackoverflow.com/questions/46504700/gcc-compiler-not-recognizing-fno-plt-option)

# Pyramid resources

If you would like to learn more about pyramids and why they're helpful
Expand All @@ -78,23 +66,9 @@ for image processing, here are some resources to get you started:
- Notes from Eero Simoncelli on [the Steerable
Pyramid](http://www.cns.nyu.edu/~eero/STEERPYR/)

# Authors

Rob Young and Eero Simoncelli, 7/13

William Broderick, 6/17

William Broderick, Pierre-Étienne Fiquet, Zhuo Wang, Zahra Kadkhodaie,
Nikhil Parthasarathy, and the Lab for Computational Vision, 4/19

# Usage:

method parameters mimic the matlab function parameters except that there's no
need to pass pyr or pind, since the pyPyrTools version pyr and pyrSize are
properties of the class.

- load modules (note that if you installed via pip, you can skip the
first two lines):
- load modules:
```
import pyrtools as pt
```
Expand All @@ -109,41 +83,29 @@ pyr = pt.pyramids.LaplacianPyramid(img)
recon_img = pyr.recon_pyr()
```

Please see `TUTORIALS/02_pyramids.ipynb` for more examples. You can
start this with: `jupyter notebook 02_pyramids.ipynb` if you have iPython
and Jupyter installed.
Please see `TUTORIALS/02_pyramids.ipynb` for more examples.

# Testing
# For developres

All code should be considered a beta release. By that we mean that it is being
actively developed and tested. You can find unit tests in
`TESTS/unitTests.py` and run them with `python TESTS/unitTests.py`.
## Testing

If you're using functions or parameters that do not have associated unit
tests you should test this yourself to make sure the results are correct.
You could then submit your test code, so that we can build more complete
unit tests.
You can find unit tests in `TESTS/unitTests.py` and run them with `python
TESTS/unitTests.py`.

# Build the documentation
## Build the documentation

NOTE: If you just want to read the documentation, you do not need to
do this; documentation is built automatically on
[readthedocs](https://pyrtools.readthedocs.io/en/latest/).

However, it can be built locally as well. You would do this if you've
made changes locally to the documentation (or the docstrings) that you
would like to examine before pushing. The virtual environment required
to do so is defined in `docs/environment.yml`, so to create that
environment and build the docs, do the following from the project's
root directory:
would like to examine before pushing.

```
# install sphinx and required packages to build documentation
conda env create -f docs/environment.yml
# activate the environment
conda activate pyrtools_docs
# install pyrtools
pip install -e .
# create a new virtual environment and then...
# install pyrtools with sphinx and documentation-related dependencies
pip install -e .[docs]
# build documentation
cd docs/
make html
Expand All @@ -152,10 +114,3 @@ make html
The index page of the documentation will then be located at
`docs/_build/html/index.html`, open it in your browser to navigate
around.

The `pyrtools_docs` environment you're creating contains the package
`sphinx` and several extensions for it that are required to build the
documentation. You also need to install `pyrtools` from your local
version so that `sphinx` can import the library and grab all of the
docstrings (you're installing the local version so you can see all the
changes you've made).
18 changes: 0 additions & 18 deletions docs/environment.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
:target: https://github.com/LabForComputationalVision/pyrtools/actions?query=workflow%3Abuild

.. |binder| image:: https://mybinder.org/badge_logo.svg
:target: https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.3?filepath=TUTORIALS%2F
:target: https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.4?filepath=TUTORIALS%2F

.. |doi| image:: https://zenodo.org/badge/137527035.svg
:target: https://zenodo.org/doi/10.5281/zenodo.10161031
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ When installing from source on Linux or Mac, we require ``gcc`` version >= 6 in
order for the C code to compile, because of `this issue
<https://stackoverflow.com/questions/46504700/gcc-compiler-not-recognizing-fno-plt-option>`_

When installing from source on Windows, Microsoft Visual C++ 14.0 or greater is required, which can be obtained with `Microsoft C++ Build Tools <https://visualstudio.microsoft.com/visual-cpp-build-tools/`_.
When installing from source on Windows, Microsoft Visual C++ 14.0 or greater is required, which can be obtained with `Microsoft C++ Build Tools <https://visualstudio.microsoft.com/visual-cpp-build-tools/>`_.
12 changes: 2 additions & 10 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ In the python interpreter, then call::

import pyrtools as pt

which should run without errors if the install worked correctly. If
you have an issue with the installation, it will most likely be with
the compilation of the C code. There is hopefully a warning of this
when you import the library, but if you get an error message along the
lines of `lib not defined` when attempting to build a pyramid or call
the functions `corrDn`, `upConv`, or `pointOp`, this is probably
what's at fault.

Create pyramid::

pyr = pt.pyramids.LaplacianPyramid(img)
Expand All @@ -28,7 +20,7 @@ Reconstruct image from pyramid::
recon_img = pyr.recon_pyr()

For more details, see the jupyter notebooks included in the
`TUTORIALS/` directory, static versions of which are linked in the
``TUTORIALS/`` directory, static versions of which are linked in the
navigation sidebar. You can play around with a live version of them in
order to test out the code before downloading on `binder
<https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.3?filepath=TUTORIALS%2F>`_
<https://mybinder.org/v2/gh/LabForComputationalVision/pyrtools/v1.0.4?filepath=TUTORIALS%2F>`_
50 changes: 49 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
[project]
name = "pyrtools"
dynamic = ["version"]
authors = [{name="Pyrtools authors"}]
description = "Python tools for multi-scale image processing, including Laplacian pyramids, Wavelets, and Steerable Pyramids."
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Intended Audience :: Science/Research",
]
keywords = ['image processing', 'visual information processing', 'computational models']

dependencies = ['numpy>=1.1',
'scipy>=0.18',
'matplotlib>=1.5',
'tqdm>=4.29',
'requests>=2.21']

[project.optional-dependencies]
docs = [
'sphinx',
'numpydoc',
# because of this issue:
# https://nbsphinx.readthedocs.io/en/0.6.0/installation.html#Pygments-Lexer-for-Syntax-Highlighting
'ipython',
'nbsphinx',
'nbsphinx_link',
'sphinxcontrib-apidoc',
# fix sphinx 7 incompatibility issue
'sphinx_rtd_theme>=1.3.0rc1'
]

[build-system]
requires = ["setuptools", "wheel"]
requires = ["setuptools", "wheel", "setuptools-scm[toml]"]
build-backend = "setuptools.build_meta"

[project.urls]
"Homepage" = "https://github.com/LabForComputationalVision/pyrtools"
"Documentation" = "https://pyrtools.readthedocs.io/en/latest/"
"Download" = "https://zenodo.org/records/10403034"

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools_scm]
write_to = "src/pyrtools/version.py"
version_scheme = 'python-simplified-semver'
local_scheme = 'no-local-version'
1 change: 0 additions & 1 deletion pyrtools/version.py

This file was deleted.

2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

43 changes: 8 additions & 35 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@

from wheel.bdist_wheel import bdist_wheel
from setuptools import setup, Extension
import importlib
import os

# copied from kymatio's setup.py: https://github.com/kymatio/kymatio/blob/master/setup.py
pyrtools_version_spec = importlib.util.spec_from_file_location('pyrtools_version',
'pyrtools/version.py')
pyrtools_version_module = importlib.util.module_from_spec(pyrtools_version_spec)
pyrtools_version_spec.loader.exec_module(pyrtools_version_module)
VERSION = pyrtools_version_module.version

# Adapted from the cibuildwheel example https://github.com/joerick/python-ctypes-package-sample
# it marks the wheel as not specific to the Python API version.
Expand All @@ -25,33 +16,15 @@ def get_tag(self):


setup(
name='pyrtools',
version=VERSION,
long_description=open('README.md', 'r').read(),
long_description_content_type='text/markdown',
description='Python tools for multi-scale image processing, including Laplacian pyramids, Wavelets, and Steerable Pyramids',
license='MIT',
url='https://github.com/LabForComputationalVision/pyrtools',
author='Eero Simoncelli',
author_email='[email protected]',
keywords='multi-scale image-processing',
packages=['pyrtools', 'pyrtools.pyramids', 'pyrtools.tools', 'pyrtools.pyramids.c'],
package_data={'': ['*.h', 'LICENSE']},
install_requires=['numpy>=1.1',
'scipy>=0.18',
'matplotlib>=1.5',
'tqdm>=4.29',
'requests>=2.21'],
ext_modules=[Extension('pyrtools.pyramids.c.wrapConv',
sources=['pyrtools/pyramids/c/py.c',
'pyrtools/pyramids/c/convolve.c',
'pyrtools/pyramids/c/edges.c',
'pyrtools/pyramids/c/wrap.c',
'pyrtools/pyramids/c/internal_pointOp.c'],
depends=['pyrtools/pyramids/c/meta.h',
'pyrtools/pyramids/c/convolve.h',
'pyrtools/pyramids/c/internal_pointOp.h'],
sources=['src/pyrtools/pyramids/c/py.c',
'src/pyrtools/pyramids/c/convolve.c',
'src/pyrtools/pyramids/c/edges.c',
'src/pyrtools/pyramids/c/wrap.c',
'src/pyrtools/pyramids/c/internal_pointOp.c'],
depends=['src/pyrtools/pyramids/c/meta.h',
'src/pyrtools/pyramids/c/convolve.h',
'src/pyrtools/pyramids/c/internal_pointOp.h'],
extra_compile_args=['-fPIC', '-shared'])],
cmdclass={"bdist_wheel": WheelABINone},
tests='TESTS',
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 5582f77

Please sign in to comment.