Skip to content

Commit

Permalink
Merge pull request #17 from Erotemic/reduce_dependency_footprint
Browse files Browse the repository at this point in the history
Reduce dependency footprint
  • Loading branch information
jack89roberts committed Jan 7, 2022
2 parents f9588b1 + 39f109b commit 021a0bf
Show file tree
Hide file tree
Showing 18 changed files with 808 additions and 476 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
ignore=E203
max-line-length=88
108 changes: 87 additions & 21 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,107 @@ name: Tests

on:
push:
paths:
- 'distinctipy/**'
- 'tests/**'
- 'requirements.txt'
- 'setup.py'
- '.github/workflows/pythonapp.yml'
pull_request:
branches:
- main
- develop

jobs:
build:

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[tests]
- name: Code quality checks
run: |
isort --check-only .
black --check .
flake8
build_and_test:

name: ${{ matrix.python-version }} ${{ matrix.depsize }} on ${{ matrix.os }}, arch=${{ matrix.arch }}
runs-on: ${{ matrix.os }}

strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
os: [ubuntu-latest, windows-latest, macOS-latest]
arch: [auto]
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
#- 'pypy-3.7' # see https://github.com/pandas-dev/pandas/issues/44253
depsize:
- 'minimal'
- 'full'

steps:
- uses: actions/checkout@v1
- name: Checkout source
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies

- name: Upgrade pip
run: |
python -m pip install --upgrade pip
pip install .
- name: Lint with flake8
- name: Install full dependencies
if: matrix.depsize == 'full'
shell: bash
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
pip install .[all,tests]
- name: Install minimal dependencies
if: matrix.depsize == 'minimal'
shell: bash
run: |
pip install .[tests]
- name: Test with pytest
shell: bash
run: |
pip install pytest
pytest
mkdir -p _empty_workspace
cd _empty_workspace
pytest --cov=distinctipy --cov-report=term ../tests
# Give coverage file a distinct name for each runner
CUSTOM_RUNNER_ID="${CI_PYTHON_VERSION}_${GITHUB_RUN_ID}_${RUNNER_OS}"
mv .coverage "../.coverage.${CUSTOM_RUNNER_ID}"
cd ..
- name: Set up Python 3.8 to combine coverage Linux
if: runner.os == 'Linux'
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Combine coverage Linux
if: runner.os == 'Linux'
run: |
python -m pip install coverage[toml]
coverage combine .
coverage xml -o ./tests/coverage.xml
find . -name .coverage.*
find . -name coverage.xml
- name: Codecov Upload
uses: codecov/codecov-action@v2.1.0
with:
file: ./tests/coverage.xml
2 changes: 2 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
profile=black
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
![distinctipy logo](https://raw.githubusercontent.com/alan-turing-institute/distinctipy/main/distinctipy_logo.png)


![tests](https://github.com/alan-turing-institute/distinctipy/workflows/Tests/badge.svg)
![build](https://github.com/alan-turing-institute/distinctipy/workflows/Build/badge.svg)
[![codecov](https://codecov.io/gh/alan-turing-institute/distinctipy/branch/main/graph/badge.svg)](https://codecov.io/gh/alan-turing-institute/distinctipy)
[![DOI](https://zenodo.org/badge/188444660.svg)](https://zenodo.org/badge/latestdoi/188444660)
[![Documentation Status](https://readthedocs.org/projects/distinctipy/badge/?version=latest)](https://distinctipy.readthedocs.io/en/latest/?badge=latest)

Expand Down Expand Up @@ -30,6 +32,25 @@ cd distinctipy
pip install .
```

### Optional Dependencies

Starting in version 1.2.1 `distinctipy` no longer bundles `matplotlib`, `pandas` or dev dependencies in the default installation. If you wish to view
colours (e.g. with `distinctipy.color_swatch`) or examples you will need `matplotlib` and `pandas` installed. To do this, either install `distinctipy`
with the optional flag:
```bash
pip install distinctipy[optional]
```

Or install them separately:
```bash
pip install matplotlib pandas
```

For developers, to install the stack needed to run tests, generate docs etc. use the `[all]` flag:
```bash
pip install distinctipy[all]
```

## Usage and Examples

*distinctipy* can:
Expand Down
16 changes: 3 additions & 13 deletions distinctipy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

name = "distinctipy"

__version__ = "1.2.0"
__version__ = "1.2.1"

# Expose these module names and their internals in the top-level API
__external__ = ["distinctipy"]
Expand All @@ -27,11 +27,7 @@
"""

# Everything after this point is autogenerate with mkinit
from . import colorblind
from . import colorsets
from . import distinctipy
from . import examples

from . import colorblind, colorsets, distinctipy, examples
from .distinctipy import (
BLACK,
BLUE,
Expand All @@ -56,13 +52,7 @@
get_text_color,
invert_colors,
)
from .examples import (
compare_clusters,
compare_colors,
)
from distinctipy import (
name,
)
from .examples import compare_clusters, compare_colors

__all__ = [
"BLACK",
Expand Down
Loading

0 comments on commit 021a0bf

Please sign in to comment.