Skip to content

Commit

Permalink
Enable tests for Python 3.10 (#339)
Browse files Browse the repository at this point in the history
* Enable tests for Python 3.10

* pep 621 pyproject.toml

* Update pyproject.toml

* Exclude pip 22.1

* Update pyproject.toml and  _metadata.py following the lead of anndata

* Fix reference to author in docs
  • Loading branch information
grst committed May 19, 2022
1 parent 580b3c3 commit 2c5b99e
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 48 deletions.
1 change: 1 addition & 0 deletions .conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ requirements:
# requires all dependencies to be installed at build time.
host:
- python >=3.7
- pip!=22.1 # https://github.com/pypa/pip/issues/11110
- flit
- setuptools_scm
- pytoml
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
# TODO this is to workaround an issue with the skbio dependency
# This will work in the next release, see https://github.com/biocore/scikit-bio/pull/1813
run: |
# https://github.com/pypa/pip/issues/11110
python -m pip install --upgrade "pip!=22.1"
# TODO this is to workaround an issue with the skbio dependency
# This will work in the next release, see https://github.com/biocore/scikit-bio/pull/1813
pip install git+https://github.com/grst/scikit-bio.git@a3423e4
pip install .[doc,test,rpack,dandelion]
- name: run sphinx
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Publish on PyPI
on:
push:
tags:
- 'v*.*.*'
- "v*.*.*"

jobs:
deploy:
Expand All @@ -19,7 +19,8 @@ jobs:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install flit
# https://github.com/pypa/pip/issues/11110
python -m pip install flit "pip!=22.1"
pip install .
- name: Build and publish
env:
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- { python-version: 3.7, os: ubuntu-latest }
- { python-version: 3.8, os: ubuntu-latest }
- { python-version: 3.9, os: ubuntu-latest }
# - { python-version: "3.10", os: ubuntu-latest }
- { python-version: "3.10", os: ubuntu-latest }
- { python-version: 3.9, os: macos-latest }
- { python-version: 3.9, os: windows-latest }

Expand Down Expand Up @@ -45,9 +45,11 @@ jobs:
with:
python-version: ${{ matrix.config.python-version }}
- name: Install dependencies
# TODO this is to workaround an issue with the skbio dependency
# This will work in the next release, see https://github.com/biocore/scikit-bio/pull/1813
run: |
# https://github.com/pypa/pip/issues/11110
python -m pip install --upgrade "pip!=22.1"
# TODO this is to workaround an issue with the skbio dependency
# This will work in the next release, see https://github.com/biocore/scikit-bio/pull/1813
pip install git+https://github.com/grst/scikit-bio.git@a3423e4
pip install .[test,rpack,dandelion]
- name: Check black formatting
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/ambv/black
rev: 22.1.0
rev: 22.3.0
hooks:
- id: black
language_version: python3.10
10 changes: 6 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@
sys.path.insert(0, str(HERE.parent))
sys.path.insert(0, str(HERE / "extensions"))

from scirpy import __author__, __version__
from importlib.metadata import metadata

info = metadata("scirpy")

# ignore Future warnings (which are caused by dependencies)
warnings.filterwarnings("ignore", category=FutureWarning)

# General information
project = "scirpy"
author = __author__
project = info["Name"]
author = info["Author"]
copyright = f"{datetime.now():%Y}, {author}."
version = __version__
version = info["Version"]

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]
Expand Down
25 changes: 15 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ requires = [
]
build-backend = 'flit_core.buildapi'

