Skip to content

Commit 0f7968c

Browse files
authored
Merge pull request #1527 from theislab/flit
2 parents f27ca71 + f653c3c commit 0f7968c

15 files changed

+320
-166
lines changed

.azure-pipelines.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ jobs:
2828

2929
- task: Cache@2
3030
inputs:
31-
key: '"python $(python.version)" | "$(Agent.OS)" | requirements.txt'
32-
restoreKeys: |
31+
key: '"python $(python.version)" | "$(Agent.OS)" | pyproject.toml'
32+
restoreKeys: |
3333
python | "$(Agent.OS)"
3434
python
3535
path: $(PIP_CACHE_DIR)
@@ -42,8 +42,9 @@ jobs:
4242
4343
- script: |
4444
python -m pip install --upgrade pip
45+
pip install -r .pip-2033.txt
4546
pip install pytest-cov wheel
46-
pip install -e .[dev,doc,test,louvain,leiden,magic,scvi,harmony,scrublet,scanorama]
47+
pip install .[dev,doc,test,louvain,leiden,magic,scvi,harmony,scrublet,scanorama]
4748
displayName: 'Install dependencies'
4849
4950
- script: |
@@ -102,6 +103,7 @@ jobs:
102103
displayName: 'Display installed versions'
103104

104105
- script: |
105-
python setup.py sdist bdist_wheel
106+
pip install flit
107+
flit build
106108
twine check dist/*
107109
displayName: 'Build & Twine check'

.pip-2033.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Flit mangles the +local part of the version spec in compliance with PEP 427,
2+
# but pip 20.3.4 started expecting wheel filenames to contain the local part unmangled.
3+
# https://github.com/pypa/pip/issues/9628
4+
pip==20.3.3

.readthedocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ sphinx:
66
python:
77
version: 3.8
88
install:
9+
- requirements: .pip-2033.txt
910
- method: pip
1011
path: .
1112
extra_requirements:

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ matrix:
1111
- pip install .[dev,doc]
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
- name: "anndata dev"

MANIFEST.in

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import sys
3-
import warnings
43
from pathlib import Path
54
from datetime import datetime
65

docs/installation.rst

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ If you do not have a working installation of Python 3.6 (or later), consider
77
installing Miniconda_ (see `Installing Miniconda`_). Then run::
88

99
conda install seaborn scikit-learn statsmodels numba pytables
10-
conda install -c conda-forge python-igraph leidenalg
10+
conda install -c conda-forge python-igraph leidenalg
1111

1212
Pull Scanpy from `PyPI <https://pypi.org/project/scanpy>`__ (consider using ``pip3`` to access Python 3)::
1313

@@ -35,21 +35,40 @@ To work with the latest version `on GitHub`_: clone the repository and `cd` into
3535
its root directory. To install using symbolic links (stay up to date with your
3636
cloned version after you update with `git pull`) call::
3737

38-
pip install -e .
38+
flit install -s --deps=develop # from an activated venv or conda env
39+
# or
40+
flit install -s --deps=develop --python path/to/venv/bin/python
3941

40-
If you intend to do development work, there are some extra dependencies you'll want.
41-
These can be install with `scanpy` via::
42+
.. _on GitHub: https://github.com/theislab/scanpy
4243

43-
pip install -e ".[dev,doc,test]"
44+
.. note::
4445

45-
.. _on GitHub: https://github.com/theislab/scanpy
46+
Due to a `bug in pip`_, packages installed by `flit` can be uninstalled by normal pip operations.
47+
For now, you can avoid this by using::
48+
49+
pip install -e ".[dev,doc,test]"
50+
51+
.. _bug in pip: https://github.com/pypa/pip/issues/9670
52+
53+
If you want to let conda_ handle the installations of dependencies, do::
54+
55+
pip install beni
56+
beni pyproject.toml > environment.yml
57+
conda env create -f environment.yml
58+
conda activate scanpy
59+
flit install -s --deps=develop # or: pip install -e ".[dev,doc,test]"
60+
61+
On Windows, you might have to use `flit install --pth-file`
62+
if you are not able to give yourself the `create symbolic links`_ privilege.
63+
64+
.. _create symbolic links: https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links
4665

4766
Docker
4867
~~~~~~
49-
If you're using Docker_, you can use the minimal `fastgenomics/scanpy`_ image from the Docker Hub.
68+
If you're using Docker_, you can use e.g. the image `gcfntnu/scanpy`_ from Docker Hub.
5069

5170
.. _Docker: https://en.wikipedia.org/wiki/Docker_(software)
52-
.. _fastgenomics/scanpy: https://hub.docker.com/r/fastgenomics/scanpy
71+
.. _gcfntnu/scanpy: https://hub.docker.com/r/gcfntnu/scanpy
5372
.. _bioconda: https://bioconda.github.io/
5473

5574
Troubleshooting
@@ -78,6 +97,8 @@ Download those and install them using `pip install ./path/to/file.whl`
7897
.. _compiling igraph: https://stackoverflow.com/q/29589696/247482
7998
.. _unofficial binaries: https://www.lfd.uci.edu/~gohlke/pythonlibs/
8099

100+
.. _conda:
101+
81102
Installing Miniconda
82103
~~~~~~~~~~~~~~~~~~~~
83104
After downloading Miniconda_, in a unix shell (Linux, Mac), run

docs/release-notes/1.8.0.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
.. rubric:: Features
55

6+
- Switched to flit_ for building and deploying the package,
7+
a simple tool with an easy to understand command line interface and metadata.
8+
9+
.. _flit: https://flit.readthedocs.io/en/latest/
10+
611
.. rubric:: External tools
712

813
.. rubric:: Performance enhancements

pyproject.toml

Lines changed: 108 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,119 @@
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 >=2,<4',
5+
'setuptools_scm',
6+
'pytoml',
7+
'importlib_metadata>=0.7; python_version < "3.8"',
8+
# setup.py stuff
9+
'packaging',
10+
]
411

5-
# uses the format of tool.flit.metadata because we’ll move to it anyway
6-
[tool.scanpy]
7-
author = """
12+
[tool.flit.metadata]
13+
module = 'scanpy'
14+
author = """\
815
Alex Wolf, Philipp Angerer, Fidel Ramirez, Isaac Virshup, \
916
Sergei Rybakov, Gokcen Eraslan, Tom White, Malte Luecken, \
1017
Davide Cittaro, Tobias Callies, Marius Lange, Andrés R. Muñoz-Rojas\
1118
"""
1219
# We don’t need all emails, the main authors are sufficient.
1320
21+
description-file = 'README.rst'
22+
home-page = 'http://github.com/theislab/scanpy'
23+
urls = { Documentation = 'https://scanpy.readthedocs.io/' }
24+
classifiers = [
25+
'License :: OSI Approved :: BSD License',
26+
'Development Status :: 5 - Production/Stable',
27+
'Environment :: Console',
28+
'Framework :: Jupyter',
29+
'Intended Audience :: Developers',
30+
'Intended Audience :: Science/Research',
31+
'Natural Language :: English',
32+
'Operating System :: MacOS :: MacOS X',
33+
'Operating System :: Microsoft :: Windows',
34+
'Operating System :: POSIX :: Linux',
35+
'Programming Language :: Python :: 3',
36+
'Programming Language :: Python :: 3.6',
37+
'Programming Language :: Python :: 3.7',
38+
'Topic :: Scientific/Engineering :: Bio-Informatics',
39+
'Topic :: Scientific/Engineering :: Visualization',
40+
]
41+
requires-python = '>=3.6'
42+
requires = [
43+
'anndata>=0.7.4',
44+
# numpy needs a version due to #1320
45+
'numpy>=1.17.0',
46+
# Matplotlib 3.1 causes an error in 3d scatter plots (https://github.com/matplotlib/matplotlib/issues/14298)
47+
# But matplotlib 3.0 causes one in heatmaps
48+
'matplotlib>=3.1.2',
49+
'pandas>=0.21',
50+
'scipy>=1.4',
51+
'seaborn',
52+
'h5py>=2.10.0',
53+
'tables',
54+
'tqdm',
55+
'scikit-learn>=0.21.2',
56+
'statsmodels>=0.10.0rc2',
57+
'patsy',
58+
'networkx>=2.3',
59+
'natsort',
60+
'joblib',
61+
'numba>=0.41.0',
62+
'umap-learn>=0.3.10',
63+
'legacy-api-wrap',
64+
'packaging',
65+
'sinfo',
66+
# for getting the stable version
67+
'importlib_metadata>=0.7; python_version < "3.8"',
68+
]
69+
70+
[tool.flit.metadata.requires-extra]
71+
louvain = ['python-igraph', 'louvain>=0.6,!=0.6.2']
72+
leiden = ['python-igraph', 'leidenalg']
73+
bbknn = ['bbknn']
74+
scvi = ['scvi==0.6.7']
75+
rapids = ['cudf>=0.9', 'cuml>=0.9', 'cugraph>=0.9']
76+
magic = ['magic-impute>=2.0']
77+
skmisc = ['scikit-misc>=0.1.3']
78+
harmony = ['harmonypy']
79+
scanorama = ['scanorama']
80+
scrublet = ['scrublet']
81+
dev = [
82+
# getting the dev version
83+
'setuptools_scm',
84+
'pytoml',
85+
# static checking
86+
'black>=20.8b1',
87+
'docutils',
88+
]
89+
doc = [
90+
'sphinx>=3.2',
91+
'sphinx-rtd-theme>=0.3.1',
92+
'sphinx-autodoc-typehints',
93+
'readthedocs-sphinx-search',
94+
'scanpydoc>=0.5',
95+
'typing_extensions; python_version < "3.8"', # for `Literal`
96+
]
97+
test = [
98+
'pytest>=4.4',
99+
'pytest-nunit',
100+
'dask[array]!=2.17.0',
101+
'fsspec',
102+
'zappy',
103+
'zarr',
104+
'profimp',
105+
# Test the metadata while this exists: https://github.com/takluyver/flit/issues/387
106+
'flit_core',
107+
]
108+
109+
[tool.flit.scripts]
110+
scanpy = 'scanpy.cli:console_main'
111+
112+
[tool.flit.sdist]
113+
exclude = [
114+
'scanpy/tests',
115+
'setup.py',
116+
]
14117

15118
[tool.pytest.ini_options]
16119
python_files = 'test_*.py'

requirements.txt

Lines changed: 0 additions & 24 deletions
This file was deleted.

scanpy/__init__.py

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
"""Single-Cell Analysis in Python."""
22

3-
from ._metadata import __version__, __author__, __email__
4-
5-
from ._utils import check_versions
6-
7-
check_versions()
8-
del check_versions
9-
10-
# the actual API
11-
from ._settings import (
12-
settings,
13-
Verbosity,
14-
) # start with settings as several tools are using it
15-
from . import tools as tl
16-
from . import preprocessing as pp
17-
from . import plotting as pl
18-
from . import datasets, logging, queries, external, get
19-
20-
from anndata import AnnData, concat
21-
from anndata import (
22-
read_h5ad,
23-
read_csv,
24-
read_excel,
25-
read_hdf,
26-
read_loom,
27-
read_mtx,
28-
read_text,
29-
read_umi_tools,
30-
)
31-
from .readwrite import read, read_10x_h5, read_10x_mtx, write, read_visium
32-
from .neighbors import Neighbors
33-
34-
set_figure_params = settings.set_figure_params
35-
36-
# has to be done at the end, after everything has been imported
37-
import sys
38-
39-
sys.modules.update({f'{__name__}.{m}': globals()[m] for m in ['tl', 'pp', 'pl']})
40-
from ._utils import annotate_doc_types
41-
42-
annotate_doc_types(sys.modules[__name__], 'scanpy')
43-
del sys, annotate_doc_types
3+
from ._metadata import __version__, __author__, __email__, within_flit
4+
5+
if not within_flit(): # see function docstring on why this is there
6+
from ._utils import check_versions
7+
8+
check_versions()
9+
del check_versions, within_flit
10+
11+
# the actual API
12+
# (start with settings as several tools are using it)
13+
from ._settings import settings, Verbosity
14+
from . import tools as tl
15+
from . import preprocessing as pp
16+
from . import plotting as pl
17+
from . import datasets, logging, queries, external, get
18+
19+
from anndata import AnnData, concat
20+
from anndata import (
21+
read_h5ad,
22+
read_csv,
23+
read_excel,
24+
read_hdf,
25+
read_loom,
26+
read_mtx,
27+
read_text,
28+
read_umi_tools,
29+
)
30+
from .readwrite import read, read_10x_h5, read_10x_mtx, write, read_visium
31+
from .neighbors import Neighbors
32+
33+
set_figure_params = settings.set_figure_params
34+
35+
# has to be done at the end, after everything has been imported
36+
import sys
37+
38+
sys.modules.update({f'{__name__}.{m}': globals()[m] for m in ['tl', 'pp', 'pl']})
39+
from ._utils import annotate_doc_types
40+
41+
annotate_doc_types(sys.modules[__name__], 'scanpy')
42+
del sys, annotate_doc_types

0 commit comments

Comments
 (0)