From 28c4d28308756b5e0aa25adde2dfdfe93674e891 Mon Sep 17 00:00:00 2001 From: Charlotte Weaver Date: Wed, 21 Aug 2019 14:26:01 -0700 Subject: [PATCH] extract prepare from main install (#887) * extract prepare from main install * add requirements-prepare to manifest --- MANIFEST.in | 3 ++- server/cli/launch.py | 5 ----- server/cli/prepare.py | 36 +++++++++++++++++++-------------- server/requirements-prepare.txt | 1 + server/requirements.txt | 4 ---- setup.py | 5 ++++- 6 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 server/requirements-prepare.txt diff --git a/MANIFEST.in b/MANIFEST.in index bab7fdc7..6ed38441 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ recursive-include server/app/web/templates * recursive-include server/app/web/static * -include server/requirements.txt \ No newline at end of file +include server/requirements.txt +include server/requirements-prepare.txt diff --git a/server/cli/launch.py b/server/cli/launch.py index 987565a2..2caea22a 100644 --- a/server/cli/launch.py +++ b/server/cli/launch.py @@ -185,11 +185,6 @@ def launch( else: click.echo(f"[cellxgene] Loading data from {basename(data)}.") - # Fix for anaconda python. matplotlib typically expects python to be installed as a framework TKAgg is usually - # available and fixes this issue. See https://matplotlib.org/faq/virtualenv_faq.html - import matplotlib as mpl - - mpl.use("TkAgg") from server.app.scanpy_engine.scanpy_engine import ScanpyEngine try: diff --git a/server/cli/prepare.py b/server/cli/prepare.py index bad6b18c..b0ff3d43 100644 --- a/server/cli/prepare.py +++ b/server/cli/prepare.py @@ -41,18 +41,18 @@ from scipy.sparse.csc import csc_matrix "--make-var-names-unique", default=True, is_flag=True, help="Ensure var index is unique.", show_default=True ) def prepare( - data, - layout, - recipe, - output, - plotting, - sparse, - overwrite, - set_obs_names, - set_var_names, - run_qc, - make_obs_names_unique, - make_var_names_unique, + data, + layout, + recipe, + output, + plotting, + sparse, + overwrite, + set_obs_names, + set_var_names, + run_qc, + make_obs_names_unique, + make_var_names_unique, ): """Preprocesses data for use with cellxgene. @@ -65,10 +65,16 @@ def prepare( # collect slow imports here to make CLI startup more responsive click.echo("[cellxgene] Starting CLI...") - import matplotlib + try: + import matplotlib - matplotlib.use("Agg") - import scanpy as sc + matplotlib.use("Agg") + import scanpy as sc + except ImportError: + raise click.ClickException( + "[cellxgene] cellxgene prepare has not been installed. Please run `pip install cellxgene[prepare]` " + "to install the necessary requirements." + ) # scanpy settings sc.settings.verbosity = 0 diff --git a/server/requirements-prepare.txt b/server/requirements-prepare.txt new file mode 100644 index 00000000..d1b43def --- /dev/null +++ b/server/requirements-prepare.txt @@ -0,0 +1 @@ +scanpy>=1.3.7 diff --git a/server/requirements.txt b/server/requirements.txt index 3c058312..f5bbb00f 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -6,11 +6,7 @@ Flask-Compress>=1.4.0 Flask-Cors>=3.0.6 Flask-RESTful>=0.3.6 flatbuffers>=1.10.0 -# TODO revert after scanpy updates their dependency on this -matplotlib<3.1 numpy>=1.15.2 pandas>=0.23.1 -scanpy>=1.3.7 scipy>=1.1.0 -scikit-learn>=0.19.1,!=0.20.0 tables==3.5.1 diff --git a/setup.py b/setup.py index d8b7b75b..7987697d 100644 --- a/setup.py +++ b/setup.py @@ -6,6 +6,9 @@ with open("README.md", "rb") as fh: with open("server/requirements.txt") as fh: requirements = fh.read().splitlines() +with open("server/requirements-prepare.txt") as fh: + requirements_prepare = fh.read().splitlines() + setup( name="cellxgene", version="0.11.0", @@ -36,5 +39,5 @@ setup( "Topic :: Scientific/Engineering :: Bio-Informatics", ], entry_points={"console_scripts": ["cellxgene = server.cli.cli:cli"]}, - extras_require=dict(louvain=["python-igraph", "louvain>=0.6"], gui=["PySide2>=5.12.3", "cefpython3>=66", "requests"]), + extras_require=dict(prepare=requirements_prepare, louvain=["python-igraph", "louvain>=0.6"], gui=["PySide2>=5.12.3", "cefpython3>=66", "requests"]), )