Skip to content

Commit fdb7e70

Browse files
authored
Merge pull request #398 from DoubleML/sk-add-uv
update development setup with uv and adjust dependencies in pyproject.toml
2 parents 22a2ed0 + 687fd02 commit fdb7e70

6 files changed

Lines changed: 41 additions & 17 deletions

File tree

.github/workflows/pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Install dependencies
4747
run: |
4848
python -m pip install --upgrade pip
49-
pip install -e .[dev,rdd]
49+
pip install -e ".[rdd]" --group dev
5050
5151
- name: Run pre-commit checks
5252
run: |

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ share/python-wheels/
2828
*.vscode
2929
MANIFEST
3030
*.idea
31-
*.vscode
3231
.flake8
3332
.coverage
3433

3534
# Setuptools SCM
3635
doubleml/_version.py
36+
37+
# uv
38+
.venv/
39+
uv.lock

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

CONTRIBUTING.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
DoubleML is a community effort.
44
Everyone is welcome to contribute.
5-
All contributors should adhere to this contributing guidelines
5+
All contributors should adhere to these contributing guidelines
66
and our [code of conduct](https://github.com/DoubleML/doubleml-for-py/blob/main/CODE_OF_CONDUCT.md).
77
The contributing guidelines are particularly helpful to get started for your first contribution.
88

@@ -34,7 +34,7 @@ In case of an exception the full traceback is appreciated.
3434
```python
3535
import platform; print(platform.platform())
3636
import sys; print("Python", sys.version)
37-
import doubleml; print("DoubleML", sklearn.__version__)
37+
import doubleml; print("DoubleML", doubleml.__version__)
3838
import sklearn; print("Scikit-Learn", sklearn.__version__)
3939
```
4040

@@ -79,10 +79,19 @@ $ git merge upstream/main
7979
```
8080

8181
5. **Install DoubleML in editable mode** (more details can be found
82-
[here](https://docs.doubleml.org/stable/intro/install.html#python-building-the-package-from-source))
83-
via
82+
[here](https://docs.doubleml.org/stable/intro/install.html#python-building-the-package-from-source)).
83+
84+
We recommend [uv](https://docs.astral.sh/uv/) for development. The following command creates a virtual
85+
environment, provisions Python 3.12 (as pinned in `.python-version`), and installs DoubleML in editable
86+
mode together with the `dev` dependency group and the `rdd` extra:
87+
```bash
88+
$ uv sync --extra rdd
89+
```
90+
Prefix tooling commands with `uv run` to execute them inside this environment (e.g. `uv run pytest .`).
91+
92+
Alternatively, you can use `pip` (requires pip >= 25.1 for the `--group` flag):
8493
```bash
85-
$ pip install --editable .[dev, rdd]
94+
$ pip install --editable ".[rdd]" --group dev
8695
```
8796

8897
6. **Develop** your code changes. The changes can be added and pushed via
@@ -109,7 +118,7 @@ When opening the PR you will be guided with a checklist.
109118
for details).
110119
To check, please run
111120
```bash
112-
$ pytest .
121+
$ uv run pytest . # or, without uv: pytest .
113122
```
114123

115124
- [x] If you add an **enhancements** or **new feature**, **unit tests**
@@ -118,13 +127,13 @@ $ pytest .
118127
- [x] Check whether your changes adhere to the **PEP8 standards**.
119128
For the check you can use the following code
120129
```bash
121-
$ git diff upstream/main -u -- "*.py" | ruff check --diff
130+
$ git diff upstream/main -u -- "*.py" | uv run ruff check --diff # or: ... | ruff check --diff
122131
```
123132

124-
- [x] Check wether the code formatting adheres to the **Black code style**
133+
- [x] Check whether the code formatting adheres to the **Black code style**
125134
by running
126135
```bash
127-
$ black . --check --diff
136+
$ uv run black . --check --diff # or, without uv: black . --check --diff
128137
```
129138

130139
If your PR is still **work in progress**, please consider marking it a **draft PR**
@@ -137,13 +146,13 @@ To ensure code quality and consistency before committing your changes, we recomm
137146
1. **Install hooks**:
138147
If you haven't already, install the required hooks by running:
139148
```bash
140-
$ pre-commit install
149+
$ uv run pre-commit install # or, without uv: pre-commit install
141150
```
142151

143152
2. **Run pre-commit manually**:
144153
To run the pre-commit checks manually, use:
145154
```bash
146-
$ pre-commit run --all-files
155+
$ uv run pre-commit run --all-files # or, without uv: pre-commit run --all-files
147156
```
148157

149158
### Unit Tests and Test Coverage
@@ -156,7 +165,7 @@ Coverage reports for the package, PRs, branches etc. are available from
156165
It is mandatory to equip new features with an appropriate level of unit test coverage.
157166
To **run all unit tests** (for further option see the [pytest docu](https://docs.pytest.org)) call
158167
```bash
159-
$ pytest --cov .
168+
$ uv run pytest --cov . # or, without uv: pytest --cov .
160169
```
161170
If `pytest` is called with the `--cov` flag, a unit test coverage report is being generated.
162171

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ It further can be readily extended with regards to
6161
**DoubleML** requires
6262

6363
- Python
64-
- sklearn
64+
- scikit-learn
6565
- numpy
6666
- scipy
6767
- pandas
@@ -82,6 +82,15 @@ cd doubleml-for-py
8282
pip install --editable .
8383
```
8484

85+
For development we recommend [uv](https://docs.astral.sh/uv/), which sets up the
86+
environment (including the `dev` dependency group) in one step:
87+
88+
```
89+
git clone git@github.com:DoubleML/doubleml-for-py.git
90+
cd doubleml-for-py
91+
uv sync --extra rdd
92+
```
93+
8594
Detailed [installation instructions](https://docs.doubleml.org/stable/intro/install.html) can be found in the documentation.
8695

8796
## Contributing

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ dependencies = [
2525
"optuna>=4.6.0",
2626
"matplotlib>=3.9.0",
2727
"seaborn>=0.13",
28-
"plotly>=5.0.0",
29-
"mypy>=1.18.0"
28+
"plotly>=5.0.0"
3029
]
3130
classifiers = [
3231
"Programming Language :: Python :: 3",
@@ -42,6 +41,8 @@ classifiers = [
4241
rdd = [
4342
"rdrobust>=1.3.0"
4443
]
44+
45+
[dependency-groups]
4546
dev = [
4647
"pytest>=8.3.0",
4748
"pytest-cov>=6.0.0",
@@ -50,6 +51,7 @@ dev = [
5051
"black>=25.1.0",
5152
"ruff>=0.11.1",
5253
"pre-commit>=4.2.0",
54+
"mypy>=1.18.0",
5355
]
5456

5557
[project.urls]

0 commit comments

Comments
 (0)