Skip to content

Commit 1e9ee71

Browse files
Add developer requirements to setup.py (#712)
* Remove env_developer.yml in favor of setup.py extras * Remove `requirements/env_developer.yml`. * Add extras for docs and test to `setup.py`. * Fix requirements: - Remove descartes, it was not used. - Remove pandoc in favor of myst_nb. * Add instructions for installing extras * Install extra requirements in readthedocs pipeline * Fix typo in .readthedocs * Add myst-nb settings to doc/conf.py * Use colon instead of underscore in setup.py dep specs * Update CHANGELOG.md * Fix header slugs in doc/guide/Guide_CLIMADA_Tutorial.ipynb * installation guide: use double quotes for compatibility with Windows --------- Co-authored-by: emanuel-schmid <[email protected]>
1 parent 8379737 commit 1e9ee71

File tree

8 files changed

+93
-40
lines changed

8 files changed

+93
-40
lines changed

.readthedocs.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,12 @@ build:
88
conda:
99
environment: requirements/env_docs.yml
1010

11+
python:
12+
install:
13+
- method: pip
14+
path: .
15+
extra_requirements:
16+
- doc
17+
1118
formats:
1219
- pdf

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ Added:
1313
Changed:
1414

1515
Removed:
16+
- `nbsphinx` [#712](https://github.com/CLIMADA-project/climada_python/pull/712)
17+
- `pandoc` [#712](https://github.com/CLIMADA-project/climada_python/pull/712)
1618

1719
### Added
1820

1921
- `Impact.impact_at_reg` method for aggregating impacts per country or custom region [#642](https://github.com/CLIMADA-project/climada_python/pull/642)
2022
- `Impact.match_centroids` convenience method for matching (hazard) centroids to impact objects [#602](https://github.com/CLIMADA-project/climada_python/pull/602)
2123
- `climada.util.coordinates.match_centroids` method for matching (hazard) centroids to GeoDataFrames [#602](https://github.com/CLIMADA-project/climada_python/pull/602)
24+
- 'Extra' requirements `doc`, `test`, and `dev` for Python package [#712](https://github.com/CLIMADA-project/climada_python/pull/712)
2225

2326
### Changed
2427

@@ -31,6 +34,7 @@ Removed:
3134
- The sigmoid and step impact functions now require the user to define the hazard type. [#675](https://github.com/CLIMADA-project/climada_python/pull/675)
3235
- Improved error messages produced by `ImpactCalc.impact()` in case hazard type is not found in exposures/impf_set [#691](https://github.com/CLIMADA-project/climada_python/pull/691)
3336
- Tests with long runtime were moved to integration tests in `climada/test` [#709](https://github.com/CLIMADA-project/climada_python/pull/709)
37+
- Use `myst-nb` for parsing Jupyter Notebooks for the documentation instead of `nbsphinx` [#712](https://github.com/CLIMADA-project/climada_python/pull/712)
3438

3539
### Fixed
3640

@@ -40,6 +44,8 @@ Removed:
4044

4145
### Removed
4246

47+
- `requirements/env_developer.yml` environment specs. Use 'extra' requirements when installing the Python package instead [#712](https://github.com/CLIMADA-project/climada_python/pull/712)
48+
4349
## v3.3.2
4450

4551
Release date: 2023-03-02

doc/conf.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,10 @@
3838
'sphinx.ext.viewcode',
3939
'sphinx.ext.napoleon',
4040
'sphinx.ext.ifconfig',
41-
'nbsphinx',
42-
'myst_parser',
41+
'myst_nb',
4342
'sphinx_markdown_tables',
4443
'readthedocs_ext.readthedocs',]
4544

46-
nbsphinx_allow_errors = True
47-
4845
# read the docs version used for links
4946
if 'dev' in __version__:
5047
read_docs_url = 'en/latest/'
@@ -54,12 +51,6 @@
5451
# Add any paths that contain templates here, relative to this directory.
5552
templates_path = []
5653

57-
# The suffix of source filenames.
58-
source_suffix = {
59-
".rst": "restructuredtext",
60-
".md": "markdown",
61-
}
62-
6354
# The encoding of source files.
6455
#source_encoding = 'utf-8'
6556

@@ -247,6 +238,28 @@ def remove_module_docstring(app, what, name, obj, options, lines):
247238

248239
autodoc_member_order = "bysource"
249240

241+
# --- MYST Parser settings ----
242+
243+
# Jupyter Notebooks will not be executed when creating the docs
244+
nb_execution_mode = "off"
245+
246+
# Extensions, see https://myst-parser.readthedocs.io/en/latest/configuration.html#list-of-syntax-extensions
247+
myst_enable_extensions = [
248+
"amsmath",
249+
"colon_fence",
250+
"deflist",
251+
"dollarmath",
252+
"html_image",
253+
]
254+
255+
# URI schemes that are converted to external links
256+
myst_url_schemes = ("http", "https", "mailto")
257+
258+
# Generate heading anchors for linking to them, up to heading level 4
259+
myst_heading_anchors = 4
260+
261+
# ---
262+
250263
def setup(app):
251264
app.connect("autodoc-skip-member", skip)
252265
app.connect("autodoc-process-docstring", remove_module_docstring)

doc/guide/Guide_CLIMADA_Tutorial.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
"\n",
1616
"## Content\n",
1717
"\n",
18-
"- [Why tutorials](#Why-tutorials)\n",
19-
"- [Basic structure](#Basic-structure)\n",
20-
"- [Good examples](#Good-examples)\n",
21-
"- [Use only Markdown for headers and table of content](#Use-only-Markdown-for-headers-and-table-of-content)"
18+
"- [Why tutorials](#why-tutorials)\n",
19+
"- [Basic structure](#basic-structure)\n",
20+
"- [Good examples](#good-examples)\n",
21+
"- [Use only Markdown for headers and table of content](#use-only-markdown-for-headers-and-table-of-content)"
2222
]
2323
},
2424
{

doc/guide/install.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,35 @@ For advanced Python users or developers of CLIMADA, we recommed cloning the CLIM
169169
If this test passes, great!
170170
You are good to go.
171171

172+
Install Developer Dependencies (Optional)
173+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
174+
175+
Building the documentation and running the entire test suite of CLIMADA requires additional dependencies which are not installed by default.
176+
They are also not needed for using CLIMADA.
177+
However, if you want to develop CLIMADA, we recommend you install them.
178+
179+
With the ``climada_env`` activated, enter the workspace directory and then the CLIMADA repository as above.
180+
Then, add the ``dev`` extra specification to the ``pip install`` command (**mind the quotation marks**, and see also `pip install examples <https://pip.pypa.io/en/stable/cli/pip_install/#examples>`_):
181+
182+
.. code-block:: shell
183+
184+
python -m pip install -e "./[dev]"
185+
186+
The CLIMADA Python package defines the following `extras <https://peps.python.org/pep-0508/#extras>`_:
187+
188+
.. list-table::
189+
:header-rows: 1
190+
:widths: 1 5
191+
192+
* - Extra
193+
- Includes Dependencies...
194+
* - ``doc``
195+
- for building documentation
196+
* - ``test``
197+
- for running and evaluating tests
198+
* - ``dev``
199+
- combination of ``doc`` and ``test``
200+
172201
Install CLIMADA Petals (Optional)
173202
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
174203

requirements/env_climada.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,3 @@ dependencies:
4141
- xarray>=2023.3
4242
- xlrd>=2.0
4343
- xlsxwriter>=3.0
44-
- pip:
45-
- deprecation>=2.1
46-
- overpy>=0.6
47-
- peewee>=3.16

requirements/env_developer.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

setup.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@
1010
with open(here.joinpath('README.md'), encoding='utf-8') as f:
1111
long_description = f.read()
1212

13+
# Requirements for documentation
14+
DEPS_DOC = [
15+
"ipython",
16+
"myst-nb",
17+
"readthedocs-sphinx-ext>=2.2",
18+
"sphinx",
19+
"sphinx-book-theme",
20+
"sphinx-markdown-tables",
21+
]
22+
23+
# Requirements for testing
24+
DEPS_TEST = [
25+
"coverage>=7.2",
26+
"ipython",
27+
"mccabe>=0.6",
28+
"pylint==2.7.1",
29+
]
30+
1331
setup(
1432
name='climada',
1533

@@ -78,5 +96,11 @@
7896
'xmlrunner'
7997
],
8098

99+
extras_require={
100+
"doc": DEPS_DOC,
101+
"test": DEPS_TEST,
102+
"dev": DEPS_DOC + DEPS_TEST
103+
},
104+
81105
include_package_data=True
82106
)

0 commit comments

Comments
 (0)