Skip to content

Commit 1553749

Browse files
ashwinvismathausedcherian
authored
Add optional dependencies (#4480)
* Add optional dependencies See #2888 Criteria for inclusion: - Mentioned in https://xarray.pydata.org/en/stable/installing.html#optional-dependencies - Listed in PyPI - Should not fail during build (due to build dependencies or external libraries) * Update what's new doc * Document installation with extras * Apply suggestions on documenting opt dependencies Co-authored-by: Mathias Hauser <[email protected]> * Include netCDF4 to io extras * Mention that extra dep are specified in setup.cfg * Remove dummy dependency iris. Add extras docs. pip install -e '.[docs]' installs all the extra packages required to generate the documentation from source. * Literal include extras_require snippet * Modify extras as suggested by @keewis * Rm pyke, add dask[complete] and other docs deps * Apply suggestions from code review Co-authored-by: Mathias Hauser <[email protected]> * Update doc/installing.rst * Update doc/whats-new.rst Co-authored-by: Mathias Hauser <[email protected]> Co-authored-by: Deepak Cherian <[email protected]>
1 parent db4f03e commit 1553749

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

doc/installing.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ Required dependencies
1616
Optional dependencies
1717
---------------------
1818

19+
.. note::
20+
21+
If you are using pip to install xarray, optional dependencies can be installed by
22+
specifying *extras*. :ref:`installation-instructions` for both pip and conda
23+
are given below.
24+
1925
For netCDF and IO
2026
~~~~~~~~~~~~~~~~~
2127

@@ -116,6 +122,7 @@ You can see the actual minimum tested versions:
116122
- `For everything else
117123
<https://github.com/pydata/xarray/blob/master/ci/requirements/py36-min-all-deps.yml>`_
118124

125+
.. _installation-instructions:
119126

120127
Instructions
121128
------------
@@ -139,6 +146,26 @@ pandas) installed first. Then, install xarray with pip::
139146

140147
$ pip install xarray
141148

149+
We also maintain other dependency sets for different subsets of functionality::
150+
151+
$ pip install "xarray[io]" # Install optional dependencies for handling I/O
152+
$ pip install "xarray[accel]" # Install optional dependencies for accelerating xarray
153+
$ pip install "xarray[parallel]" # Install optional dependencies for dask arrays
154+
$ pip install "xarray[viz]" # Install optional dependencies for visualization
155+
$ pip install "xarray[complete]" # Install all the above
156+
157+
The above commands should install most of the `optional dependencies`_. However,
158+
some packages which are either not listed on PyPI or require extra
159+
installation steps are excluded. To know which dependencies would be
160+
installed, take a look at the ``[options.extras_require]`` section in
161+
``setup.cfg``:
162+
163+
.. literalinclude:: ../setup.cfg
164+
:language: ini
165+
:start-at: [options.extras_require]
166+
:end-before: [options.package_data]
167+
168+
142169
Testing
143170
-------
144171

doc/whats-new.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ Documentation
5656

5757
Internal Changes
5858
~~~~~~~~~~~~~~~~
59+
60+
- Optional dependencies can be installed along with xarray by specifying
61+
extras as ``pip install "xarray[extra]"`` where ``extra`` can be one of ``io``,
62+
``accel``, ``parallel``, ``viz`` and ``complete``. See docs for updated
63+
:ref:`installation instructions <installation-instructions>`.
64+
(:issue:`2888`, :pull:`4480`).
65+
By `Ashwin Vishnu <https://github.com/ashwinvis>`_, `Justus Magin
66+
<https://github.com/keewis>`_ and `Mathias Hauser
67+
<https://github.com/mathause>`_.
5968
- Removed stray spaces that stem from black removing new lines (:pull:`4504`).
6069
By `Mathias Hauser <https://github.com/mathause>`_.
6170

setup.cfg

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,52 @@ setup_requires =
8181
setuptools >= 38.4
8282
setuptools_scm
8383

84+
[options.extras_require]
85+
io =
86+
netCDF4
87+
h5netcdf
88+
scipy
89+
pydap
90+
zarr
91+
fsspec
92+
cftime
93+
rasterio
94+
cfgrib
95+
## Scitools packages & dependencies (e.g: cartopy, cf-units) can be hard to install
96+
# scitools-iris
97+
98+
accel =
99+
scipy
100+
bottleneck
101+
numbagg
102+
103+
parallel =
104+
dask[complete]
105+
106+
viz =
107+
matplotlib
108+
seaborn
109+
nc-time-axis
110+
## Cartopy requires 3rd party libraries and only provides source distributions
111+
## See: https://github.com/SciTools/cartopy/issues/805
112+
# cartopy
113+
114+
complete =
115+
%(io)s
116+
%(accel)s
117+
%(parallel)s
118+
%(viz)s
119+
120+
docs =
121+
%(complete)s
122+
sphinx-autosummary-accessors
123+
sphinx_rtd_theme
124+
ipython
125+
ipykernel
126+
jupyter-client
127+
nbsphinx
128+
scanpydoc
129+
84130
[options.package_data]
85131
xarray =
86132
py.typed

0 commit comments

Comments
 (0)