Skip to content

Commit

Permalink
Switch to flit
Browse files Browse the repository at this point in the history
This reverts commit d645790
  • Loading branch information
flying-sheep committed Dec 4, 2020
1 parent d205474 commit 5d34d96
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 143 deletions.
3 changes: 1 addition & 2 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- script: |
python -m pip install --upgrade pip
pip install pytest-azurepipelines wheel
pip install -e .[dev,doc,test,louvain,leiden,magic,scvi,harmony]
pip install .[dev,doc,test,louvain,leiden,magic,scvi,harmony]
displayName: 'Install dependencies'
- script: |
Expand All @@ -47,6 +47,5 @@ jobs:
displayName: 'PyTest'
- script: |
python setup.py check --restructuredtext --strict
rst2html.py --halt=2 README.rst >/dev/null
displayName: 'rst2html'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ __pycache__/
/scanpy.egg-info/
/*-env/
/env-*/
/setup.py

# OS stuff
.DS_Store
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ matrix:
script:
- black . --check --diff
- python -m scanpy.tests.blackdiff 10
- 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
23 changes: 21 additions & 2 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 All @@ -33,10 +33,27 @@ 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 # from an activated venv or conda env
# or
flit install -s --python path/to/venv/bin/python

.. _on GitHub: https://github.com/theislab/scanpy

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

On Windows, you might have to use `flit install --pth-file`
if you are not able to give yourself the `create symbolic links`_ privilege.
Be aware that a `conda bug`_ might prevent `conda list` from working then.

.. _create symbolic links: https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links
.. _conda bug: https://github.com/conda/conda/issues/9074

Docker
~~~~~~
If you're using Docker_, you can use the minimal `fastgenomics/scanpy`_ image from the Docker Hub.
Expand Down Expand Up @@ -71,6 +88,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
106 changes: 97 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,104 @@
[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"',
]

# uses the format of tool.flit.metadata because we’ll move to it anyway
[tool.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
'''
[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.5']
rapids = ['cudf>=0.9', 'cuml>=0.9', 'cugraph>=0.9']
magic = ['magic-impute>=2.0']
skmisc = ['scikit-misc>=0.1.3']
harmony = ['harmonypy']
dev = [
# getting the dev version
'setuptools_scm',
'pytoml',
# static checking
'black>=20.8b1',
'docutils',
]
doc = [
'sphinx<3.1, >3',
'sphinx-rtd-theme>=0.3.1',
'sphinx-autodoc-typehints',
'scanpydoc>=0.5',
'typing_extensions; python_version < "3.8"', # for `Literal`
]
test = [
'pytest>=4.4',
'dask[array]!=2.17.0',
'fsspec',
'zappy',
'zarr',
'profimp',
]

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

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

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

This file was deleted.

43 changes: 22 additions & 21 deletions scanpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
"""Single-Cell Analysis in Python."""

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

from ._utils import check_versions
check_versions()
del check_versions
if not within_flit():
from ._utils import check_versions
check_versions()
del check_versions, within_flit

# 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
# 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
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
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
# 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
10 changes: 9 additions & 1 deletion scanpy/_metadata.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import traceback
from pathlib import Path

here = Path(__file__).parent
Expand All @@ -7,7 +8,7 @@
import pytoml

proj = pytoml.loads((here.parent / 'pyproject.toml').read_text())
metadata = proj['tool']['scanpy']
metadata = proj['tool']['flit']['metadata']

__version__ = get_version(root='..', relative_to=__file__)
__author__ = metadata['author']
Expand All @@ -19,3 +20,10 @@
__version__ = metadata['Version']
__author__ = metadata['Author']
__email__ = metadata['Author-email']


def within_flit():
for frame in traceback.extract_stack():
if frame.name == 'get_docstring_and_version_via_import':
return True
return False
78 changes: 0 additions & 78 deletions setup.py

This file was deleted.

0 comments on commit 5d34d96

Please sign in to comment.