From 63b0655c1402117ef26e35d724acf36f92318f85 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ha=CC=8Akon=20Wiik=20A=CC=8Anes?=
Date: Sat, 7 Sep 2024 15:34:56 +0200
Subject: [PATCH 1/6] Replace setup.py and setup.cfg with pyproject.toml,
update README header
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Håkon Wiik Ånes
---
README.rst | 17 +++-----
pyproject.toml | 112 +++++++++++++++++++++++++++++++++++++++++++++++++
setup.cfg | 40 ------------------
setup.py | 103 ---------------------------------------------
4 files changed, 117 insertions(+), 155 deletions(-)
create mode 100644 pyproject.toml
delete mode 100644 setup.cfg
delete mode 100644 setup.py
diff --git a/README.rst b/README.rst
index cd486d6d..5ec3f626 100644
--- a/README.rst
+++ b/README.rst
@@ -1,15 +1,8 @@
-.. raw:: html
-
-
-
-
- orix
-
-
-
-.. Content above here until EXCLUDE plus one line is excluded from the long description
-.. in the source distributions uploaded to PyPI
-.. EXCLUDE
+|logo| orix
+===========
+
+.. |logo| image:: https://raw.githubusercontent.com/pyxem/orix/develop/doc/_static/img/orix_logo.png
+ :width: 50
orix is an open-source Python library for analysing orientations and crystal symmetry.
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 00000000..838c3d28
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,112 @@
+[build-system]
+requires = ["hatchling"]
+build-backend = "hatchling.build"
+
+[project]
+name = "orix"
+authors = [{name = "orix developers", email = "pyxem.team@gmail.com"}]
+description = "Handling crystal orientation mapping data"
+license = {file = "LICENSE"}
+readme = {file = "README.rst", content-type = "text/x-rst"}
+dynamic = ["version"]
+classifiers=[
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
+ "Programming Language :: Python :: 3.11",
+ "Development Status :: 4 - Beta",
+ "Intended Audience :: Science/Research",
+ "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
+ "Natural Language :: English",
+ "Operating System :: OS Independent",
+ "Topic :: Scientific/Engineering",
+ "Topic :: Scientific/Engineering :: Physics",
+]
+dependencies = [
+ "dask[array]",
+ "diffpy.structure >= 3.0.2",
+ "h5py",
+ "matplotlib >= 3.5",
+ "matplotlib-scalebar",
+ "numba",
+ "numpy",
+ "numpy-quaternion",
+ "pooch >= 0.13",
+ # TODO: Remove once https://github.com/diffpy/diffpy.structure/issues/97 is fixed
+ "pycifrw",
+ "scipy",
+ "tqdm",
+]
+
+[project.optional-dependencies]
+doc = [
+ "ipykernel", # Used by nbsphinx to execute notebooks
+ "memory_profiler",
+ "nbconvert >= 7.16.4",
+ "nbsphinx >= 0.7",
+ "numpydoc",
+ "pydata-sphinx-theme",
+ "scikit-image",
+ "scikit-learn",
+ "sphinx >= 3.0.2",
+ "sphinx-codeautolink[ipython]",
+ "sphinx-copybutton >= 0.2.5",
+ "sphinx-design",
+ "sphinx-gallery",
+ "sphinxcontrib-bibtex >= 1.0",
+]
+tests = [
+ "numpydoc",
+ "pytest >= 5.4",
+ "pytest-rerunfailures",
+ "pytest-xdist",
+]
+coverage = [
+ "coverage >= 5.0",
+ "pytest-cov >= 2.8.1",
+]
+dev = [
+ "black[jupyter]",
+ "hatch",
+ "isort >= 5.10",
+ "manifix",
+ "outdated",
+ "pre-commit >= 1.16",
+ "orix[doc,tests,coverage]",
+]
+
+[tool.hatch.readme]
+path = "orix/__init__.py"
+
+[tool.hatch.version]
+path = "orix/__init__.py"
+
+[tool.coverage.report]
+precision = 2
+
+[tool.coverage.run]
+branch = true
+source = ["orix"]
+relative_files = true
+omit = [
+ "orix/__init__.py",
+ "orix/tests/**/*.py",
+]
+
+[tool.pytest.ini_options]
+addopts = [
+ "-ra",
+ "--ignore=doc/_static/img/colormap_banners/create_colormap_banners.py",
+ "--ignore=examples/*/*.py",
+]
+doctest_optionflags = "NORMALIZE_WHITESPACE"
+filterwarnings = [
+ "ignore:Deprecated call to `pkg_resources:DeprecationWarning",
+ "ignore:pkg_resources is deprecated as an API:DeprecationWarning",
+]
+
+[tool.isort]
+profile = "black"
+filter_files = true
+force_sort_within_sections = true
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index f59f4c06..00000000
--- a/setup.cfg
+++ /dev/null
@@ -1,40 +0,0 @@
-# Note that Black does not support setup.cfg
-
-[tool:pytest]
-addopts =
- -ra
- # Documentation scripts
- --ignore=doc/_static/img/colormap_banners/create_colormap_banners.py
- # Examples
- --ignore=examples/*/*.py
-doctest_optionflags = NORMALIZE_WHITESPACE
-filterwarnings =
- # From setuptools
- ignore:Deprecated call to \`pkg_resources:DeprecationWarning
- ignore:pkg_resources is deprecated as an API:DeprecationWarning
-
-[coverage:run]
-source = orix
-omit =
- setup.py
- orix/__init__.py
- orix/tests/**/*.py
-relative_files = True
-
-[coverage:report]
-precision = 2
-
-[manifix]
-known_excludes =
- .*
- .*/**
- *.code-workspace
- **/*.pyc
- **/*.nbi
- **/*.nbc
- **/__pycache__/**
- doc/_build/**
- doc/examples/**
- doc/reference/generated/**
- doc/.ipynb_checkpoints/**
- htmlcov/**
diff --git a/setup.py b/setup.py
deleted file mode 100644
index dfcc4c09..00000000
--- a/setup.py
+++ /dev/null
@@ -1,103 +0,0 @@
-from itertools import chain
-
-from setuptools import find_packages, setup
-
-from orix import __author__, __author_email__, __description__, __name__, __version__
-
-# Projects with optional features for building the documentation and running
-# tests. From setuptools:
-# https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies
-# fmt: off
-extra_feature_requirements = {
- "doc": [
- "ipykernel", # Used by nbsphinx to execute notebooks
- "memory_profiler",
- "nbconvert >= 7.16.4",
- "nbsphinx >= 0.7",
- "numpydoc",
- "pydata-sphinx-theme",
- "scikit-image",
- "scikit-learn",
- "sphinx >= 3.0.2",
- "sphinx-codeautolink[ipython]",
- "sphinx-copybutton >= 0.2.5",
- "sphinx-design",
- "sphinx-gallery",
- "sphinxcontrib-bibtex >= 1.0",
- ],
- "tests": [
- "coverage >= 5.0",
- "numpydoc",
- "pytest >= 5.4",
- "pytest-cov >= 2.8.1",
- "pytest-rerunfailures",
- "pytest-xdist",
- ],
-}
-extra_feature_requirements["dev"] = [
- "black[jupyter]",
- "isort >= 5.10",
- "manifix",
- "outdated",
- "pre-commit >= 1.16",
-] + list(chain(*list(extra_feature_requirements.values())))
-# fmt: on
-
-# Remove the "raw" ReStructuredText directive from the README so we can
-# use it as the long_description on PyPI
-readme = open("README.rst").read()
-readme_split = readme.split("\n")
-for i, line in enumerate(readme_split):
- if line == ".. EXCLUDE":
- break
-long_description = "\n".join(readme_split[i + 2 :])
-
-setup(
- name=__name__,
- version=str(__version__),
- license="GPLv3",
- url="https://orix.readthedocs.io",
- author=__author__,
- author_email=__author_email__,
- description=__description__,
- long_description=long_description,
- long_description_content_type="text/x-rst",
- classifiers=[
- "Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.8",
- "Programming Language :: Python :: 3.9",
- "Programming Language :: Python :: 3.10",
- "Programming Language :: Python :: 3.11",
- "Development Status :: 4 - Beta",
- "Intended Audience :: Science/Research",
- (
- "License :: OSI Approved :: GNU General Public License v3 or later "
- "(GPLv3+)"
- ),
- "Natural Language :: English",
- "Operating System :: OS Independent",
- "Topic :: Scientific/Engineering",
- "Topic :: Scientific/Engineering :: Physics",
- ],
- python_requires=">=3.8",
- packages=find_packages(exclude=["orix/tests"]),
- extras_require=extra_feature_requirements,
- # fmt: off
- install_requires=[
- "dask[array]",
- "diffpy.structure >= 3.0.2",
- "h5py",
- "matplotlib >= 3.5",
- "matplotlib-scalebar",
- "numba",
- "numpy",
- "numpy-quaternion",
- "pooch >= 0.13",
- # TODO: Remove once https://github.com/diffpy/diffpy.structure/issues/97 is fixed
- "pycifrw",
- "scipy",
- "tqdm",
- ],
- # fmt: on
- package_data={"": ["LICENSE", "README.rst", "readthedocs.yaml"], "orix": ["*.py"]},
-)
From e72acc1fbd6e4a7541f4e7dafeda99d24e762009 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ha=CC=8Akon=20Wiik=20A=CC=8Anes?=
Date: Sat, 7 Sep 2024 15:35:37 +0200
Subject: [PATCH 2/6] Remove manifix dependency and MANIFEST.in file
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Håkon Wiik Ånes
---
.github/workflows/build.yml | 17 -----------------
MANIFEST.in | 14 --------------
doc/dev/building_writing_documentation.rst | 2 +-
pyproject.toml | 1 -
4 files changed, 1 insertion(+), 33 deletions(-)
delete mode 100644 MANIFEST.in
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f721f637..ec101a10 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -34,23 +34,6 @@ jobs:
run: |
black --diff --line-length 77 doc/tutorials/*.ipynb
- # Make sure all necessary files will be included in a release
- manifest:
- name: check manifest
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
-
- - uses: actions/setup-python@v4
-
- - name: Install dependencies
- run: |
- pip install manifix
-
- - name: Check MANIFEST.in file
- run: |
- python setup.py manifix
-
build-with-pip:
name: ${{ matrix.os }}-py${{ matrix.python-version }}${{ matrix.LABEL }}
runs-on: ${{ matrix.os }}
diff --git a/MANIFEST.in b/MANIFEST.in
deleted file mode 100644
index 9c3daa8f..00000000
--- a/MANIFEST.in
+++ /dev/null
@@ -1,14 +0,0 @@
-include CHANGELOG.rst
-include CONTRIBUTING.rst
-include environment.yml
-include LICENSE
-include README.rst
-include RELEASE.rst
-include readthedocs.yaml
-include setup.cfg
-include setup.py
-include tutorials/README.rst
-
-recursive-include doc Makefile make.bat *.rst *.py *.ipynb *.bib *.txt *.cfg *.sh *.yml
-recursive-include doc/_static *.png *.jpb *.svg *.css *.sh
-recursive-include examples *.txt *.py
diff --git a/doc/dev/building_writing_documentation.rst b/doc/dev/building_writing_documentation.rst
index 5bd8d66d..05815b42 100644
--- a/doc/dev/building_writing_documentation.rst
+++ b/doc/dev/building_writing_documentation.rst
@@ -112,7 +112,7 @@ We use :doc:`nbval ` for this.
The tutorial notebooks can be run interactively in the browser with the help of Binder.
When creating a server from the orix source code, Binder installs the packages listed in
the ``environment.yml`` configuration file, which must include all ``doc`` dependencies
-in ``setup.py`` necessary to run the notebooks.
+in ``pyproject.toml`` necessary to run the notebooks.
Writing API reference
---------------------
diff --git a/pyproject.toml b/pyproject.toml
index 838c3d28..9c72c7d5 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -70,7 +70,6 @@ dev = [
"black[jupyter]",
"hatch",
"isort >= 5.10",
- "manifix",
"outdated",
"pre-commit >= 1.16",
"orix[doc,tests,coverage]",
From 71f5435c71b37edc8723cbd03bd7ee47ce7633cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ha=CC=8Akon=20Wiik=20A=CC=8Anes?=
Date: Sat, 7 Sep 2024 16:01:43 +0200
Subject: [PATCH 3/6] Add coverage deps to CI build
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Håkon Wiik Ånes
---
.github/workflows/build.yml | 10 +++++-----
orix/__init__.py | 4 ----
pyproject.toml | 5 +----
3 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index ec101a10..150240bd 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -14,11 +14,11 @@ jobs:
name: code style
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: psf/black@stable
- - uses: actions/setup-python@v4
+ - uses: actions/setup-python@v5
with:
python-version: '3.11'
@@ -51,17 +51,17 @@ jobs:
DEPENDENCIES: diffpy.structure==3.0.2 matplotlib==3.5
LABEL: -oldest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install depedencies and package
shell: bash
run: |
- pip install -U -e .'[doc, tests]'
+ pip install -U -e .'[doc,tests,coverage]'
- name: Install oldest supported version
if: ${{ contains(matrix.LABEL, 'oldest') }}
diff --git a/orix/__init__.py b/orix/__init__.py
index 13604a79..dc1de331 100644
--- a/orix/__init__.py
+++ b/orix/__init__.py
@@ -1,8 +1,4 @@
-__name__ = "orix"
__version__ = "0.14.dev0"
-__author__ = "orix developers"
-__author_email__ = "pyxem.team@gmail.com"
-__description__ = "orix is an open-source Python library for handling crystal orientation mapping data."
# Sorted by line contributions (ideally excluding lines in notebook files)
__credits__ = [
"Håkon Wiik Ånes",
diff --git a/pyproject.toml b/pyproject.toml
index 9c72c7d5..5bba288b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
[project]
name = "orix"
authors = [{name = "orix developers", email = "pyxem.team@gmail.com"}]
-description = "Handling crystal orientation mapping data"
+description = "orix is an open-source Python library for handling crystal orientation mapping data"
license = {file = "LICENSE"}
readme = {file = "README.rst", content-type = "text/x-rst"}
dynamic = ["version"]
@@ -75,9 +75,6 @@ dev = [
"orix[doc,tests,coverage]",
]
-[tool.hatch.readme]
-path = "orix/__init__.py"
-
[tool.hatch.version]
path = "orix/__init__.py"
From f8144ab52b74b8ce866ee1d8b484e4248eb85411 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ha=CC=8Akon=20Wiik=20A=CC=8Anes?=
Date: Sat, 7 Sep 2024 16:03:50 +0200
Subject: [PATCH 4/6] Update black version to 24.8.0 in pre-commit config
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Håkon Wiik Ånes
---
.pre-commit-config.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index b4cd29ca..ae7f0bd8 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
- rev: 24.4.2
+ rev: 24.8.0
hooks:
- id: black
- id: black-jupyter
From 9bdfa9fdfd3bba04d508f5b1c2d192d8cf0b6bec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ha=CC=8Akon=20Wiik=20A=CC=8Anes?=
Date: Sat, 7 Sep 2024 16:43:43 +0200
Subject: [PATCH 5/6] Fix use of project metadata in docs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Håkon Wiik Ånes
---
doc/conf.py | 23 +++++++++++++++--------
pyproject.toml | 1 +
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/doc/conf.py b/doc/conf.py
index a15b86f8..25676091 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -6,8 +6,10 @@
import inspect
import os
from os.path import dirname, relpath
+from pathlib import Path
import re
import sys
+import tomllib
from numpydoc.docscrape_sphinx import SphinxDocString
@@ -20,9 +22,14 @@
# sys.path.insert(0, os.path.abspath("."))
sys.path.append("../")
-project = "orix"
-copyright = f"2018-{str(datetime.now().year)}, {orix.__author__}"
-author = orix.__author__
+top_dir = Path(__file__).parent.parent
+
+with open(top_dir / "pyproject.toml", "rb") as f:
+ metadata = tomllib.load(f)
+
+project = metadata["project"]["name"]
+author = metadata["project"]["authors"][0]["name"]
+copyright = f"2018-{str(datetime.now().year)}, {author}"
release = orix.__version__
# Add any Sphinx extension module names here, as strings. They can be
@@ -120,10 +127,10 @@
# modifications to point nbviewer and Binder to the GitHub develop
# branch links when the documentation is launched from a kikuchipy
# version with "dev" in the version
-if "dev" in orix.__version__:
+if "dev" in release:
release_version = "develop"
else:
- release_version = "v" + orix.__version__
+ release_version = "v" + release
# This is processed by Jinja2 and inserted before each notebook
nbsphinx_prolog = (
r"""
@@ -234,14 +241,14 @@ def linkcode_resolve(domain, info):
fn = relpath(fn, start=startdir).replace(os.path.sep, "/")
if fn.startswith("orix/"):
- m = re.match(r"^.*dev0\+([a-f\d]+)$", orix.__version__)
+ m = re.match(r"^.*dev0\+([a-f\d]+)$", release)
pre_link = "https://github.com/pyxem/orix/blob/"
if m:
return pre_link + "%s/%s%s" % (m.group(1), fn, linespec)
- elif "dev" in orix.__version__:
+ elif "dev" in release:
return pre_link + "develop/%s%s" % (fn, linespec)
else:
- return pre_link + "v%s/%s%s" % (orix.__version__, fn, linespec)
+ return pre_link + "v%s/%s%s" % (release, fn, linespec)
else:
return None
diff --git a/pyproject.toml b/pyproject.toml
index 5bba288b..bd543f7c 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,6 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "orix"
+# conf.py assumes orix developers to be first author
authors = [{name = "orix developers", email = "pyxem.team@gmail.com"}]
description = "orix is an open-source Python library for handling crystal orientation mapping data"
license = {file = "LICENSE"}
From 735a06fbedf3aad8771d0a096a03dfaf19fdb718 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ha=CC=8Akon=20Wiik=20A=CC=8Anes?=
Date: Sun, 8 Sep 2024 19:05:57 +0200
Subject: [PATCH 6/6] Remove email as we want communication to happen on GitHub
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Håkon Wiik Ånes
---
pyproject.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pyproject.toml b/pyproject.toml
index bd543f7c..598b82b7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
[project]
name = "orix"
# conf.py assumes orix developers to be first author
-authors = [{name = "orix developers", email = "pyxem.team@gmail.com"}]
+authors = [{name = "orix developers"}]
description = "orix is an open-source Python library for handling crystal orientation mapping data"
license = {file = "LICENSE"}
readme = {file = "README.rst", content-type = "text/x-rst"}