Skip to content

Commit

Permalink
Merge pull request #10 from ericpre/remove_setup.py
Browse files Browse the repository at this point in the history
Consolidate packaging in `pyproject.toml`
  • Loading branch information
ericpre authored Nov 14, 2023
2 parents b8c0de6 + 165217d commit 987e6a8
Show file tree
Hide file tree
Showing 64 changed files with 170 additions and 235 deletions.
69 changes: 0 additions & 69 deletions .github/workflows/build.yml

This file was deleted.

8 changes: 8 additions & 0 deletions .github/workflows/package_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Package & Test

on: [push, pull_request]

jobs:
package_and_test:
# Use the "reusable workflow" from the hyperspy organisation
uses: hyperspy/.github/.github/workflows/package_and_test.yml@main
70 changes: 29 additions & 41 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
name: Release
# Reusable workflow are not supported with trusted publisher
# https://github.com/pypa/gh-action-pypi-publish/issues/166
# copy and paste
# https://github.com/hyperspy/.github/blob/main/.github/workflows/release_pure_python.yml

# This workflow builds the wheels "on tag".
# If run from the hyperspy/hyperspy repository, the wheels will be uploaded to pypi ;
Expand All @@ -10,76 +14,60 @@ on:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
build_wheels:
name: Build wheels
build:
name: Build wheel and sdist
runs-on: ubuntu-latest
env:
CIBW_TEST_COMMAND: "pytest --pyargs exspy"
CIBW_TEST_EXTRAS: "tests"

steps:
- uses: actions/checkout@v3

- name: Build wheels
uses: pypa/[email protected]

- uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/*.whl
if-no-files-found: error
- uses: actions/checkout@v4

make_sdist:
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run build
run: |
pipx run build
- name: Build SDist
run: pipx run build --sdist
- name: Display built files
run: |
ls -shR
working-directory: dist

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
path: dist/*
name: artifacts

upload_to_pypi:
needs: [build_wheels, make_sdist]
needs: [build]
runs-on: ubuntu-latest
name: Upload to pypi
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- name: Download dist
uses: actions/download-artifact@v3
with:
name: artifact
path: dist

- name: Download wheels
uses: actions/download-artifact@v3
with:
name: wheels
name: artifacts
path: dist

- name: Display structure of downloaded files
run: ls -R
- name: Display downloaded files
run: |
ls -shR
working-directory: dist

- uses: pypa/gh-action-pypi-publish@release/v1
if: github.repository_owner == 'hyperspy'
if: ${{ startsWith(github.ref, 'refs/tags/') && github.repository_owner == 'hyperspy' }}
# See https://docs.pypi.org/trusted-publishers/using-a-publisher/

create_release:
# TODO: once we are happy with the workflow
# setup zenodo to create a DOI automatically
create_github_release:
# If zenodo is setup to create a DOI automatically on a GitHub release,
# this step will trigger the mining of the DOI
needs: upload_to_pypi
permissions:
contents: write
name: Create Release
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Create Release
id: create_release
if: ${{ startsWith(github.ref, 'refs/tags/') && github.repository_owner == 'hyperspy' }}
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, windows, macos]
PYTHON_VERSION: ['3.9', '3.10']
PYTHON_VERSION: ['3.9', '3.11']
LABEL: ['']
include:
- os: ubuntu
PYTHON_VERSION: '3.8'
- os: ubuntu
PYTHON_VERSION: '3.11'
PYTHON_VERSION: '3.10'
- os: ubuntu
PYTHON_VERSION: '3.12'

steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ https://holospy.readthedocs.io/en/latest/changes.html
(`HyperSpy #3082 <https://github.com/hyperspy/hyperspy/issues/3082>`_)
- Add functionality to fit the :ref:`EELS fine structure <eels.fine_structure>` using components, e.g. :py:class:`hyperspy.api.model.components1D.Gaussian`. (`HyperSpy #3206 <https://github.com/hyperspy/hyperspy/issues/3206>`_)
- Use reusable workflow from the hyperspy organisation for the doc workflow (`#13 <https://github.com/hyperspy/exspy/pull/13>`_)
- Consolidate packaging metadata in ``pyproject.toml``. (`#4 <https://github.com/hyperspy/exspy/pull/4>`_, `#10 <https://github.com/hyperspy/exspy/pull/10>`_)
- Use ``setuptools_scm`` to set holospy version at build time (`#10 <https://github.com/hyperspy/exspy/pull/10>`_)
- Add package and test workflow (`#10 <https://github.com/hyperspy/exspy/pull/10>`_)
- Add python 3.12 (`#10 <https://github.com/hyperspy/exspy/pull/10>`_)
- Add release workflow (`#10 <https://github.com/hyperspy/exspy/pull/10>`_)


Initiation (2023-10-28)
=======================
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
prune exspy/tests/drawing/plot_model
prune exspy/tests/drawing/plot_spectra_markers
15 changes: 14 additions & 1 deletion exspy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
from pathlib import Path

from . import components
from . import data
from . import models
from . import signals
from .misc import material
from ._defaults_parser import preferences
from ._version import __version__


if Path(__file__).parent.parent.name == "site-packages": # pragma: no cover
# Tested in the "build" workflow on GitHub CI
from importlib.metadata import version

__version__ = version("rosettasciio")
else:
# Editable install
from setuptools_scm import get_version

__version__ = get_version(Path(__file__).parent.parent)


__all__ = [
Expand Down
1 change: 0 additions & 1 deletion exspy/_version.py

This file was deleted.

2 changes: 1 addition & 1 deletion exspy/components/eels_double_power_law.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(
left_cutoff=0.0,
module="numexpr",
compute_gradients=False,
**kwargs
**kwargs,
):
super().__init__(
expression="where(x > left_cutoff, \
Expand Down
2 changes: 1 addition & 1 deletion exspy/components/volume_plasmon_drude.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(
fwhm=1.5,
module="numexpr",
compute_gradients=False,
**kwargs
**kwargs,
):
super().__init__(
expression="where(x > 0, intensity * (pe2 * x * fwhm) \
Expand Down
4 changes: 2 additions & 2 deletions exspy/models/edsmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def fit_background(
end_energy=None,
windows_sigma=(4.0, 3.0),
kind="single",
**kwargs
**kwargs,
):
"""
Fit the background in the energy range containing no X-ray line.
Expand Down Expand Up @@ -849,7 +849,7 @@ def get_lines_intensity(
plot_result=False,
only_one=True,
only_lines=("a",),
**kwargs
**kwargs,
):
"""
Return the fitted intensity of the X-ray lines.
Expand Down
2 changes: 1 addition & 1 deletion exspy/signals/eds_sem.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def create_model(self, auto_background=True, auto_add_lines=True, *args, **kwarg
auto_background=auto_background,
auto_add_lines=auto_add_lines,
*args,
**kwargs
**kwargs,
)
return model

Expand Down
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.
File renamed without changes.
Loading

0 comments on commit 987e6a8

Please sign in to comment.