Skip to content

Commit

Permalink
Merge pull request #121 from scipp/complete-switch-to-namespace-package
Browse files Browse the repository at this point in the history
Complete switch to namespace package
  • Loading branch information
nvaytet authored Apr 4, 2024
2 parents 0371984 + b067b62 commit 8ddea00
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 61 deletions.
4 changes: 2 additions & 2 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 0c28de4
_commit: '2955216'
_src_path: gh:scipp/copier_template
description: SANS data reduction for the European Spallation Source
max_python: '3.12'
min_python: '3.10'
namespace_package: ''
namespace_package: ess
nightly_deps: plopp,sciline,scippneutron,scippnexus,scipp
orgname: scipp
prettyname: ESSsans
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

name: CI

on:
Expand All @@ -24,15 +21,16 @@ jobs:
run: |
echo "min_python=$(cat .github/workflows/python-version-ci)" >> $GITHUB_OUTPUT
echo "min_tox_env=py$(cat .github/workflows/python-version-ci | sed 's/\.//g')" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version-file: '.github/workflows/python-version-ci'
- run: python -m pip install --upgrade pip
- run: python -m pip install -r requirements/ci.txt
- run: tox -e static
- uses: stefanzweifel/git-auto-commit-action@v5
- uses: pre-commit/[email protected]
with:
extra_args: --all-files
- uses: pre-commit-ci/[email protected]
if: always()
with:
commit_message: Apply automatic formatting
msg: Apply automatic formatting

tests:
name: Tests
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

name: Docs