[tool.flit.metadata]
module = 'scirpy'
author = 'Gregor Sturm, Tamas Szabo'
author-email = 'gregor.sturm@i-med.ac.at'
home-page = 'https://github.com/grst/scirpy'
description-file = "README.rst"
[project]
name = 'scirpy'
authors = [
{name = "Gregor Sturm", email="gregor.sturm@i-med.ac.at"},
{name= "Tamas Szabo"},
]
readme = {file = "README.rst", content-type="text/x-rst"}
classifiers = [
'License :: OSI Approved :: BSD License',
'Development Status :: 4 - Beta',
Expand All @@ -23,11 +24,11 @@ classifiers = [
'Programming Language :: R'
]
requires-python = '>= 3.7'
requires = [
dependencies = [
'anndata>=0.7.6',
'scanpy>=1.6.0',
'pandas>=1.0',
'numpy>=1.17.0',
'numpy>=1.17.0',
'scipy',
# parasail 1.2.1 fails to be installd on MacOS
'parasail != 1.2.1',
Expand All @@ -46,8 +47,9 @@ requires = [
'importlib_metadata>=0.7; python_version < "3.8"',
'pycairo>=1.20; sys_platform == "win32"',
]
dynamic = ["version", "description"]

[tool.flit.metadata.requires-extra]
[project.optional-dependencies]
rpack = [
'rectangle-packer',
]
Expand Down Expand Up @@ -78,8 +80,11 @@ doc = [
'sc-dandelion',
]

[tool.flit.metadata.urls]
[project.urls]
Documentation = 'https://scverse.org/scirpy/'
Home-page = 'https://scverse.org/scirpy/'
Source = "https://github.com/scverse/scirpy"


[tool.pytest.ini_options]
markers = [
Expand Down
2 changes: 1 addition & 1 deletion scirpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Python library for single-cell adaptive immune receptor repertoire (AIRR) analysis"""

from ._metadata import __version__, __author__, __email__, within_flit
from ._metadata import __version__, within_flit

if not within_flit():
from scanpy import AnnData, read_h5ad
Expand Down
51 changes: 26 additions & 25 deletions scirpy/_metadata.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
"""Metadata. Adapted from https://github.com/theislab/scanpy/pull/1374/."""
import traceback
from pathlib import Path

here = Path(__file__).parent


def refresh_entry_points():
"""\
Under some circumstances, (e.g. when installing a PEP 517 package via pip),
pkg_resources.working_set.entries is stale. This tries to fix that.
See https://github.com/pypa/setuptools_scm/issues/513
"""
try:
import sys
import pkg_resources

ws: pkg_resources.WorkingSet = pkg_resources.working_set
for entry in sys.path:
ws.add_entry(entry)
except Exception:
pass


try:
from setuptools_scm import get_version
import pytoml

proj = pytoml.loads((here.parent / "pyproject.toml").read_text())
metadata = proj["tool"]["flit"]["metadata"]

# The `split` removes the "local" version part (PEP440), e.g. from
# 0.6.1.dev5+ga652c20.d20210130. Leaving the local part, results in the following
# error message:
# WARNING: Built wheel for scirpy is invalid: Wheel has unexpected file name:
# expected '0.6.1.dev5+ga652c20.d20210130', got '0.6.1.dev5-ga652c20.d20210130'
#
# TODO I expect this to be a temporary issue with either flit or wheel, as
# this has worked before.
__version__ = get_version(
# Allegedly, the parameters from pyproject.toml should be passed automatically.
# However, this didn't work, so I pass them explicitly here.
root="..",
relative_to=__file__,
**proj["tool"]["setuptools_scm"],
).split("+")[0]
__author__ = metadata["author"]
__email__ = metadata["author-email"]

refresh_entry_points()
__version__ = get_version(root="..", relative_to=__file__)
except (ImportError, LookupError, FileNotFoundError):
from ._compat import pkg_metadata

metadata = pkg_metadata(here.name)
__version__ = metadata["Version"]
__author__ = metadata["Author"]
__email__ = metadata["Author-email"]


def within_flit():
"""\
Checks if we are being imported by flit.
This is necessary so flit can import __version__ without all depedencies installed.
There are a few options to make this hack unnecessary, see:
https://github.com/takluyver/flit/issues/253#issuecomment-737870438
"""
for frame in traceback.extract_stack():
if frame.name == "get_docstring_and_version_via_import":
return True
Expand Down

0 comments on commit 2c5b99e

Please sign in to comment.