Skip to content

Commit 999acd5

Browse files
qgallouedeclewtun
andauthored
🕺 Migrate setup configuration from setup.py to setup.cfg and make rich an optional dep (#3403)
Co-authored-by: lewtun <[email protected]>
1 parent 8606b1a commit 999acd5

17 files changed

+352
-149
lines changed

CONTRIBUTING.md

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,3 +456,193 @@ Warnings play a critical role in guiding users toward resolving potential issues
456456
```
457457
458458
By following this classification, you ensure that warnings, information, and exceptions are used appropriately, providing clear guidance to the user without cluttering the system with unnecessary messages.
459+
460+
461+
## Making a release
462+
463+
> [!NOTE]
464+
> VERSION needs to be formatted following the `v{major}.{minor}.{patch}` convention. We need to follow this convention to be able to retrieve versioned scripts.
465+
466+
To create the package for PyPI.
467+
468+
#### 0. Prerequisites
469+
470+
- Dependencies:
471+
- twine: `pip install build twine`
472+
- Create an account in (and join the `trl` project):
473+
- PyPI: https://pypi.org/
474+
- Test PyPI: https://test.pypi.org/
475+
476+
#### 1. Ensure your local repository is up to date with the upstream repository
477+
478+
```bash
479+
git checkout main
480+
git pull origin main
481+
```
482+
483+
> [!WARNING]
484+
> Do not merge other pull requests into `main` until the release is done. This is to ensure that the release is stable and does not include any untested changes. Announce internally (#trl-internal) to other maintainers that you are doing a release and that they must not merge PRs until the release is done.
485+
486+
#### 2. Create a release branch from main
487+
488+
```bash
489+
git checkout -b release-v{major}.{minor}
490+
```
491+
492+
#### 3. Change the version in the following files
493+
494+
- `.github/workflows/tests_latest.yml`:
495+
```diff
496+
- with: { ref: v{major}.{minor-1}-release }
497+
+ with: { ref: v{major}.{minor}-release }
498+
```
499+
- `CITATION.cff`
500+
```diff
501+
- version: {major}.{minor-1}
502+
+ version: {major}.{minor}
503+
```
504+
- `__init__.py`
505+
```diff
506+
- __version__ = "{major}.{minor}.0.dev0"
507+
+ __version__ = "{major}.{minor}.0"
508+
```
509+
- `setup.cfg`
510+
```diff
511+
- version = {major}.{minor}.0.dev0
512+
+ version = {major}.{minor}.0
513+
```
514+
515+
#### 4. Commit and push these changes
516+
517+
```shell
518+
git commit -m 'Release: {major}.{minor}'
519+
git push origin release-v{major}.{minor}
520+
```
521+
522+
#### 5. Create a pull request
523+
524+
from `release-v{major}.{minor}` to `main`, named `Release: v{major}.{minor}`, wait for tests to pass, and request a review.
525+
526+
#### 6. Once the pull request is approved, merge it into `main`
527+
528+
#### 7. Add a tag in git to mark the release
529+
530+
```shell
531+
git checkout main
532+
git pull origin main
533+
git tag -a v{major}.{minor}.0 -m 'Adds tag v{major}.{minor}.0 for PyPI'
534+
git push origin v{major}.{minor}.0
535+
```
536+
537+
#### 8. Create a branch `v{major}.{minor}-release` for future patch releases.
538+
539+
```shell
540+
git checkout -b v{major}.{minor}-release
541+
git push origin v{major}.{minor}-release
542+
```
543+
544+
This ensures that future patch releases (`v{major}.{minor}.1`, `v{major}.{minor}.2`, etc.) can be made separately from `main`.
545+
546+
#### 9. Create the wheels for your release
547+
548+
These are the artifacts that will be uploaded to PyPI and installed by users via `pip install trl`.
549+
550+
Clean previous builds:
551+
552+
```shell
553+
rm -rf build dist
554+
```
555+
556+
At the root of your repo, run
557+
558+
```bash
559+
python -m build .
560+
```
561+
562+
This will create a folders named `dist` with the new versions of your package.
563+
564+
#### 10. Upload the package to PyPI Test
565+
566+
> [!IMPORTANT]
567+
> Do not skip this step. It is important to test the package before uploading it to the main PyPI server.
568+
569+
```shell
570+
twine upload dist/* -r testpypi
571+
```
572+
573+
Then in a fresh environment containing all dependencies you need, try to install your new package from the PyPI test server.
574+
575+
```bash
576+
pip install -i https://test.pypi.org/simple/ trl
577+
```
578+
579+
You might get errors for missing dependencies since the PyPI test server does not contain all packages like PyPI does. To make sure you have everything you can do:
580+
581+
```bash
582+
pip install trl
583+
pip uninstall trl
584+
```
585+
586+
(the second line will remove trl but keep all its dependencies).
587+
588+
Also make sure you can actually use the package! Run the following line:
589+
590+
```bash
591+
python -c "from trl import *"
592+
```
593+
594+
along with anything that tests:
595+
596+
- the core feature of your package
597+
- the new features you’re adding in the release
598+
599+
#### 11. Publish on PyPI
600+
601+
> [!WARNING]
602+
> This can't be reverted. Make sure you have tested everything before doing this step.
603+
604+
```shell
605+
twine upload dist/*
606+
```
607+
608+
#### 12. Create a GitHub Release
609+
610+
1. Go to the repo’s [releases section](https://github.com/huggingface/trl/releases) on GitHub.
611+
2. Click **Draft a new release**.
612+
3. Select the `v{major}.{minor}.0` tag you just created in step 7.
613+
4. Add a title (`v{major}.{minor}.0`) and a short description of what’s new.
614+
5. Click **Publish Release**.
615+
616+
#### 13. Bump to dev version
617+
618+
1. Create a branch `bump-dev-version-{major}.{minor+1}` from `main` and checkout to it.
619+
620+
```shell
621+
git checkout -b bump-dev-version-{major}.{minor+1}
622+
```
623+
624+
2. Change the version in the following files:
625+
1. `__init__.py`
626+
```diff
627+
- __version__ = "{major}.{minor}.0"
628+
+ __version__ = "{major}.{minor+1}.0.dev0"
629+
```
630+
2. `setup.cfg`
631+
```diff
632+
- version = {major}.{minor}.0
633+
+ version = {major}.{minor+1}.0.dev0
634+
```
635+
636+
3. Commit and push these changes
637+
638+
```shell
639+
git add trl/__init__.py setup.cfg
640+
git commit -m '⬆️ Bump dev version'
641+
git push origin bump-dev-version-{major}.{minor+1}
642+
```
643+
644+
4. Create a pull request from `bump-dev-version-{major}.{minor+1}` to `main`, named `⬆️ Bump dev version`, and request urgent review.
645+
646+
5. Once the pull request is approved, merge it into `main`.
647+
648+
6. The codebase is now ready for the next development cycle, inform the team in the #trl-internal channel.

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
include settings.ini
21
include LICENSE
32
include CONTRIBUTING.md
43
include README.md

setup.cfg

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,94 @@
11
[metadata]
2-
license_file = LICENSE
2+
name = trl
3+
version = 0.18.0.dev0
4+
description = Train transformer language models with reinforcement learning.
5+
long_description = file: README.md
6+
long_description_content_type = text/markdown
7+
author = Leandro von Werra
8+
author_email = [email protected]
9+
url = https://github.com/huggingface/trl
10+
keywords = transformers, huggingface, language modeling, post-training, rlhf, sft, dpo, grpo
11+
license_file = LICENSE
12+
classifiers =
13+
Development Status :: 2 - Pre-Alpha
14+
Intended Audience :: Developers
15+
Intended Audience :: Science/Research
16+
Natural Language :: English
17+
Operating System :: OS Independent
18+
Programming Language :: Python :: 3
19+
Programming Language :: Python :: 3.9
20+
Programming Language :: Python :: 3.10
21+
Programming Language :: Python :: 3.11
22+
Programming Language :: Python :: 3.12
23+
24+
[options]
25+
packages = find:
26+
python_requires = >=3.9
27+
include_package_data = True
28+
install_requires =
29+
accelerate>=0.34.0
30+
datasets>=3.0.0
31+
transformers>=4.46.0
32+
33+
[options.packages.find]
34+
exclude =
35+
tests*
36+
37+
[options.package_data]
38+
trl = templates/*.md
39+
40+
[options.extras_require]
41+
bco =
42+
scikit-learn
43+
joblib
44+
deepspeed =
45+
deepspeed>=0.14.4
46+
diffusers =
47+
diffusers>=0.18.0,<0.33.0
48+
judges =
49+
openai>=1.23.2
50+
llm-blender>=0.0.2
51+
liger =
52+
liger-kernel>=0.5.8
53+
mergekit =
54+
mergekit>=0.0.5.1
55+
peft =
56+
peft>=0.8.0
57+
quantization =
58+
bitsandbytes
59+
scikit =
60+
scikit-learn
61+
test =
62+
parameterized
63+
pytest-cov
64+
pytest-rerunfailures
65+
pytest-xdist
66+
pytest
67+
vllm =
68+
vllm>=0.8.3
69+
fastapi
70+
pydantic
71+
requests
72+
uvicorn
73+
vlm =
74+
Pillow
75+
dev =
76+
%(bco)s
77+
%(deepspeed)s
78+
%(diffusers)s
79+
%(judges)s
80+
%(liger)s
81+
%(mergekit)s
82+
%(peft)s
83+
%(quantization)s
84+
%(scikit)s
85+
%(test)s
86+
%(vllm)s
87+
%(vlm)s
88+
89+
[options.entry_points]
90+
console_scripts =
91+
trl = trl.cli:main
92+
93+
[coverage:run]
94+
branch = True

0 commit comments

Comments
 (0)