Skip to content

Commit f57e87b

Browse files
committed
Modernize Python package structure
1 parent fb89f49 commit f57e87b

18 files changed

Lines changed: 126 additions & 166 deletions

.github/workflows/docbuild.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ jobs:
3030
- name: Install dependencies
3131
run: |
3232
python -m pip install --upgrade pip
33-
python -m pip install -r requirements.txt
34-
python -m pip install -r requirements-dev.txt
35-
python -m pip install .
33+
python -m pip install ".[docs]"
3634
- name: Build docs
3735
working-directory: docs
3836
run: make html

.github/workflows/pythonpackage.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ jobs:
6363
- name: Install dependencies
6464
run: |
6565
python -m pip install --upgrade pip
66-
python -m pip install -r requirements-test.txt
67-
python -m pip install "numpy<2" "${{ matrix.sklearn-spec }}"
68-
python -m pip install --no-deps .
66+
python -m pip install ".[test]" "numpy<2" "${{ matrix.sklearn-spec }}"
6967
python -m pip check
7068
- name: Show resolved versions
7169
run: |

MANIFEST.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ and test increasing the number of trees in the model to reach convergence.
3131

3232
Before installing the module you will need `numpy`, `scipy` and `scikit-learn`.
3333

34-
To install `forest-confidence-interval` execute:
34+
To install `forest-confidence-interval`, run:
35+
3536
```
36-
pip install forestci
37+
python -m pip install forestci
3738
```
38-
If would like to install the development version of the software use:
39+
40+
To install the development version from GitHub, use:
3941

4042
```shell
41-
pip install git+git://github.com/scikit-learn-contrib/forest-confidence-interval.git
43+
python -m pip install git+https://github.com/scikit-learn-contrib/forest-confidence-interval.git
4244
```
4345

