Skip to content

Commit

Permalink
Merge 0cc670d into 02b8330
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Feb 15, 2023
2 parents 02b8330 + 0cc670d commit d5192f6
Show file tree
Hide file tree
Showing 13 changed files with 1,440 additions and 523 deletions.
34 changes: 28 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
fail-fast: true
matrix:
os: ["windows-latest", "ubuntu-latest", "macos-latest"]
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11"]
experimental: [false]
include:
- python-version: "3.9"
- python-version: "3.11"
os: "ubuntu-latest"
experimental: true

Expand All @@ -30,13 +30,14 @@ jobs:
- name: Setup Conda Environment
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true
python-version: ${{ matrix.python-version }}
mamba-version: "*"
activate-environment: test-environment
channels: conda-forge
channel-priority: strict
environment-file: continuous_integration/environment.yaml
activate-environment: test-environment

- name: Install unstable dependencies
if: matrix.experimental == true
Expand All @@ -60,15 +61,36 @@ jobs:
shell: bash -l {0}
run: |
pip install --no-deps -e .
# pip forces non-wheel builds if we provide --cython-coverage as a --build-option
# and that's way too slow
python setup.py build_ext --inplace --cython-coverage --force
- name: Run unit tests
shell: bash -l {0}
run: |
pytest --cov=trollimage trollimage/tests --cov-report=xml
pytest --cov=trollimage trollimage/tests --cov-report=xml --cov-report=
- name: Upload unittest coverage to Codecov
uses: codecov/codecov-action@v3
with:
flags: unittests
file: ./coverage.xml
env_vars: OS,PYTHON_VERSION,UNSTABLE

- name: Coveralls Parallel
# See https://github.com/AndreMiras/coveralls-python-action/pull/16
uses: djhoese/coveralls-python-action@feature-cython-coverage
with:
flag-name: run-${{ matrix.test_number }}
parallel: true
if: runner.os == 'Linux'

coveralls:
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
# See https://github.com/AndreMiras/coveralls-python-action/pull/16
uses: djhoese/coveralls-python-action@feature-cython-coverage
with:
parallel-finished: true
25 changes: 0 additions & 25 deletions .github/workflows/deploy-sdist.yaml

This file was deleted.

76 changes: 76 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build Package


on:
push:
pull_request:
release:
types:
- published

jobs:
build_sdist:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3

- name: Create sdist
shell: bash -l {0}
run: |
python -m pip install -q build
python -m build -s
- name: Upload sdist to build artifacts
uses: actions/upload-artifact@v3
with:
name: sdist
path: dist/*.tar.gz

build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macOS-11]

steps:
- uses: actions/checkout@v3

- name: Build wheels
uses: pypa/cibuildwheel@v2.12.0
env:
CIBW_SKIP: "cp36-* cp37-* cp38-* pp* *-i686"

- uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/*.whl

upload_to_pypi:
needs: [build_sdist, build_wheels]
runs-on: ubuntu-latest
steps:
- name: Download sdist artifact
uses: actions/download-artifact@v2
with:
name: sdist
path: dist
- name: Download wheels artifact
uses: actions/download-artifact@v2
with:
name: wheels
path: dist
- name: Publish package to Test PyPI
if: github.event.action != 'published' && github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@v1.4.1
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
- name: Publish package to PyPI
if: github.event.action == 'published'
uses: pypa/gh-action-pypi-publish@v1.4.1
with:
user: __token__
password: ${{ secrets.pypi_password }}
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[build-system]
requires = ["setuptools", "wheel", "oldest-supported-numpy", "Cython", "versioneer"]
build-backend = "setuptools.build_meta"

[tool.coverage.run]
relative_files = true
plugins = ["Cython.Coverage"]
omit = ["trollimage/version.py", "versioneer.py"]
9 changes: 3 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ universal=1
max-line-length = 120
exclude =
doc/conf.py
trollimage/version.py
versioneer.py

[versioneer]
VCS = git
style = pep440
versionfile_source = trollimage/version.py
versionfile_build =
versionfile_build = trollimage/version.py
tag_prefix = v

[coverage:run]
omit =
trollimage/version.py
versioneer.py
73 changes: 68 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,98 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Setup for trollimage."""
import sys
from typing import Any

from setuptools import setup
import versioneer
import numpy as np
from Cython.Build import build_ext
from Cython.Distutils import Extension

if sys.platform.startswith("win"):
extra_compile_args = []
else:
extra_compile_args = ["-O3"]

EXTENSIONS = [
Extension(
'trollimage._colorspaces',
sources=['trollimage/_colorspaces.pyx'],
extra_compile_args=extra_compile_args,
include_dirs=[np.get_include()],
),
]

cython_directives: dict[str, Any] = {
"language_level": "3",
}


class CythonCoverageBuildExtCommand(build_ext):
"""Simple command extension to add Cython coverage flag.
With this class included in the build we are able to pass
``--cython-coverage`` to compile Cython modules with flags necessary to
report test coverage.
"""

user_options = build_ext.user_options + [
('cython-coverage', None, None),
]

def initialize_options(self):
"""Initialize command line flag options to default values."""
super().initialize_options()
self.cython_coverage = False # noqa

def run(self):
"""Build extensions and handle cython coverage flags."""
define_macros = []
if self.cython_coverage:
print("Enabling directives/macros for Cython coverage support")
cython_directives.update({
"linetrace": True,
"profile": True,
})
define_macros.extend([
("CYTHON_TRACE", "1"),
("CYTHON_TRACE_NOGIL", "1"),
])
for ext in EXTENSIONS:
ext.define_macros = define_macros
ext.cython_directives.update(cython_directives)
super().run()


cmdclass = versioneer.get_cmdclass(cmdclass={"build_ext": CythonCoverageBuildExtCommand})

with open('README.rst', 'r') as readme_file:
long_description = readme_file.read()

setup(name="trollimage",
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
cmdclass=cmdclass,
description='Pytroll imaging library',
long_description=long_description,
author='Martin Raspaud',
author_email='martin.raspaud@smhi.se',
classifiers=["Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 " +
"or later (GPLv3+)",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Scientific/Engineering"],
url="https://github.com/pytroll/trollimage",
packages=['trollimage'],
zip_safe=False,
install_requires=['numpy>=1.13', 'pillow'],
python_requires='>=3.6',
install_requires=['numpy>=1.20', 'pillow'],
python_requires='>=3.9',
extras_require={
'geotiff': ['rasterio>=1.0'],
'xarray': ['xarray', 'dask[array]'],
},
tests_require=['xarray', 'dask[array]', 'pyproj', 'pyresample'],
ext_modules=EXTENSIONS,
)
18 changes: 6 additions & 12 deletions trollimage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Copyright (c) 2013 Martin Raspaud

# Author(s):

# Martin Raspaud <martin.raspaud@smhi.se>

#
# Copyright (c) 2013-2023 Trollimage developers
#
# This program 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.

#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.

"""The trollimage package
"""
"""The trollimage package."""

from .version import get_versions
__version__ = get_versions()['version']
Expand Down

0 comments on commit d5192f6

Please sign in to comment.