Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ matrix:
include:
- name: static analysis
python: "3.7"
install: pip install .[dev,doc]
install: pip install .[dev]
script:
- black . --check --diff
- python setup.py check --restructuredtext --strict
- rst2html.py --halt=2 README.rst >/dev/null
after_success: skip
python:
- "3.6"
- "3.7"
install:
- pip install -e .[dev,test]
- pip install .[dev,test]
script:
- pytest --cov=. --cov-report=xml
after_success:
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

36 changes: 19 additions & 17 deletions anndata/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
"""Annotated multivariate observation data."""

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

from ._core.anndata import AnnData, ImplicitModificationWarning
from ._core.merge import concat
from ._core.raw import Raw
from ._io import (
read_h5ad,
read_loom,
read_hdf,
read_excel,
read_umi_tools,
read_csv,
read_text,
read_mtx,
read_zarr,
)
if not within_flit():
del within_flit
from ._core.anndata import AnnData, ImplicitModificationWarning
from ._core.merge import concat
from ._core.raw import Raw
from ._io import (
read_h5ad,
read_loom,
read_hdf,
read_excel,
read_umi_tools,
read_csv,
read_text,
read_mtx,
read_zarr,
)

# backwards compat / shortcut for default format
from ._io import read_h5ad as read
# backwards compat / shortcut for default format
from ._io import read_h5ad as read
35 changes: 34 additions & 1 deletion anndata/_metadata.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
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"]["anndata"]
metadata = proj["tool"]["flit"]["metadata"]

