Skip to content

Commit 0b3754d

Browse files
IamLRBAbenoit-cty
authored andcommitted
Remove Conda support and update documentation Fixes #1017
1 parent 68b98ad commit 0b3754d

8 files changed

Lines changed: 49 additions & 222 deletions

File tree

.conda/recipe.yaml

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

.conda/variants.yaml

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

.github/pyproject_versions.py

Lines changed: 33 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Read package version in pyproject.toml and replace it in .conda/recipe.yaml
1+
# Read package version in pyproject.toml
22
# Also provides version coherence checking across multiple files
33

44
import argparse
@@ -132,48 +132,10 @@ def get_versions():
132132
}
133133

134134

135-
def replace_in_file(filepath: str, info: dict):
136-
"""
137-
::filepath:: Path to recipe.yaml, with filename
138-
::info:: Dict with information to populate
139-
"""
140-
with open(filepath, "rt") as fin:
141-
meta = fin.read()
142-
# Replace with info from pyproject.toml
143-
if PACKAGE_VERSION not in meta:
144-
raise Exception(f"{PACKAGE_VERSION=} not found in {filepath}")
145-
meta = meta.replace(PACKAGE_VERSION, info["package_version"])
146-
if " - dependencies" not in meta:
147-
raise Exception(f'" - dependencies" not found in {filepath}')
148-
dependencies = ""
149-
for dep in info["dependencies"]:
150-
if "fief-client" in dep:
151-
# Prevent to have unsupported "fief-client[cli]" in dependencies
152-
dependencies += " - fief-client-fastapi\n - yaspin\n"
153-
else:
154-
dependencies += f" - {dep}\n"
155-
meta = meta.replace(" - dependencies", dependencies)
156-
with open(filepath, "wt") as fout:
157-
fout.write(meta)
158-
logging.info(
159-
f"File {filepath} has been updated with informations from pyproject.toml."
160-
)
161-
162-
163-
if __name__ == "__main__":
164-
parser = argparse.ArgumentParser()
165-
parser.add_argument(
166-
"-r",
167-
"--replace",
168-
action="store_true",
169-
help="replace in file",
170-
)
171-
parser.add_argument(
172-
"-f",
173-
"--filename",
174-
type=str,
175-
default=".conda/recipe.yaml",
176-
help="Path to recipe.yaml, with filename",
135+
def main():
136+
"""Main entry point for the script."""
137+
parser = argparse.ArgumentParser(
138+
description="Read package version and check version coherence"
177139
)
178140
parser.add_argument(
179141
"-o",
@@ -187,27 +149,39 @@ def replace_in_file(filepath: str, info: dict):
187149
action="store_true",
188150
help="Check version coherence across all bumpver-managed files",
189151
)
152+
153+
# Parse arguments - all arguments are optional, so this works fine with no args
190154
args = parser.parse_args()
191155

192-
# Check version coherence first if requested or before any operations
156+
# Check version coherence first if requested
193157
if args.check_coherence:
194158
coherence_ok = check_version_coherence()
195159
sys.exit(0 if coherence_ok else 1)
196160

197-
# Always check coherence before doing replacements or showing versions
198-
if not check_version_coherence(quiet=True):
199-
logging.error("Aborting due to version coherence issues.")
161+
# If only_package_version is requested, just print version and exit
162+
if args.only_package_version:
163+
try:
164+
info = get_versions()
165+
print(f'{info["package_version"]}')
166+
sys.exit(0)
167+
except Exception as e:
168+
logging.error(f"Error getting version: {e}")
169+
sys.exit(1)
170+
171+
# Default behavior: check coherence quietly, then show versions
172+
try:
173+
if not check_version_coherence(quiet=True):
174+
logging.error("Aborting due to version coherence issues.")
175+
sys.exit(1)
176+
177+
info = get_versions()
178+
logging.info("Versions:")
179+
print(info) # noqa: T201
180+
sys.exit(0)
181+
except Exception as e:
182+
logging.error(f"Error: {e}")
200183
sys.exit(1)
201184

202-
info = get_versions()
203-
file = args.filename
204-
if args.only_package_version:
205-
print(f'{info["package_version"]}')
206-
exit()
207-
logging.info("Versions :")
208-
print(info) # noqa: T201
209-
if args.replace:
210-
logging.info(f"Replace in {file}")
211-
replace_in_file(file, info)
212-
else:
213-
logging.info("Dry mode, no replace made")
185+
186+
if __name__ == "__main__":
187+
main()

.github/workflows/package.yml

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -71,47 +71,3 @@ jobs:
7171
codecarbon --help
7272
python -c "from codecarbon import EmissionsTracker; print('✓ Package import successful')"
7373
74-
build-conda:
75-
runs-on: ubuntu-24.04
76-
steps:
77-
- name: Checkout
78-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
79-
- name: Cache build
80-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
81-
with:
82-
path: /tmp/conda-bld
83-
key: build-conda-${{ github.sha }}
84-
- name: set version
85-
run: |
86-
python3 .github/pyproject_versions.py --check_coherence --replace
87-
- name: Build conda package
88-
uses: prefix-dev/rattler-build-action@20cb88d3095cc01fa181385021c57f886d624879 # v0.2.16
89-
with:
90-
build-args: --channel codecarbon --channel conda-forge --output-dir /tmp/conda-bld
91-
recipe-path: .conda/recipe.yaml
92-
upload-artifact: false
93-
test-conda:
94-
runs-on: ubuntu-24.04
95-
needs: [ build-conda ]
96-
steps:
97-
# Checkout needed to get github.sha
98-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
99-
- name: Setup conda
100-
uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1
101-
with:
102-
activate-environment: codecarbon
103-
miniforge-version: latest
104-
python-version: 3.12
105-
use-mamba: true
106-
- name: Restore build
107-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
108-
with:
109-
path: /tmp/conda-bld
110-
key: build-conda-${{ github.sha }}
111-
fail-on-cache-miss: true
112-
- name: Install package
113-
shell: bash -l {0}
114-
run: mamba install --channel file:///tmp/conda-bld --channel codecarbon codecarbon
115-
- name: Test conda package
116-
shell: bash -l {0}
117-
run: codecarbon --help

.github/workflows/python-publish.yml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,3 @@ jobs:
3333
run: uv build
3434
- name: Publish package
3535
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1.13.0
36-
publish-to-conda:
37-
runs-on: ubuntu-24.04
38-
needs: [ deploy-pypi ]
39-
steps:
40-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
41-
- name: Restore build
42-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
43-
with:
44-
path: /tmp/conda-bld
45-
key: build-conda-${{ github.sha }}
46-
fail-on-cache-miss: true
47-
- uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1
48-
with:
49-
activate-environment: codecarbon
50-
miniforge-version: latest
51-
python-version: 3.12
52-
use-mamba: true
53-
- name: Install package
54-
shell: bash -l {0}
55-
run: mamba install --channel file:///tmp/conda-bld --channel codecarbon codecarbon
56-
- name: Test conda package
57-
shell: bash -l {0}
58-
run: codecarbon --help
59-
- name: Conda upload already build package
60-
shell: bash -l {0}
61-
env:
62-
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
63-
run: |
64-
anaconda upload --user codecarbon /tmp/conda-bld/noarch/codecarbon-*.tar.bz2

CONTRIBUTING.md

Lines changed: 1 addition & 16 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/), or better, faster, stronger with [UV](https://github.com/astral-sh/uv).
73+
CodeCarbon is a Python package, to contribute to it, you need to have Python installed on your machine, natively or 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

@@ -258,7 +258,6 @@ Dependencies are defined in different places:
258258

259259
- In [pyproject.toml](pyproject.toml#L28), those are all the dependencies.
260260
- In [uv.lock](uv.lock), those are the locked dependencies managed by UV, do not edit them.
261-
- In [.conda/meta.yaml](.conda/meta.yaml#L21), those are the dependencies for the Conda pacakge targeting Python 3.7 and higher versions.
262261

263262

264263
<!-- TOC --><a name="build-documentation-"></a>
@@ -288,20 +287,6 @@ to regenerate the html files.
288287
- Wait for the Github Action `ReleaseDrafter` to finish running on the merge commit.
289288
- [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).
290289
- A [Github Action](https://github.com/mlco2/codecarbon/actions) _Upload Python Package_ will be run automaticaly to upload the package.
291-
- For conda, we now have a [feedstock](https://github.com/conda-forge/codecarbon-feedstock/pulls) to publish to Conda-Forge channel.
292-
293-
If you still want to publish to the Anaconda CodeCarbon channel:
294-
295-
Start a Docker image in the same directory and bind-mount the current directory with:
296-
297-
`docker run -ti --rm=true -v $PWD:/data continuumio/anaconda3`.
298-
299-
Inside the docker container, run:
300-
301-
- `conda install -y conda-build conda-verify`
302-
- `cd /data && mkdir -p /conda_dist`
303-
- `conda build --python 3.11 .conda/ -c conda-forge --output-folder /conda_dist`
304-
- `anaconda upload --user codecarbon /conda_dist/noarch/codecarbon-*.tar.bz2`
305290

306291
#### Test the build in Docker
307292

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ CodeCarbon websites:
1313

1414
<br/>
1515

16-
[![](https://anaconda.org/conda-forge/codecarbon/badges/version.svg)](https://anaconda.org/conda-forge/codecarbon)
17-
[![](https://anaconda.org/codecarbon/codecarbon/badges/version.svg)](https://anaconda.org/codecarbon/codecarbon)
1816
[![](https://img.shields.io/pypi/v/codecarbon?color=024758)](https://pypi.org/project/codecarbon/)
1917
[![DOI](https://zenodo.org/badge/263364731.svg)](https://zenodo.org/badge/latestdoi/263364731)
2018
<!-- [![Downloads](https://static.pepy.tech/badge/codecarbon/month)](https://pepy.tech/project/codecarbon) -->
@@ -63,10 +61,13 @@ Our hope is that this package will be used widely for estimating the carbon foot
6361
pip install codecarbon
6462
```
6563

66-
**From Conda repository**
64+
**Using Conda environments**
65+
If you're using Conda, you can install CodeCarbon with pip in your Conda environment:
6766
```python
68-
conda install -c codecarbon codecarbon
67+
conda activate your_env
68+
pip install codecarbon
6969
```
70+
7071
To see more installation options please refer to the documentation: [**Installation**](https://mlco2.github.io/codecarbon/installation.html#)
7172

7273
## Start to estimate your impact 📏

docs/edit/installation.rst

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@
33
Installing CodeCarbon
44
=====================
55

6-
Create a virtual environment using `conda` for easier management of dependencies and packages.
7-
For installing conda, follow the instructions on the
8-
`official conda website <https://docs.conda.io/projects/conda/en/latest/user-guide/install>`__
9-
10-
.. code-block:: bash
11-
12-
conda create --name codecarbon
13-
conda activate codecarbon
14-
156
From PyPi repository
167
--------------------
178

@@ -23,16 +14,20 @@ To install the package, run the following command in your terminal.
2314
2415
pip install codecarbon
2516
26-
From conda repository
27-
---------------------
28-
29-
The package is hosted on the conda repository `here <https://anaconda.org/codecarbon/codecarbon>`__.
17+
Using Conda environments
18+
------------------------
3019

31-
To install the package, run the following command in your terminal.
20+
If you're using Conda for environment management, you can install CodeCarbon with pip in your Conda environment:
3221

3322
.. code-block:: bash
3423
35-
conda install -c codecarbon -c conda-forge codecarbon
24+
conda create --name codecarbon
25+
conda activate codecarbon
26+
pip install codecarbon
27+
28+
.. note::
29+
30+
While CodeCarbon can be used in Conda environments, we no longer maintain Conda packages. We recommend using ``pip install codecarbon`` within your Conda environment, which works seamlessly with Conda.
3631

3732
.. note::
3833

0 commit comments

Comments
 (0)