Skip to content

Commit 7efabb2

Browse files
author
benoit-cty
committed
How to build doc
1 parent 9670801 commit 7efabb2

3 files changed

Lines changed: 1249 additions & 793 deletions

File tree

CONTRIBUTING.md

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ You have a cool idea, but do not know know if it fits with Code Carbon? You can
7070
<!-- TOC --><a name="installation"></a>
7171
### Installation
7272

73-
CodeCarbon is a Python package, to contribute to it, you need to have Python installed on your machine, natively or with [Conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/).
73+
CodeCarbon is a Python package, to contribute to it, you need to have Python installed on your machine, natively or with [Conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/), or better, faster, stronger with [UV](https://github.com/astral-sh/uv).
7474

7575
Between April 2024 and July 2025 we use Hatch for managing development environment. Since August 2025 we use UV manages the environments, Python versions, and dependencies - it's a fast, reliable way to work with Python projects.
7676

@@ -87,19 +87,8 @@ Then, clone the repository and create the environment with:
8787
```sh
8888
git clone https://github.com/mlco2/codecarbon.git
8989
cd codecarbon
90-
uv venv
91-
uv pip install -e .
92-
uv pip install -e ".[dev,test]"
93-
```
94-
95-
To activate the virtual environment:
96-
97-
```sh
98-
# On Linux/macOS
99-
source .venv/bin/activate
100-
101-
# On Windows
102-
.venv\Scripts\activate
90+
uv sync
91+
uv run task pre-commit-install
10392
```
10493

10594
<!-- TOC --><a name="some-uv-commands"></a>
@@ -108,20 +97,12 @@ source .venv/bin/activate
10897
UV simplifies Python package management with fast, reliable commands:
10998

11099
```sh
111-
# Install the package in development mode
112-
uv pip install -e .
113-
114-
# Install with optional dependencies
115-
uv pip install -e ".[viz]"
116-
117-
# Install dev dependencies
118-
uv pip install -e ".[dev]"
119-
120-
# Run a script defined in pyproject.toml
121-
uv run test
122-
123-
# Update all dependencies
124-
uv pip compile requirements.in -o requirements.txt
100+
# Show dependencies
101+
uv tree
102+
# Add a dependency
103+
uv add --dev pytest
104+
# List all task for CodeCarbon
105+
uv run task -l
125106
```
126107

127108
<!-- TOC --><a name="tests"></a>
@@ -130,22 +111,12 @@ uv pip compile requirements.in -o requirements.txt
130111
You can run the unit tests by running UV in the terminal when in the root package directory:
131112

132113
```sh
133-
uv run test
134-
```
135-
136-
To run integration tests:
137-
138-
```sh
139-
uv run test-integ
114+
uv run task test-package
140115
```
141116

142117
You can also run a specific test:
143118

144119
```sh
145-
uv run pytest tests/test_cloud.py
146-
147-
# or
148-
149120
uv run python -m unittest tests.test_your_feature.YourTestCase.test_function
150121
```
151122

@@ -308,15 +279,16 @@ to regenerate the html files.
308279
<!-- TOC --><a name="release-process"></a>
309280
### Release process
310281

311-
- Merge all PRs.
312-
- Create a PR bumping the version with `uv run bumpver update --patch`. For a release candidate, use `uv run bumpver update --set-version 3.0.0_rc1`.
313-
- Run `uv run python3 .github/check_version.py` to check version consistancy.
314-
- Update the dependencies with `uv pip compile requirements.in -o requirements.txt`.
315-
- [Build Documentation](#documentation) if needed with `uv run docs`.
316-
- Push the changes.
317-
- Merge the PR.
318-
- Wait for the Github Action `ReleaseDrafter` to finish running on the merge commit.
319-
- [Edit the Draft release](https://github.com/mlco2/codecarbon/releases/) on Github and give it a tag, `v1.0.0` for the version 1.0.0. Github will automatically create a Git tag for it. Complete help [here](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository).
282+
- Merge all PRs.
283+
- Create a PR bumping the version with `uv run bumpver update --patch`. For a release candidate, use `uv run bumpver update --set-version 3.0.0_rc1`.
284+
- Run `uv run python3 .github/check_version.py` to check version consistancy.
285+
- Update the dependencies with `uv sync --upgrade`
286+
- Export a requirements.txt `uv pip freeze > requirements.txt`.
287+
- [Build Documentation](#documentation) with `uv run --only-group doc task docs`.
288+
- Push the changes.
289+
- Merge the PR.
290+
- Wait for the Github Action `ReleaseDrafter` to finish running on the merge commit.
291+
- [Edit the Draft release](https://github.com/mlco2/codecarbon/releases/) on Github and give it a tag, `v1.0.0` for the version 1.0.0. Github will automatically create a Git tag for it. Complete help [here](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository).
320292
- A [Github Action](https://github.com/mlco2/codecarbon/actions) _Upload Python Package_ will be run automaticaly to upload the package.
321293
- For conda, we now have a [feedstock](https://github.com/conda-forge/codecarbon-feedstock/pulls) to publish to Conda-Forge channel.
322294

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ dev = [
5959
"ruff",
6060
"black",
6161
"mypy",
62+
"pytest>=7.4.4",
6263
]
6364
# TODO: Put in detached ?
6465
doc = [

0 commit comments

Comments
 (0)