Skip to content

Commit

Permalink
Merge pull request #517 from hakonanes/from-setup-to-pyproject
Browse files Browse the repository at this point in the history
Change build backend from setuptools to Hatch
  • Loading branch information
hakonanes committed Sep 8, 2024
2 parents b327412 + 735a06f commit 886796a
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 205 deletions.
27 changes: 5 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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 }}
Expand All @@ -68,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') }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 0 additions & 14 deletions MANIFEST.in

This file was deleted.

17 changes: 5 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
.. raw:: html

<p>
<h1>
<a href="https://orix.readthedocs.io"><img valign="middle" src="https://github.com/raw/pyxem/orix/develop/doc/_static/img/orix_logo.png" width="50" alt="orix logo"/></a>
orix
</h1>
</p>

.. 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://github.com/raw/pyxem/orix/develop/doc/_static/img/orix_logo.png
:width: 50

orix is an open-source Python library for analysing orientations and crystal symmetry.

Expand Down
23 changes: 15 additions & 8 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion doc/dev/building_writing_documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ We use :doc:`nbval <nbval:index>` 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
---------------------
Expand Down
4 changes: 0 additions & 4 deletions orix/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
109 changes: 109 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "orix"
# conf.py assumes orix developers to be first author
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"}
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",
"outdated",
"pre-commit >= 1.16",
"orix[doc,tests,coverage]",
]

[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
40 changes: 0 additions & 40 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit 886796a

Please sign in to comment.