Skip to content
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

build: improve opt deps #16340

Merged
merged 3 commits into from
May 28, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/development/codeguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ Interface and Dependencies
statement, which will raise an ``ImportError`` if the dependency is
not available. In the astropy core package, such optional dependencies should
be recorded in the ``pyproject.toml`` file in the ``[project.optional-dependencies]``
entry, under ``all`` (or ``test_all`` if the dependency is only
needed for testing).
entry (put it in the appropriate category of optional dependencies).

At the module level, one can subclass a class from an optional dependency
like so::
Expand Down
14 changes: 12 additions & 2 deletions docs/development/testguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,18 @@ option::

python -m pip install --editable ".[test]"

A detailed description of the plugins can be found in the :ref:`pytest-plugins`
section.
To test the full set of optional dependencies, use the ``test_all`` option::

python -m pip install --editable ".[test_all]"
Comment on lines +42 to +44
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be much better if these descriptions could link to relevant subsections in the description of dependencies, but that would require those subsections to exist. It looks like all the installation instructions (including the installation instructions for building documentation) could benefit from being rewritten, but that's going beyond the scope of this pull request and is best done in a separate pull request instead.


If you are looking to do development in Astropy beyond running the tests, e.g. building
the documentation or doing static analysis, we provide the complete set of all
dependencies with the ``dev_all`` option::

python -m pip install --editable ".[dev_all]"

A detailed description of the |pytest-astropy| plugins can be found in the
:ref:`pytest-plugins` section.

.. _running-tests:

Expand Down
2 changes: 1 addition & 1 deletion docs/development/workflow/development_workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ install the version of ``astropy`` you are working on into it. Do that with:

.. code-block:: bash

python -m pip install --editable ".[test]"
python -m pip install --editable ".[test_all]"

This will install ``astropy`` itself, along with a few packages which will be
useful for testing the changes you will make down the road.
Expand Down
79 changes: 52 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,30 @@ dependencies = [
]

[project.optional-dependencies]
test = [
"pytest>=7.0",
"pytest-doctestplus>=0.12",
"pytest-astropy-header>=0.2.1",
"pytest-astropy>=0.10",
"pytest-xdist",
"threadpoolctl",
]
test_all = [
"astropy[test]", # installs the [test] dependencies
"objgraph",
"ipykernel",
"ipython>=7.32",
"ipywidgets",
"coverage[toml]",
"skyfield>=1.20",
"sgp4>=2.3",
"array-api-strict",
]
# Recommended run-time dependencies to enable a lot of functionality within Astropy.
recommended = [
"scipy>=1.8",
"matplotlib>=3.3,!=3.4.0,!=3.5.2",
]
typing = [
"typing_extensions>=4.0.0"
# Optional IPython-related behavior is in many places in Astropy. IPython is a complex
# dependency that occasionally requires pinning one of it's upstream dependencies. If
# you are using Astropy from an IPython-dependent IDE, like Jupyter, this should enforce
# the minimum supported version of IPython.
ipython = [
"ipython>=7.32",
]
jupyter = [ # these are optional dependencies for `utils.console`
"astropy[ipython]",
"ipywidgets",
"ipykernel",
]
Comment on lines +62 to 66
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this install jupyter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it does. But I'm also not sure it should: jupyter comes in different shapes (jupyterlab and notebook) and we don't need to impose a choice onto our users (I think ?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something seems to be pulling in jupyter stack but it is already that way in main. Hmm!

2024-05-19T22:19:37.9405799Z jupyter_client==8.6.1
2024-05-19T22:19:37.9406161Z jupyter_core==5.7.2
2024-05-19T22:19:37.9406568Z jupyterlab_widgets==3.0.10

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just moving around the dependencies, not adding any. I titled it jupyter since it's for use when in a Jupyter environment.

Copy link
Member Author

@nstarman nstarman May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in contrast to the ipython dep, which enables functionality in astropy.utils.console within any ipython environment not just a Jupyter one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you expect anyone to ever use the ipython and jupyter dependency sets?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Even if not publicly advertised, these things have a way of finding their users, in my experience.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For another PR, but I do think we should have a page detailing these install options. Like...

If you're using an IPYthon environment, use astropy[ipython]. This is further improved by astropy[jupyter] when in a Jupyter notebook. astropy[typing] improves static typing compatibility. To get everything do astropy[all].

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might indeed be the case that documentation could explain what these dependency sets would be good for, but the more dependency sets we have, the more documentation we need to explain them. At some point the more granular dependency sets will not be worth the effort of documenting them.

# This is ALL the run-time optional dependencies.
all = [
"astropy[recommended]", # installs the [recommended] dependencies
"astropy[typing]",
# Install grouped optional dependencies
"astropy[recommended]",
"astropy[ipython]",
"astropy[jupyter]",
# Install all remaining optional dependencies
"certifi",
"dask[array]",
"h5py",
Expand All @@ -90,13 +85,32 @@ all = [
"mpmath",
"asdf-astropy>=0.3",
"bottleneck",
"ipykernel",
"ipython>=7.32",
"ipywidgets",
"pytest>=7.0",
"fsspec[http]>=2023.4.0",
"s3fs>=2023.4.0",
]
# The base set of test-time dependencies.
test = [
"coverage[toml]",
"pre-commit",
"pytest>=7.0",
"pytest-doctestplus>=0.12",
"pytest-astropy-header>=0.2.1",
"pytest-astropy>=0.10",
"pytest-xdist",
"threadpoolctl",
]
test_all = [
# Install grouped optional dependencies
"astropy[all]", # installs all optional run-time dependencies
"astropy[test]",
# Install all remaining dependencies
"objgraph",
"skyfield>=1.20",
"sgp4>=2.3",
"array-api-strict",
]
typing = [
"typing_extensions>=4.0.0",
]
docs = [
"astropy[recommended]", # installs the [recommended] dependencies
Expand All @@ -110,6 +124,17 @@ docs = [
"sphinxcontrib-globalsubs >= 0.1.1",
"matplotlib!=3.9.0", # https://github.com/matplotlib/matplotlib/issues/28234
]
# These group together all the dependencies needed for developing in Astropy.
dev = [
"astropy[recommended]", # installs the most common optional dependencies
"astropy[test]",
"astropy[docs]",
"astropy[typing]",
]
dev_all = [
"astropy[dev]",
"astropy[test_all]",
]

[project.urls]
homepage = "https://www.astropy.org/"
Expand Down