Skip to content

Switch to flit #1527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 1, 2021
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
10 changes: 6 additions & 4 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:

- task: Cache@2
inputs:
key: '"python $(python.version)" | "$(Agent.OS)" | requirements.txt'
restoreKeys: |
key: '"python $(python.version)" | "$(Agent.OS)" | pyproject.toml'
restoreKeys: |
python | "$(Agent.OS)"
python
path: $(PIP_CACHE_DIR)
Expand All @@ -42,8 +42,9 @@ jobs:

- script: |
python -m pip install --upgrade pip
pip install -r .pip-2033.txt
pip install pytest-cov wheel
pip install -e .[dev,doc,test,louvain,leiden,magic,scvi,harmony,scrublet,scanorama]
pip install .[dev,doc,test,louvain,leiden,magic,scvi,harmony,scrublet,scanorama]
displayName: 'Install dependencies'

- script: |
Expand Down Expand Up @@ -102,6 +103,7 @@ jobs:
displayName: 'Display installed versions'

- script: |
python setup.py sdist bdist_wheel
pip install flit
flit build
twine check dist/*
displayName: 'Build & Twine check'
4 changes: 4 additions & 0 deletions .pip-2033.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Flit mangles the +local part of the version spec in compliance with PEP 427,
# but pip 20.3.4 started expecting wheel filenames to contain the local part unmangled.
# https://github.com/pypa/pip/issues/9628
pip==20.3.3
1 change: 1 addition & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ sphinx:
python:
version: 3.8
install:
- requirements: .pip-2033.txt
- method: pip
path: .
extra_requirements:
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ matrix:
- pip install .[dev,doc]
script:
- black . --check --diff
- python setup.py check --restructuredtext --strict
- rst2html.py --halt=2 README.rst >/dev/null
after_success: skip
- name: "anndata dev"
Expand Down
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import sys
import warnings
from pathlib import Path
from datetime import datetime

Expand Down
37 changes: 29 additions & 8 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ If you do not have a working installation of Python 3.6 (or later), consider
installing Miniconda_ (see `Installing Miniconda`_). Then run::

conda install seaborn scikit-learn statsmodels numba pytables
conda install -c conda-forge python-igraph leidenalg
conda install -c conda-forge python-igraph leidenalg

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

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

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

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

pip install -e ".[dev,doc,test]"
.. note::

.. _on GitHub: https://github.com/theislab/scanpy
Due to a `bug in pip`_, packages installed by `flit` can be uninstalled by normal pip operations.
For now, you can avoid this by using::

pip install -e ".[dev,doc,test]"

.. _bug in pip: https://github.com/pypa/pip/issues/9670

If you want to let conda_ handle the installations of dependencies, do::

pip install beni
beni pyproject.toml > environment.yml
conda env create -f environment.yml
conda activate scanpy
flit install -s --deps=develop # or: pip install -e ".[dev,doc,test]"

On Windows, you might have to use `flit install --pth-file`
if you are not able to give yourself the `create symbolic links`_ privilege.

.. _create symbolic links: https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links

Docker
~~~~~~
If you're using Docker_, you can use the minimal `fastgenomics/scanpy`_ image from the Docker Hub.
If you're using Docker_, you can use e.g. the image `gcfntnu/scanpy`_ from Docker Hub.

.. _Docker: https://en.wikipedia.org/wiki/Docker_(software)
.. _fastgenomics/scanpy: https://hub.docker.com/r/fastgenomics/scanpy
.. _gcfntnu/scanpy: https://hub.docker.com/r/gcfntnu/scanpy
.. _bioconda: https://bioconda.github.io/

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

.. _conda:

Installing Miniconda
~~~~~~~~~~~~~~~~~~~~
After downloading Miniconda_, in a unix shell (Linux, Mac), run
Expand Down
5 changes: 5 additions & 0 deletions docs/release-notes/1.8.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

.. rubric:: Features

- Switched to flit_ for building and deploying the package,
a simple tool with an easy to understand command line interface and metadata.

.. _flit: https://flit.readthedocs.io/en/latest/

.. rubric:: External tools

.. rubric:: Performance enhancements
Expand Down
113 changes: 108 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,119 @@
[build-system]
requires = ['setuptools', 'setuptools_scm', 'wheel', 'pytoml']
build-backend = 'setuptools.build_meta'
build-backend = 'flit_core.buildapi'
requires = [
'flit_core >=2,<4',
'setuptools_scm',
'pytoml',
'importlib_metadata>=0.7; python_version < "3.8"',
# setup.py stuff
'packaging',
]

# uses the format of tool.flit.metadata because we’ll move to it anyway
[tool.scanpy]
author = """
[tool.flit.metadata]
module = 'scanpy'
author = """\
Alex Wolf, Philipp Angerer, Fidel Ramirez, Isaac Virshup, \
Sergei Rybakov, Gokcen Eraslan, Tom White, Malte Luecken, \
Davide Cittaro, Tobias Callies, Marius Lange, Andrés R. Muñoz-Rojas\
"""
# We don’t need all emails, the main authors are sufficient.
author-email = '[email protected], [email protected]'
description-file = 'README.rst'
home-page = 'http://github.com/theislab/scanpy'
urls = { Documentation = 'https://scanpy.readthedocs.io/' }
classifiers = [
'License :: OSI Approved :: BSD License',
'Development Status :: 5 - Production/Stable',
'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 = [
'anndata>=0.7.4',
# numpy needs a version due to #1320
'numpy>=1.17.0',
# Matplotlib 3.1 causes an error in 3d scatter plots (https://github.com/matplotlib/matplotlib/issues/14298)
# But matplotlib 3.0 causes one in heatmaps
'matplotlib>=3.1.2',
'pandas>=0.21',
'scipy>=1.4',
'seaborn',
'h5py>=2.10.0',
'tables',
'tqdm',
'scikit-learn>=0.21.2',
'statsmodels>=0.10.0rc2',
'patsy',
'networkx>=2.3',
'natsort',
'joblib',
'numba>=0.41.0',
'umap-learn>=0.3.10',
'legacy-api-wrap',
'packaging',
'sinfo',
# for getting the stable version
'importlib_metadata>=0.7; python_version < "3.8"',
]

[tool.flit.metadata.requires-extra]
louvain = ['python-igraph', 'louvain>=0.6,!=0.6.2']
leiden = ['python-igraph', 'leidenalg']
bbknn = ['bbknn']
scvi = ['scvi==0.6.7']
rapids = ['cudf>=0.9', 'cuml>=0.9', 'cugraph>=0.9']
magic = ['magic-impute>=2.0']
skmisc = ['scikit-misc>=0.1.3']
harmony = ['harmonypy']
scanorama = ['scanorama']
scrublet = ['scrublet']
dev = [
# getting the dev version
'setuptools_scm',
'pytoml',
# static checking
'black>=20.8b1',
'docutils',
]
doc = [
'sphinx>=3.2',
'sphinx-rtd-theme>=0.3.1',
'sphinx-autodoc-typehints',
'readthedocs-sphinx-search',
'scanpydoc>=0.5',
'typing_extensions; python_version < "3.8"', # for `Literal`
]
test = [
'pytest>=4.4',
'pytest-nunit',
'dask[array]!=2.17.0',
'fsspec',
'zappy',
'zarr',
'profimp',
# Test the metadata while this exists: https://github.com/takluyver/flit/issues/387
'flit_core',
]

[tool.flit.scripts]
scanpy = 'scanpy.cli:console_main'

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

[tool.pytest.ini_options]
python_files = 'test_*.py'
Expand Down
24 changes: 0 additions & 24 deletions requirements.txt

This file was deleted.

81 changes: 40 additions & 41 deletions scanpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
"""Single-Cell Analysis in Python."""

from ._metadata import __version__, __author__, __email__

from ._utils import check_versions

check_versions()
del check_versions

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

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
from ._metadata import __version__, __author__, __email__, 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

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
Loading