refresh_entry_points()
__version__ = get_version(root="..", relative_to=__file__)
__author__ = metadata["author"]
__email__ = metadata["author-email"]
Expand All @@ -22,3 +42,16 @@
__version__ = meta["Version"]
__author__ = meta["Author"]
__email__ = meta["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
return False
11 changes: 0 additions & 11 deletions docs/requirements.txt

This file was deleted.

81 changes: 77 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,85 @@
[build-system]
requires = ['setuptools', 'setuptools_scm', 'wheel', 'pytoml']
build-backend = 'setuptools.build_meta'
build-backend = 'flit_core.buildapi'
requires = [
'flit_core >=3.1,<4',
'setuptools_scm',
'pytoml',
'importlib_metadata>=0.7; python_version < "3.8"',
]

# uses the format of tool.flit.metadata because we’ll move to it anyway
[tool.anndata]
[tool.flit.metadata]
module = 'anndata'
author = 'Philipp Angerer, Alex Wolf, Isaac Virshup, Sergei Rybakov'
# We don’t need all emails, the main authors are sufficient.
author-email = 'phil.angerer@gmail.com, f.alex.wolf@gmx.de'
description-file = 'README.rst'
home-page = 'http://github.com/theislab/anndata'
urls = { Documentation = 'https://anndata.readthedocs.io/' }
classifiers = [
'License :: OSI Approved :: BSD License',
'Environment :: Console',
'Framework :: Jupyter',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Natural Language :: English',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'Topic :: Scientific/Engineering :: Visualization',
]
requires-python = '>=3.6'
requires = [
'pandas>=1.1.1', # pandas <1.1.1 has pandas/issues/35446
'numpy>=1.16.5', # required by pandas 1.x
'scipy~=1.0',
'h5py',
'natsort',
'packaging>=20',
'xlrd<2.0', # xlsx format not support anymore from v2.0, see pandas/issues/38524
# for getting the stable version
'importlib_metadata>=0.7; python_version < "3.8"',
]

[tool.flit.metadata.requires-extra]
dev = [
# dev version generation
'setuptools_scm',
'pytoml',
# static checking
'black>=20.8b1',
'docutils',
]
doc = [
# Sphinx 2 has nicer looking sections
'sphinx>=2.0.1',
'sphinx-rtd-theme',
'sphinx-autodoc-typehints>=1.11.0',
'sphinx_issues',
'scanpydoc>=0.5',
'typing_extensions; python_version < "3.8"',
]
test = [
'loompy>=3.0.5',
'pytest>=6.0',
'pytest-cov>=2.10',
'zarr',
'matplotlib',
'sklearn',
'xlrd',
'joblib',
'boltons',
'scanpy',
]

[tool.flit.sdist]
exclude = [
'anndata/tests',
'setup.py',
]

[tool.coverage.run]
source = ['anndata']
Expand Down
8 changes: 0 additions & 8 deletions requirements.txt

This file was deleted.

133 changes: 66 additions & 67 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,74 +1,73 @@
"""Temporary setuptools bridge
Don't use this except if you have a deadline or you encounter a bug.
"""
import re
import sys
from warnings import warn

if sys.version_info < (3, 6):
sys.exit("anndata requires Python >= 3.6")
import setuptools
from pathlib import Path

from setuptools import setup, find_namespace_packages
from flit_core import common, config
from setuptools_scm.integration import find_files

try:
import pytoml
except ImportError:
sys.exit("Please use `pip install .` or install pytoml first.")

proj = pytoml.loads(Path("pyproject.toml").read_text())
metadata = proj["tool"]["anndata"]

setup(
name="anndata",
use_scm_version=True,
setup_requires=["setuptools_scm"],
description="Annotated Data.",
long_description=Path("README.rst").read_text("utf-8"),
url="http://github.com/theislab/anndata",
author=metadata["author"],
author_email=metadata["author-email"],
license="BSD-3-Clause",
install_requires=[
l.strip() for l in Path("requirements.txt").read_text("utf-8").splitlines()
],
extras_require=dict(
dev=["setuptools_scm", "pytoml", "black>=20.8b1"],
doc=[
# Sphinx 2 has nicer looking sections
"sphinx>=2.0.1",
"sphinx-rtd-theme",
"sphinx-autodoc-typehints>=1.11.0",
"sphinx_issues",
"scanpydoc>=0.5",
'typing_extensions; python_version < "3.8"',
],
test=[
"loompy>=3.0.5",
"pytest>=4.6",
"pytest-cov>=2.10",
"docutils", # for rst2html.py
"zarr",
"matplotlib",
"sklearn",
"xlrd<2",
"joblib",
"boltons",
"scanpy",
],
),
python_requires=">=3.6",
packages=find_namespace_packages(include=["anndata", "anndata.*"]),
include_package_data=True,
zip_safe=False,
classifiers=[
"Environment :: Console",
"Framework :: Jupyter",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Natural Language :: English",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Scientific/Engineering :: Visualization",
],
field_map = dict(
description="summary",
long_description="description",
long_description_content_type="description_content_type",
python_requires="requires_python",
url="home_page",
**{
n: n
for n in ["name", "version", "author", "author_email", "license", "classifiers"]
},
)


def setup_args(config_path=Path("pyproject.toml")):
cfg = config.read_flit_config(config_path)
module = common.Module(cfg.module, config_path.parent)
metadata = common.make_metadata(module, cfg)
kwargs = {}
for st_field, metadata_field in field_map.items():
val = getattr(metadata, metadata_field, None)
if val is not None:
kwargs[st_field] = val
else:
msg = f"{metadata_field} not found in {dir(metadata)}"
assert metadata_field in {"license"}, msg
kwargs["packages"] = setuptools.find_packages(include=[metadata.name + "*"])
if metadata.requires_dist:
kwargs["install_requires"] = [
req for req in metadata.requires_dist if "extra ==" not in req
]
if cfg.reqs_by_extra:
kwargs["extras_require"] = cfg.reqs_by_extra
scripts = cfg.entrypoints.get("console_scripts")
if scripts is not None:
kwargs["entry_points"] = dict(
console_scipts=[" = ".join(ep) for ep in scripts.items()]
)
kwargs["include_package_data"] = True
kwargs["package_data"] = {
module.name: [
re.escape(f[len(module.name) + 1 :]) for f in find_files(module.path)
]
}
return kwargs


if __name__ == "__main__":
if "develop" in sys.argv:
msg = (
"Please use `flit install -s` or `flit install --pth-file` "
"instead of `pip install -e`/`python setup.py develop` "
"once https://github.com/pypa/pip/issues/9670 is fixed."
)
elif "install" in sys.argv:
msg = 'Please use `pip install "$d"` instead of `python "$d/setup.py" install`'
else:
msg = "Please use `pip ...` or `flit ...` instead of `python setup.py ...`"
warn(msg, FutureWarning)
setuptools.setup(**setup_args())