Skip to content

Commit 7f2be73

Browse files
authored
Merge pull request #156 from pymc-labs/pyproject
`setup.py` is dead, long live `pyproject.toml`
2 parents 77dbbe9 + babaa46 commit 7f2be73

13 files changed

+112
-94
lines changed

.isort.cfg

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

CONTRIBUTING.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,15 @@ pip install -e .
2525
4. Install development dependencies
2626

2727
```
28-
pip install -r requirements-dev.txt
29-
pip install -r requirements-docs.txt
28+
pip install causalpy[dev]
29+
pip install causalpy[docs]
30+
```
31+
32+
If that fails, try:
33+
34+
```
35+
pip install 'causalpy[dev]'
36+
pip install 'causalpy[docs]'
3037
```
3138

3239
It may also be necessary to [install](https://pandoc.org/installing.html) `pandoc`. On a mac, I run `brew install pandoc`.
@@ -54,7 +61,7 @@ cd docs
5461
make html
5562
```
5663

57-
Sometimes not all changes are recognised. In that case run:
64+
Sometimes not all changes are recognised. In that case run this (again from within the `docs` folder):
5865

5966
```bash
6067
make clean && make html
@@ -70,16 +77,16 @@ The `.readthedocs.yaml` file contains the configurations for the remote build.
7077

7178
If there are autodoc issues/errors in remote builds of the docs, we need to add all package dependencies (in `requirements.txt`) into the list `autodoc_mock_imports` in `docs/config.py`.
7279

73-
## New releases [work in progress]
80+
## New releases
7481

7582
### Test release to `test.pypi.org` (manual)
7683

77-
1. Bump the release version in `causalpy/version.py`. This is automatically read by `setup.py` and `docs/config.py`.
78-
2. Build locally and upload to test.pypi.org. _Note that this requires username and password for test.pypi.org_. In the root directory type the following:
84+
1. Bump the release version in `causalpy/version.py` and `pyproject.toml`.
85+
2. Build locally and upload to test.pypi.org. Full instructions here https://packaging.python.org/en/latest/tutorials/packaging-projects/. _Note that this requires username and password for test.pypi.org_. In the root directory type the following:
7986
```bash
8087
rm -rf dist
81-
python setup.py sdist
82-
twine upload --repository testpypi dist/*
88+
python3 -m build
89+
python3 -m twine upload --repository testpypi dist/*
8390
```
8491
3. At this point the updated build is available on test.pypi.org. We can test that this is working as expected by installing (into a test environment) from test.pypi.org with
8592

@@ -93,14 +100,14 @@ python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-u
93100

94101
### Actual release to `pypi.org` (manual)
95102

96-
1. Bump the release version (if not done in the previous step) in `causalpy/version.py`. This is automatically read by `setup.py` and `docs/config.py`.
103+
1. Bump the release version in `causalpy/version.py` and `pyproject.toml` (if not done in the previous step). This is automatically read by `setup.py` and `docs/config.py`.
97104
2. Push this to a branch, open a pull request, and merge into main.
98105
3. Manually draft a new release [here](https://github.com/pymc-labs/CausalPy/releases), making sure to hit 'generate release notes'.
99106
4. Build locally and upload to pypi.org. In the root directory:
100107
```bash
101108
rm -rf dist
102-
python setup.py sdist
103-
twine upload dist/*
109+
python3 -m build
110+
python3 -m twine upload dist/*
104111
```
105112
5. Readthedocs:
106113
- Docs should be built remotely every time there is a pull request

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ init:
44
python -m pip install -e .
55

66
lint:
7-
pip install -r requirements-lint.txt
7+
pip install causalpy[lint]
88
isort .
99
black .
1010

1111
check_lint:
12-
pip install -r requirements-lint.txt
12+
pip install causalpy[lint]
1313
flake8 .
1414
isort --check-only .
1515
black --diff --check --fast .
@@ -18,5 +18,5 @@ check_lint:
1818
interrogate .
1919

2020
test:
21-
pip install -r requirements-test.txt
21+
pip install causalpy[test]
2222
pytest

causalpy/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.9"
1+
__version__ = "0.0.10b"

manifest.in

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

pyproject.toml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,95 @@
1+
[build-system]
2+
# Minimum requirements for the build system to execute.
3+
build-backend = "setuptools.build_meta"
4+
requires = ["setuptools>=61.0"]
5+
6+
# This is configuration specific to the `setuptools` build backend.
7+
# If you are using a different build backend, you will need to change this.
8+
[tool.setuptools]
9+
# define all packages here
10+
packages = ['causalpy', 'causalpy.data']
11+
12+
[project]
13+
name = "CausalPy"
14+
version = "0.0.10b"
15+
description = "Causal inference for quasi-experiments in Python"
16+
readme = "README.md"
17+
license = {file = "LICENSE"}
18+
authors = [{ name = "Ben Vincent", email = "[email protected]" }]
19+
requires-python = ">=3.8"
20+
21+
# This field lists other packages that your project depends on to run.
22+
# Any package you put here will be installed by pip when your project is
23+
# installed, so they must be valid existing projects.
24+
#
25+
# For an analysis of this field vs pip's requirements files see:
26+
# https://packaging.python.org/discussions/install-requires-vs-requirements/
27+
dependencies = [
28+
"arviz>=0.14.0",
29+
"graphviz",
30+
"ipython!=8.7.0",
31+
"matplotlib>=3.5.3",
32+
"numpy",
33+
"pandas",
34+
"patsy",
35+
"pymc>=5.0.0",
36+
"scikit-learn>=1",
37+
"scipy",
38+
"seaborn>=0.11.2",
39+
"xarray>=v2022.11.0",
40+
]
41+
42+
# List additional groups of dependencies here (e.g. development dependencies). Users
43+
# will be able to install these using the "extras" syntax, for example:
44+
#
45+
# $ pip install causalpy[dev]
46+
#
47+
# Similar to `dependencies` above, these must be valid existing projects.
48+
[project.optional-dependencies]
49+
dev = [
50+
"pathlib",
51+
"pre-commit",
52+
"twine",
53+
"interrogate",
54+
]
55+
docs = ["ipykernel",
56+
"linkify-it-py",
57+
"myst_parser",
58+
"nbsphinx",
59+
"pathlib",
60+
"sphinx",
61+
"sphinx-autodoc-typehints",
62+
"sphinx-design",
63+
"sphinx-rtd-theme",
64+
"statsmodels",
65+
]
66+
lint = ["black",
67+
"flake8",
68+
"interrogate",
69+
"isort",
70+
"nbqa",
71+
"pre-commit"
72+
]
73+
test = [
74+
"pytest",
75+
"pytest-cov",
76+
]
77+
78+
[metadata]
79+
description-file = 'README.md'
80+
license_files = 'LICENSE'
81+
82+
[project.urls]
83+
Homepage = "https://github.com/pymc-labs/CausalPy"
84+
"Bug Reports" = "https://github.com/pymc-labs/CausalPy/issues"
85+
"Source" = "https://github.com/pymc-labs/CausalPy"
86+
87+
[tool.black]
88+
line_length = 88
89+
190
[tool.isort]
291
profile = "black"
92+
skip_gitignore = true
393

494
[tool.pytest.ini_options]
595
addopts = [

requirements-dev.txt

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

requirements-docs.txt

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

requirements-lint.txt

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

requirements-test.txt

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

0 commit comments

Comments
 (0)