Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minimal install and tidy up #13

Merged
merged 13 commits into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build

on: [push, pull_request]

jobs:
build-and-test:
name: Build
runs-on: ubuntu-latest
env:
PYTHON_VERSION: '3.10'

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3
name: Install Python
with:
python-version: '3.10'

- 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 dist/

- uses: actions/upload-artifact@v3
with:
path: ./dist/*

- name: Install distribution
run: |
pip install --pre --find-links dist rosettasciio[all,tests]

- name: Install HyperSpy (dev)
run: |
pip install https://github.com/hyperspy/hyperspy/archive/refs/heads/RELEASE_next_major.zip

- name: Test distribution
run: |
pytest --pyargs rsciio --reruns 3 -n 2
34 changes: 23 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,27 @@ jobs:
matrix:
os: [ubuntu, windows, macos]
PYTHON_VERSION: ['3.8', '3.9']
PIP_SELECTOR: ['[all, tests]']
LABEL: ['']
include:
# test oldest supported version of main dependencies on python 3.6
- os: ubuntu
PYTHON_VERSION: '3.7'
OLDEST_SUPPORTED_VERSION: true
DEPENDENCIES: matplotlib==3.1.3 numpy==1.17.1 scipy==1.1 imagecodecs==2020.1.31 tifffile==2020.2.16 dask==2.11.0 distributed==2.11.0 numba==0.52
PIP_SELECTOR: '[all, tests]'
LABEL: -oldest
LABEL: '-oldest'
# test minimum requirement
- os: ubuntu
PYTHON_VERSION: '3.8'
PIP_SELECTOR: '[tests]'
LABEL: -minimum
LABEL: '-minimum'
- os: ubuntu
PYTHON_VERSION: '3.8'
LABEL: '-minimum-wo-hyperspy'
- os: ubuntu
PYTHON_VERSION: '3.8'
LABEL: '-wo-hyperspy'
- os: ubuntu
PYTHON_VERSION: '3.7'
PIP_SELECTOR: '[all, tests]'
- os: ubuntu
PYTHON_VERSION: '3.10'
PIP_SELECTOR: '[all, tests]'

steps:
- uses: actions/checkout@v3
Expand All @@ -43,24 +44,35 @@ jobs:
with:
python-version: ${{ matrix.PYTHON_VERSION }}

- name: Set Environment Variable
shell: bash
# Set PIP_SELECTOR environment variable according to matrix.LABEL
run: |
if [[ -n "${{ matrix.LABEL }}" && "${{ matrix.LABEL }}" == *"minimum"* ]]; then
PIP_SELECTOR="[tests]"
else
PIP_SELECTOR="[all, tests]"
fi
echo "PIP_SELECTOR=${PIP_SELECTOR}" >> $GITHUB_ENV

- name: Display version
run: |
python --version
pip --version

- name: Install oldest supported version
if: ${{ matrix.OLDEST_SUPPORTED_VERSION }}
if: contains(matrix.LABEL, 'oldest')
run: |
pip install ${{ matrix.DEPENDENCIES }}

- name: Install
shell: bash
run: |
pip install --upgrade -e .'${{ matrix.PIP_SELECTOR }}'
pip install --upgrade -e .'${{ env.PIP_SELECTOR }}'

- name: Install (HyperSpy dev)
if: "!contains(matrix.LABEL, 'wo-hyperspy')"
# Need to install hyperspy dev until hyperspy 2.0 is released
shell: bash
run: |
pip install https://github.com/hyperspy/hyperspy/archive/refs/heads/RELEASE_next_major.zip

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/docs/_build/*
/build/*
/dist/*
/RosettaSciIO.egg-info/*
*__pycache__*
*test_compilers.obj
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include *.txt
include *.rst
recursive-include rsciio *.pyx
recursive-include docs *.txt *.rst *.pdf *py *bat makefile
recursive-include rsciio *.pyx *specifications.yaml
recursive-include docs *.txt *.rst *.pdf *.py *.bat makefile
include rsciio/tests/bruker_data/test_compilers.c

9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ requires = ["setuptools>=49.0", "wheel", "cython", "pyyaml"]
build-backend = "setuptools.build_meta:__legacy__"

[tool.pytest.ini_options]
# Note we may need to use `-n 2` argument for pytest-xdist on CI
# Note we may need to use `-n 2` argument for pytest-xdist on CI
# due to https://github.com/pytest-dev/pytest-xdist/issues/9.
addopts = "-ra -n auto --dist loadfile"
minversion = "6.0"
testpaths = [
"rsciio/tests",
"rsciio/tests",
]

[tool.towncrier]
Expand Down Expand Up @@ -62,7 +62,10 @@ testpaths = "rsciio/tests/"
[tool.coverage.run]
branch = true
source = ["rsciio"]
omit = ["rsciio/tests/*"]
omit = [
"rsciio/tests/*",
"setup.py",
]

[tool.coverage.report]
precision = 2
10 changes: 10 additions & 0 deletions rsciio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,13 @@
specs = yaml.safe_load(stream)
specs["api"] = "rsciio.%s.api" % os.path.split(sub)[1]
IO_PLUGINS.append(specs)


__all__ = [
"__version__",
"IO_PLUGINS",
]


def __dir__():
return sorted(__all__)
30 changes: 30 additions & 0 deletions rsciio/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Copyright 2007-2022 The HyperSpy developers
#
# This file is part of RosettaSciIO.
#
# RosettaSciIO is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RosettaSciIO is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RosettaSciIO. If not, see <https://www.gnu.org/licenses/#GPL>.

from packaging.version import Version

try:
import hyperspy

if Version(hyperspy.__version__) < Version("2.0.dev"):
raise Exception(
"To run the test suite using hyperspy, \
hyperspy 2.0 or higher is required."
)
except ImportError:
pass
2 changes: 0 additions & 2 deletions rsciio/digital_micrograph/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@
import dateutil.parser

import numpy as np
import traits.api as t
from copy import deepcopy

import rsciio.utils.utils_readfile as iou
from rsciio.exceptions import DM3TagIDError, DM3DataTypeError, DM3TagTypeError
import rsciio.utils.tools
from box import Box


Expand Down