4446
Usage:
@@ -84,12 +86,25 @@ E-mail [Ariel Rokem](mailto:arokem@gmail.com), [Kivan Polimis](mailto:kivan.poli
8486

8587
## Testing
8688

87-
Tests live in the top-level `tests/` directory. To test against the
88-
scikit-learn version already installed in your current environment, install
89-
only the test runner and the local package without resolving its dependencies:
89+
The project uses a `pyproject.toml` build configuration and a `src/` package
90+
layout. Runtime, test, documentation, and development dependencies are declared
91+
as project dependency groups, while tests live in the top-level `tests/`
92+
directory.
93+
94+
For a complete development environment, install the editable package and its
95+
development dependencies:
96+
97+
```shell
98+
python -m pip install -e ".[dev]"
99+
python -m pytest
100+
```
101+
102+
To test only against the scikit-learn version already installed in the current
103+
environment, install the test runner and then install `forestci` without
104+
resolving dependencies:
90105

91106
```shell
92-
python -m pip install -r requirements-test.txt
107+
python -m pip install pytest==9.0.3
93108
python -m pip install --no-deps -e .
94109
python -m pytest
95110
```

docs/conf.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import sys
1616
import os
1717

18-
import sphinx_gallery
1918
import sphinx_rtd_theme
2019

2120
# If extensions (or modules to document with autodoc) are in another directory,
@@ -36,6 +35,7 @@
3635
'sphinx.ext.autosummary',
3736
'sphinx.ext.doctest',
3837
'sphinx.ext.intersphinx',
38+
'sphinx.ext.imgmath',
3939
'sphinx.ext.viewcode',
4040
'numpydoc',
4141
'sphinx_gallery.gen_gallery',
@@ -47,14 +47,6 @@
4747
# see https://github.com/numpy/numpydoc/issues/69
4848
numpydoc_show_class_members = False
4949

50-
# pngmath / imgmath compatibility layer for different sphinx versions
51-
import sphinx
52-
from distutils.version import LooseVersion
53-
if LooseVersion(sphinx.__version__) < LooseVersion('1.4'):
54-
extensions.append('sphinx.ext.pngmath')
55-
else:
56-
extensions.append('sphinx.ext.imgmath')
57-
5850
# autodoc_default_flags = ['members', 'inherited-members']
5951

6052
# autodoc_default_options = True
@@ -150,9 +142,6 @@
150142
# documentation.
151143
#html_theme_options = {}
152144

153-
# Add any paths that contain custom themes here, relative to this directory.
154-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
155-
156145
# The name for this set of Sphinx documents. If None, it defaults to
157146
# "<project> v<release> documentation".
158147
#html_title = None
@@ -229,10 +218,10 @@
229218
intersphinx_mapping = {
230219
'python': ('https://docs.python.org/{.major}'.format(
231220
sys.version_info), None),
232-
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
233-
'scipy': ('https://docs.scipy.org/doc/scipy/reference', None),
234-
'matplotlib': ('https://matplotlib.org/', None),
235-
'sklearn': ('http://scikit-learn.org/stable', None)
221+
'numpy': ('https://numpy.org/doc/stable/', None),
222+
'scipy': ('https://docs.scipy.org/doc/scipy/', None),
223+
'matplotlib': ('https://matplotlib.org/stable/', None),
224+
'sklearn': ('https://scikit-learn.org/stable/', None)
236225
}
237226

238227
# sphinx-gallery configuration

docs/installation_guide.rst

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
Installation Guide
44
==================
55

6-
Before installing the `forestci` module, you will need `numpy`, `scipy`
7-
and `scikit-learn`
6+
To install `forestci` and its dependencies:
87

98
.. code-block:: bash
109
11-
pip install numpy scipy scikit-learn
10+
python -m pip install forestci
1211
13-
Then, to install `forestci`:
12+
If you wish to install from the source code (available `here <https://github.com/scikit-learn-contrib/forest-confidence-interval>`_),
13+
change your working directory to the top-level directory and install the
14+
package in editable mode. Development dependencies are declared in
15+
``pyproject.toml``:
1416

1517
.. code-block:: bash
1618
17-
pip install forestci
18-
19-
If you wish to install from the source code (available `here <https://github.com/scikit-learn-contrib/forest-confidence-interval>`_ ), change your working directory to the top-level directory of the source code, and issue:
20-
21-
.. code-block:: bash
22-
23-
python setup.py install
19+
python -m pip install -e ".[dev]"

forestci/version.py

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

pyproject.toml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
[build-system]
2+
requires = ["setuptools>=77"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "forestci"
7+
dynamic = ["version"]
8+
description = "Confidence intervals for scikit-learn forest algorithms"
9+
readme = "README.md"
10+
license = "MIT"
11+
license-files = ["LICENSE"]
12+
authors = [
13+
{ name = "Ariel Rokem", email = "arokem@uw.edu" },
14+
{ name = "Bryna Hazelton" },
15+
{ name = "Kivan Polimis" },
16+
]
17+
maintainers = [
18+
{ name = "Ariel Rokem", email = "arokem@uw.edu" },
19+
]
20+
requires-python = ">=3.10"
21+
classifiers = [
22+
"Development Status :: 3 - Alpha",
23+
"Environment :: Console",
24+
"Intended Audience :: Science/Research",
25+
"Operating System :: OS Independent",
26+
"Programming Language :: Python",
27+
"Programming Language :: Python :: 3",
28+
"Programming Language :: Python :: 3 :: Only",
29+
"Programming Language :: Python :: 3.10",
30+
"Programming Language :: Python :: 3.11",
31+
"Programming Language :: Python :: 3.12",
32+
"Topic :: Scientific/Engineering",
33+
]
34+
dependencies = [
35+
"numpy>=1.20",
36+
"scikit-learn>=1.0,<2.0",
37+
"scipy",
38+
]
39+
40+
[project.optional-dependencies]
41+
test = [
42+
"pytest==9.0.3",
43+
]
44+
docs = [
45+
"matplotlib",
46+
"numpydoc",
47+
"pandas",
48+
"pillow",
49+
"sphinx",
50+
"sphinx-autoapi",
51+
"sphinx-gallery",
52+
"sphinx-rtd-theme",
53+
]
54+
dev = [
55+
"flake8",
56+
"matplotlib",
57+
"numpydoc",
58+
"pandas",
59+
"pillow",
60+
"pytest==9.0.3",
61+
"sphinx",
62+
"sphinx-autoapi",
63+
"sphinx-gallery",
64+
"sphinx-rtd-theme",
65+
]
66+
67+
[project.urls]
68+
Documentation = "https://contrib.scikit-learn.org/forest-confidence-interval/"
69+
Source = "https://github.com/scikit-learn-contrib/forest-confidence-interval"
70+
Issues = "https://github.com/scikit-learn-contrib/forest-confidence-interval/issues"
71+
72+
[tool.setuptools]
73+
package-dir = { "" = "src" }
74+
75+
[tool.setuptools.dynamic]
76+
version = { attr = "forestci.version.__version__" }
77+
78+
[tool.setuptools.packages.find]
79+
where = ["src"]
80+
81+
[tool.pytest.ini_options]
82+
addopts = "--doctest-modules"
83+
testpaths = [
84+
"src/forestci",
85+
"tests",
86+
]

requirements-dev.txt

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

requirements-test.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)