From 3b6fa82a9d22da8ce8e29c2159d3ec005c2798d5 Mon Sep 17 00:00:00 2001 From: Eric Prestat Date: Sat, 28 Oct 2023 22:46:56 +0200 Subject: [PATCH 1/2] Add GitHub actions and templates --- .github/ISSUE_TEMPLATE/bug_report.md | 27 +++++++ .github/ISSUE_TEMPLATE/custom.md | 8 +++ .github/ISSUE_TEMPLATE/feature_request.md | 17 +++++ .github/PULL_REQUEST_TEMPLATE.md | 30 ++++++++ .github/workflows/black.yml | 11 +++ .github/workflows/build.yml | 65 +++++++++++++++++ .github/workflows/release.yml | 85 +++++++++++++++++++++++ .github/workflows/tests.yml | 52 ++++++++++++++ 8 files changed, 295 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/custom.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/black.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..949c35204 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,27 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: 'type: bug' + +--- + +#### Describe the bug +A clear and concise description of what the bug is. + +#### To Reproduce +Steps to reproduce the behavior: +``` +Minimum working example of code +``` + +#### Expected behavior +A clear and concise description of what you expected to happen. + +#### Python environement: + - exSpy version: 0.x.x + - HyperSpy version: 1.x.x + - Python version: 3.x + +#### Additional context +Add any other context about the problem here. If necessary, add screenshots to help explain your problem. diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md new file mode 100644 index 000000000..bdd4f85ed --- /dev/null +++ b/.github/ISSUE_TEMPLATE/custom.md @@ -0,0 +1,8 @@ +--- +name: Custom issue template +about: Describe this issue template's purpose here. +title: '' +labels: '' +--- + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..3f681faa2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: 'type: feature request' +assignees: '' + +--- + +#### Describe the functionality you would like to see. +A clear and concise description of what you would like to do. + +#### Describe the context +Do you want to extend existing functionalities, what types of signals should it apply to, etc. + +#### Additional information +Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..9dadaa450 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,30 @@ +### Requirements +* Read the [contributing guidelines](https://github.com/hyperspy/exspy/blob/main/CONTRIBUTING.rst). +* Fill out the template; it helps the review process and it is useful to summarise the PR. +* This template can be updated during the progression of the PR to summarise its status. + +*You can delete this section after you read it.* + +### Description of the change +A few sentences and/or a bulleted list to describe and motivate the change: +- Change A. +- Change B. +- etc. + +### Progress of the PR +- [ ] Change implemented (can be split into several points), +- [ ] docstring updated (if appropriate), +- [ ] update user guide (if appropriate), +- [ ] added tests, +- [ ] added line to CHANGES.rst, +- [ ] ready for review. + +### Minimal example of the bug fix or the new feature +```python +import exspy +import numpy as np +s = exspy.signals.EELSSpectrum(np.arange(100).reshape(10,10)) +# Your new feature... +``` + + diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 000000000..048e60008 --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,11 @@ +name: Lint + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + - uses: psf/black@stable diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..0b1171db7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,65 @@ +name: Build + +on: [push, pull_request] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + env: + PYTHON_VERSION: '3.11' + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + name: Install Python + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Display version + run: | + python --version + pip --version + + - name: Install pypa/build + run: | + pip install build + + - name: Build a binary wheel and a source tarball + run: | + python -m build + + - name: Display content dist folder + run: | + ls -l dist/ + + - uses: actions/upload-artifact@v3 + with: + path: ./dist/* + name: dist + + test: + name: Test Packaging + needs: build + runs-on: ubuntu-latest + env: + PYTHON_VERSION: '3.11' + steps: + - uses: actions/setup-python@v4 + name: Install Python + with: + python-version: ${{ env.PYTHON_VERSION }} + + - uses: actions/download-artifact@v3 + + - name: Display content working folder + run: | + ls -R + + - name: Install distribution + run: | + pip install --pre --find-links dist exspy[tests] + + - name: Test distribution + run: | + pytest --pyargs exspy diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..7662cf974 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,85 @@ +name: Release + +# This workflow builds the wheels "on tag". +# If run from the hyperspy/hyperspy repository, the wheels will be uploaded to pypi ; +# otherwise, the wheels will be available as a github artifact. +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + build_wheels: + name: Build wheels + 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/cibuildwheel@v2.14.0 + + - uses: actions/upload-artifact@v3 + with: + name: wheels + path: ./wheelhouse/*.whl + if-no-files-found: error + + make_sdist: + name: Make SDist + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Build SDist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v3 + with: + path: dist/*.tar.gz + + upload_to_pypi: + needs: [build_wheels, make_sdist] + runs-on: ubuntu-latest + 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 + path: dist + + - name: Display structure of downloaded files + run: ls -R + working-directory: dist + + - uses: pypa/gh-action-pypi-publish@release/v1 + if: 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 + needs: upload_to_pypi + permissions: + contents: write + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Create Release + id: create_release + uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..5f5f49217 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,52 @@ +name: Tests + +on: [push, pull_request] + +jobs: + run_test_site: + name: ${{ matrix.os }}-py${{ matrix.PYTHON_VERSION }}${{ matrix.LABEL }} + runs-on: ${{ matrix.os }}-latest + timeout-minutes: 30 + env: + MPLBACKEND: agg + strategy: + fail-fast: false + matrix: + os: [ubuntu, windows, macos] + PYTHON_VERSION: ['3.9', '3.10'] + LABEL: [''] + include: + - os: ubuntu + PYTHON_VERSION: '3.8' + - os: ubuntu + PYTHON_VERSION: '3.11' + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + name: Install Python + with: + python-version: ${{ matrix.PYTHON_VERSION }} + + - name: Display version + run: | + python --version + pip --version + + - name: Install + shell: bash + run: | + pip install -e .[tests] + + - name: Pip list + run: | + pip list + + - name: Run test suite + run: | + pytest --pyargs exspy + + - name: Upload coverage to Codecov + if: ${{ always() }} + uses: codecov/codecov-action@v3 From 6acf5a1b1a0e285e98e70a0119feffe33ca3594b Mon Sep 17 00:00:00 2001 From: Eric Prestat Date: Sat, 28 Oct 2023 23:03:53 +0200 Subject: [PATCH 2/2] Update dependency requirement --- setup.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 206946e50..ce1119f79 100644 --- a/setup.py +++ b/setup.py @@ -26,6 +26,12 @@ # https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies extra_feature_requirements = { + "gui-jupyter": [ + "hyperspy_gui_ipywidgets @ git+https://github.com/ericpre/hyperspy_gui_ipywidgets.git@hyperspy2.0", + ], + "gui-traitsui": [ + "hyperspy_gui_traitsui @ git+https://github.com/ericpre/hyperspy_gui_traitsui.git@hyperspy2.0", + ], "doc": [ "numpydoc", "pydata-sphinx-theme>=0.13", @@ -36,6 +42,7 @@ ], "tests": [ "pytest >= 5.0", + "pytest-mpl", "pytest-cov >= 2.8.1", ], "dev": ["black", "pre-commit >=1.16"], @@ -58,10 +65,10 @@ ], classifiers=[ "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "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 (GPLv3)", @@ -76,10 +83,19 @@ package_dir={"exspy": "exspy"}, extras_require=extra_feature_requirements, install_requires=[ - "hyperspy_gui_ipywidgets @ git+https://github.com/ericpre/hyperspy_gui_ipywidgets.git@hyperspy2.0", - "hyperspy_gui_traitsui @ git+https://github.com/ericpre/hyperspy_gui_traitsui.git@hyperspy2.0", + "dask[array]", + "hyperspy @ git+https://github.com/hyperspy/hyperspy@RELEASE_next_major", + "matplotlib", + "numexpr", + "numpy", + "pint", + "pooch", + "prettytable", + "requests", + "scipy", + "traits", ], - python_requires=">=3.7", + python_requires="~=3.8", package_data={ "": ["LICENSE", "README.rst"], "exspy": [