on:
Expand Down Expand Up @@ -47,11 +44,11 @@ jobs:
runs-on: 'ubuntu-22.04'
steps:
- run: sudo apt install --yes graphviz pandoc
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch == '' && github.ref_name || inputs.branch }}
fetch-depth: 0 # history required so cmake can determine version
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version-file: '.github/workflows/python-version-ci'
- run: python -m pip install --upgrade pip
Expand All @@ -62,12 +59,12 @@ jobs:
if: ${{ inputs.version == '' }}
- run: tox -e linkcheck
if: ${{ inputs.linkcheck }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: docs_html
path: html/

- uses: JamesIves/github-pages-deploy-action@v4.4.3
- uses: JamesIves/github-pages-deploy-action@v4.5.0
if: ${{ inputs.publish }}
with:
branch: gh-pages
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/nightly_at_main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

name: Nightly test at main branch

on:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/nightly_at_release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

name: Nightly tests at latest release

on:
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

name: Release

on:
Expand All @@ -18,7 +15,7 @@ jobs:
runs-on: 'ubuntu-22.04'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0 # history required so setuptools_scm can determine version
Expand All @@ -31,7 +28,7 @@ jobs:
boa
- run: conda mambabuild --channel conda-forge --channel scipp --no-anaconda-upload --override-channels --output-folder conda/package conda

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: conda-package-noarch
path: conda/package/noarch/*.tar.bz2
Expand All @@ -41,11 +38,11 @@ jobs:
runs-on: 'ubuntu-22.04'

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0 # history required so setuptools_scm can determine version

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version-file: '.github/workflows/python-version-ci'

Expand All @@ -56,7 +53,7 @@ jobs:
run: python -m build

- name: Upload wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
Expand All @@ -71,7 +68,7 @@ jobs:
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
- uses: pypa/[email protected].10
- uses: pypa/[email protected].14

upload_conda:
name: Deploy Conda
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

name: Test

on:
Expand Down Expand Up @@ -48,16 +45,16 @@ jobs:
runs-on: ${{ inputs.os-variant }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ inputs.checkout_ref }}
- uses: actions/setup-python@v3
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- run: python -m pip install --upgrade pip
- run: python -m pip install -r ${{ inputs.pip-recipe }}
- run: tox -e ${{ inputs.tox-env }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: ${{ inputs.coverage-report }}
with:
name: CoverageReport
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/unpinned.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

name: Unpinned tests at latest release

on:
Expand Down
4 changes: 3 additions & 1 deletion conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ requirements:

test:
imports:
- esssans
- ess.sans
- ess.isissans
- ess.loki
requires:
- pytest
source_files:
Expand Down
2 changes: 1 addition & 1 deletion docs/_templates/doc_version.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<!-- This will display the version of the docs -->
Current {{ project }} version: {{ version }} (<a href="https://github.com/scipp/{{ project|lower }}/releases">older versions</a>).
Current {{ project }} version: {{ version }} (<a href="https://github.com/{{orgname}}/{{ project|lower }}/releases">older versions</a>).
4 changes: 4 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'sphinx_autodoc_typehints',
'sphinx_copybutton',
'sphinx_design',
'nbsphinx',
'myst_parser',
]

try:
import sciline.sphinxext.domain_types # noqa: F401

extensions.append('sciline.sphinxext.domain_types')
except ModuleNotFoundError:
pass


myst_enable_extensions = [
"amsmath",
"colon_fence",
Expand Down Expand Up @@ -90,6 +93,7 @@
'scipp.core.data_group.DataGroup': 'scipp.DataGroup',
}


# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

Expand Down
7 changes: 2 additions & 5 deletions requirements/base.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Temporary until questionary (dep of copier) updates
# See https://github.com/tmbo/questionary/blob/2df265534f3eb77aafcf70902e53e80beb1793e0/pyproject.toml#L36C43-L36C110
prompt-toolkit==3.0.36
# Temporary pinned until prompt-tookit conflict is resolved.
ipython==8.9.0
# Anything above "--- END OF CUSTOM SECTION ---"
# will not be touched by ``make_base.py``
# --- END OF CUSTOM SECTION ---
# The following was generated by 'tox -e deps', DO NOT EDIT MANUALLY!
dask
Expand Down
3 changes: 3 additions & 0 deletions requirements/dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ copier
jupyterlab
pip-compile-multi
pre-commit

# See https://github.com/copier-org/copier/issues/1568
pyyaml-include<2
5 changes: 1 addition & 4 deletions requirements/make_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

import sys
from argparse import ArgumentParser
from pathlib import Path
Expand Down Expand Up @@ -43,7 +40,7 @@ def write_dependencies(dependency_name: str, dependencies: List[str]) -> None:
with open("../pyproject.toml", "rb") as toml_file:
pyproject = tomli.load(toml_file)
dependencies = pyproject["project"].get("dependencies")
if not dependencies:
if dependencies is None:
raise RuntimeError("No dependencies found in pyproject.toml")
dependencies = [dep.strip().strip('"') for dep in dependencies]

Expand Down
7 changes: 7 additions & 0 deletions src/ess/isissans/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2024 Scipp contributors (https://github.com/scipp)

import importlib.metadata

from . import components, data, general, io, sans2d
from .components import DetectorBankOffset, MonitorOffset, SampleOffset
from .io import CalibrationFilename
from .visualization import plot_flat_detector_xy

try:
__version__ = importlib.metadata.version(__package__ or __name__)
except importlib.metadata.PackageNotFoundError:
__version__ = "0.0.0"

providers = components.providers + general.providers + io.providers

del importlib

__all__ = [
'CalibrationFilename',
Expand Down
9 changes: 9 additions & 0 deletions src/ess/loki/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)

import importlib.metadata

from . import data, general, io
from .general import default_parameters

try:
__version__ = importlib.metadata.version(__package__ or __name__)
except importlib.metadata.PackageNotFoundError:
__version__ = "0.0.0"

providers = general.providers + io.providers

del importlib

__all__ = ['data', 'general', 'io', 'providers', 'default_parameters']
11 changes: 5 additions & 6 deletions src/ess/sans/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2024 Scipp contributors (https://github.com/scipp)

# flake8: noqa
import importlib.metadata

try:
__version__ = importlib.metadata.version(__package__ or __name__)
except importlib.metadata.PackageNotFoundError:
__version__ = "0.0.0"

from . import (
beam_center_finder,
common,
Expand All @@ -22,6 +16,11 @@
from .direct_beam import direct_beam
from .types import BackgroundSubtractedIofQ, IofQ, ReturnEvents, SampleRun

try:
__version__ = importlib.metadata.version(__package__ or __name__)
except importlib.metadata.PackageNotFoundError:
__version__ = "0.0.0"

providers = (
*conversions.providers,
*i_of_q.providers,
Expand Down
7 changes: 5 additions & 2 deletions tests/package_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2024 Scipp contributors (https://github.com/scipp)
import ess.sans as pkg
import pytest

from ess import isissans, loki, sans

def test_has_version():

@pytest.mark.parametrize('pkg', [sans, loki, isissans])
def test_has_version(pkg):
assert hasattr(pkg, '__version__')

0 comments on commit 8ddea00

Please sign in to comment.