Skip to content

Commit

Permalink
backport hatch to 1.9.x (#2727)
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep authored Oct 31, 2023
1 parent 0b624b0 commit 1083b36
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 100 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

# Python build files
__pycache__/
/scanpy/_version.py
/dist/
/build/
/scanpy.egg-info/
Expand Down
24 changes: 10 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
[build-system]
build-backend = "flit_core.buildapi"
requires = [
"flit_core >=3.4,<4",
"setuptools_scm",
"tomli",
"importlib_metadata>=0.7; python_version < '3.8'",
]
build-backend = "hatchling.build"
requires = ["hatchling", "hatch-vcs"]

[project]
name = "scanpy"
description = "Single-Cell Analysis in Python."
requires-python = ">=3.8"
license = {file = "LICENSE"}
license = "BSD-3-clause"
authors = [
{name = "Alex Wolf"},
{name = "Philipp Angerer"},
Expand All @@ -31,7 +26,7 @@ maintainers = [
{name = "Philipp Angerer", email = "phil.angerer@gmail.com"},
{name = "Alex Wolf", email = "f.alex.wolf@gmx.de"},
]
readme = {file = "README.md", content-type="text/markdown"}
readme = "README.md"
classifiers = [
"License :: OSI Approved :: BSD License",
"Development Status :: 5 - Production/Stable",
Expand Down Expand Up @@ -135,11 +130,12 @@ scrublet = ["scrublet"] # Doublet detection
rapids = ["cudf>=0.9", "cuml>=0.9", "cugraph>=0.9"] # GPU accelerated calculation of neighbors
dask = ["dask[array]!=2.17.0"] # Use the Dask parallelization engine

[tool.flit.sdist]
exclude = [
"scanpy/tests",
"setup.py",
]
[tool.hatch.build]
exclude = ["scanpy/tests"]
[tool.hatch.version]
source = "vcs"
[tool.hatch.build.hooks.vcs]
version-file = "scanpy/_version.py"

[tool.pytest.ini_options]
addopts = [
Expand Down
90 changes: 50 additions & 40 deletions scanpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,52 @@
"""Single-Cell Analysis in Python."""

from ._metadata import __version__, within_flit

if not within_flit(): # see function docstring on why this is there
from ._utils import check_versions

check_versions()
del check_versions, within_flit

# the actual API
# (start with settings as several tools are using it)
from ._settings import settings, Verbosity
from . import tools as tl
from . import preprocessing as pp
from . import plotting as pl
from . import datasets, logging, queries, external, get, metrics, experimental

from anndata import AnnData, concat
from anndata import (
read_h5ad,
read_csv,
read_excel,
read_hdf,
read_loom,
read_mtx,
read_text,
read_umi_tools,
)
from .readwrite import read, read_10x_h5, read_10x_mtx, write, read_visium
from .neighbors import Neighbors

set_figure_params = settings.set_figure_params

# has to be done at the end, after everything has been imported
import sys

sys.modules.update({f'{__name__}.{m}': globals()[m] for m in ['tl', 'pp', 'pl']})
from ._utils import annotate_doc_types

annotate_doc_types(sys.modules[__name__], 'scanpy')
del sys, annotate_doc_types
try: # See https://github.com/maresb/hatch-vcs-footgun-example
from setuptools_scm import get_version

__version__ = get_version(root="..", relative_to=__file__)
del get_version
except (ImportError, LookupError):
try:
from ._version import __version__
except ModuleNotFoundError:
raise RuntimeError(
"scanpy is not correctly installed. Please install it, e.g. with pip."
)

from ._utils import check_versions

check_versions()
del check_versions

# the actual API
# (start with settings as several tools are using it)
from ._settings import settings, Verbosity
from . import tools as tl
from . import preprocessing as pp
from . import plotting as pl
from . import datasets, logging, queries, external, get, metrics, experimental

from anndata import AnnData, concat
from anndata import (
read_h5ad,
read_csv,
read_excel,
read_hdf,
read_loom,
read_mtx,
read_text,
read_umi_tools,
)
from .readwrite import read, read_10x_h5, read_10x_mtx, write, read_visium
from .neighbors import Neighbors

set_figure_params = settings.set_figure_params

# has to be done at the end, after everything has been imported
import sys

sys.modules.update({f"{__name__}.{m}": globals()[m] for m in ["tl", "pp", "pl"]})
from ._utils import annotate_doc_types

annotate_doc_types(sys.modules[__name__], "scanpy")
del sys, annotate_doc_types
46 changes: 0 additions & 46 deletions scanpy/_metadata.py

This file was deleted.

0 comments on commit 1083b36

Please sign in to comment.