Skip to content

Commit 4238f6b

Browse files
committed
Switch to flit (#478)
This reverts commit f8ed61f.
1 parent 5f3be07 commit 4238f6b

9 files changed

+131
-120
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __pycache__/
99
/build/
1010
/dist/
1111
/*.egg-info/
12+
/setup.py
1213

1314
# Tests and coverage
1415
/.pytest_cache/

.travis.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ matrix:
88
include:
99
- name: static analysis
1010
python: "3.7"
11-
install: pip install .[dev,doc]
11+
install: pip install .[dev]
1212
script:
1313
- black . --check --diff
14-
- python setup.py check --restructuredtext --strict
1514
- rst2html.py --halt=2 README.rst >/dev/null
1615
after_success: skip
1716
python:
1817
- "3.6"
1918
- "3.7"
2019
install:
21-
- pip install -e .[dev,test]
20+
- pip install .[dev,test]
2221
script:
2322
- pytest --cov=. --cov-report=xml
2423
after_success:

MANIFEST.in

-2
This file was deleted.

anndata/__init__.py

+19-17
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
"""Annotated multivariate observation data."""
22

3-
from ._metadata import __version__, __author__, __email__
3+
from ._metadata import __version__, __author__, __email__, within_flit
44

5-
from ._core.anndata import AnnData, ImplicitModificationWarning
6-
from ._core.merge import concat
7-
from ._core.raw import Raw
8-
from ._io import (
9-
read_h5ad,
10-
read_loom,
11-
read_hdf,
12-
read_excel,
13-
read_umi_tools,
14-
read_csv,
15-
read_text,
16-
read_mtx,
17-
read_zarr,
18-
)
5+
if not within_flit():
6+
del within_flit
7+
from ._core.anndata import AnnData, ImplicitModificationWarning
8+
from ._core.merge import concat
9+
from ._core.raw import Raw
10+
from ._io import (
11+
read_h5ad,
12+
read_loom,
13+
read_hdf,
14+
read_excel,
15+
read_umi_tools,
16+
read_csv,
17+
read_text,
18+
read_mtx,
19+
read_zarr,
20+
)
1921

20-
# backwards compat / shortcut for default format
21-
from ._io import read_h5ad as read
22+
# backwards compat / shortcut for default format
23+
from ._io import read_h5ad as read

anndata/_metadata.py

+34-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
1+
import traceback
12
from pathlib import Path
23

34
here = Path(__file__).parent
45

6+
7+
def refresh_entry_points():
8+
"""\
9+
Under some circumstances, (e.g. when installing a PEP 517 package via pip),
10+
pkg_resources.working_set.entries is stale. This tries to fix that.
11+
See https://github.com/pypa/setuptools_scm/issues/513
12+
"""
13+
try:
14+
import sys
15+
import pkg_resources
16+
17+
ws: pkg_resources.WorkingSet = pkg_resources.working_set
18+
for entry in sys.path:
19+
ws.add_entry(entry)
20+
except Exception:
21+
pass
22+
23+
524
try:
625
from setuptools_scm import get_version
726
import pytoml
827

928
proj = pytoml.loads((here.parent / "pyproject.toml").read_text())
10-
metadata = proj["tool"]["anndata"]
29+
metadata = proj["tool"]["flit"]["metadata"]
1130

31+
refresh_entry_points()
1232
__version__ = get_version(root="..", relative_to=__file__)
1333
__author__ = metadata["author"]
1434
__email__ = metadata["author-email"]
@@ -22,3 +42,16 @@
2242
__version__ = meta["Version"]
2343
__author__ = meta["Author"]
2444
__email__ = meta["Author-email"]
45+
46+
47+
def within_flit():
48+
"""\
49+
Checks if we are being imported by flit.
50+
This is necessary so flit can import __version__ without all depedencies installed.
51+
There are a few options to make this hack unnecessary, see:
52+
https://github.com/takluyver/flit/issues/253#issuecomment-737870438
53+
"""
54+
for frame in traceback.extract_stack():
55+
if frame.name == "get_docstring_and_version_via_import":
56+
return True
57+
return False

docs/requirements.txt

-11
This file was deleted.

pyproject.toml

+75-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,83 @@
11
[build-system]
2-
requires = ['setuptools', 'setuptools_scm', 'wheel', 'pytoml']
3-
build-backend = 'setuptools.build_meta'
2+
build-backend = 'flit_core.buildapi'
3+
requires = [
4+
'flit_core >=3.1,<4',
5+
'setuptools_scm',
6+
'pytoml',
7+
'importlib_metadata>=0.7; python_version < "3.8"',
8+
]
49

5-
# uses the format of tool.flit.metadata because we’ll move to it anyway
6-
[tool.anndata]
10+
[tool.flit.metadata]
11+
module = 'anndata'
712
author = 'Philipp Angerer, Alex Wolf, Isaac Virshup, Sergei Rybakov'
813
# We don’t need all emails, the main authors are sufficient.
914
15+
description-file = 'README.rst'
16+
home-page = 'http://github.com/theislab/anndata'
17+
urls = { Documentation = 'https://anndata.readthedocs.io/' }
18+
classifiers = [
19+
'License :: OSI Approved :: BSD License',
20+
'Environment :: Console',
21+
'Framework :: Jupyter',
22+
'Intended Audience :: Developers',
23+
'Intended Audience :: Science/Research',
24+
'Natural Language :: English',
25+
'Operating System :: MacOS :: MacOS X',
26+
'Operating System :: Microsoft :: Windows',
27+
'Operating System :: POSIX :: Linux',
28+
'Programming Language :: Python :: 3',
29+
'Programming Language :: Python :: 3.6',
30+
'Programming Language :: Python :: 3.7',
31+
'Topic :: Scientific/Engineering :: Bio-Informatics',
32+
'Topic :: Scientific/Engineering :: Visualization',
33+
]
34+
requires-python = '>=3.6'
35+
requires = [
36+
# pandas 1.1 breaks tests, https://github.com/pandas-dev/pandas/issues/35446
37+
'pandas>=1.0,!=1.1',
38+
'numpy>=1.15',
39+
'scipy~=1.0',
40+
'h5py',
41+
'natsort',
42+
'packaging>=20',
43+
'xlrd<2.0', # xlsx format not support anymore from v2.0, see pandas/issues/38524
44+
# for getting the stable version
45+
'importlib_metadata>=0.7; python_version < "3.8"',
46+
]
47+
48+
[tool.flit.metadata.requires-extra]
49+
dev = [
50+
# dev version generation
51+
'setuptools_scm',
52+
'pytoml',
53+
# static checking
54+
'black>=20.8b1',
55+
'docutils',
56+
]
57+
doc = [
58+
# Sphinx 2 has nicer looking sections
59+
'sphinx>=2.0.1',
60+
'sphinx-rtd-theme',
61+
'sphinx-autodoc-typehints>=1.11.0',
62+
'sphinx_issues',
63+
'scanpydoc>=0.5',
64+
'typing_extensions; python_version < "3.8"',
65+
]
66+
test = [
67+
'loompy>=3.0.5',
68+
'pytest>=6.0',
69+
'pytest-cov>=2.10',
70+
'zarr',
71+
'matplotlib',
72+
'sklearn',
73+
'xlrd',
74+
'joblib',
75+
'boltons',
76+
'scanpy',
77+
]
78+
79+
[tool.flit.sdist]
80+
exclude = ['anndata/tests']
1081

1182
[tool.coverage.run]
1283
source = ['anndata']

requirements.txt

-8
This file was deleted.

setup.py

-74
This file was deleted.

0 commit comments

Comments
 (0)