Skip to content

Commit b550c0d

Browse files
committed
feat: replace setuptools with uv
Replace setuptools with uv to streamline dependency management. This also allows for environment-specific requirements, which Aider needs for several use cases.
1 parent 77976a5 commit b550c0d

18 files changed

Lines changed: 3913 additions & 1803 deletions

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Install dependencies
2424
run: |
2525
python -m pip install --upgrade pip
26-
pip install build setuptools wheel twine importlib-metadata==7.2.1
26+
pip install build uv wheel twine
2727
2828
- name: Build and publish
2929
env:

.python-version

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

CONTRIBUTING.md

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ All contributors will be asked to complete the agreement as part of the PR proce
3939

4040
## Setting up a Development Environment
4141

42+
### Prerequisites
43+
44+
You’ll need the `uv` tool for some development tasks.
45+
Refer to
46+
[uv’s documentation](https://docs.astral.sh/uv/getting-started/installation/)
47+
for installation instructions, or use your favorite package manager to
48+
install uv.
49+
4250
### Clone the Repository
4351

4452
```
@@ -48,14 +56,20 @@ cd aider
4856

4957
### Create a Virtual Environment
5058

51-
It is recommended to create a virtual environment outside of the repository to keep your development environment isolated.
59+
It is recommended to create a virtual environment outside of the repository to keep your development environment isolated. To create one, use `venv` or `uv`.
5260

5361
#### Using `venv` (Python 3.9 and later)
5462

5563
```
5664
python -m venv /path/to/venv
5765
```
5866

67+
### Using `uv`
68+
69+
```
70+
uv venv /path/to/venv
71+
```
72+
5973
### Activate the Virtual Environment
6074

6175
#### On Windows
@@ -75,25 +89,22 @@ source /path/to/venv/bin/activate
7589
This step allows you to make changes to the source code and have them take effect immediately without reinstalling the package.
7690

7791
```
78-
pip install -e .
92+
uv sync
7993
```
8094

81-
### Install the Project Dependencies
95+
(This includes base, development, and test dependencies.)
8296

83-
```
84-
pip install -r requirements.txt
85-
```
97+
### Install Optional Dependencies
8698

87-
For development, at least install the development dependencies:
99+
Consider installing other optional dependencies from the `requirements/` directory, if your development work needs them:
88100

89101
```
90-
pip install -r requirements/requirements-dev.txt
102+
uv sync --all-extras
103+
uv sync --extra help
104+
uv sync --extra browser
105+
uv sync --extra playwright
91106
```
92107

93-
Consider installing other optional dependencies from the `requirements/` directory, if your development work needs them.
94-
95-
Note that these dependency files are generated by `./scripts/pip-compile.sh` and then committed. See [Managing Dependencies](#managing-dependencies).
96-
97108
### Install Pre-commit Hooks (Optional)
98109

99110
The project uses pre-commit hooks for code formatting and linting. If you want to install and use these hooks, run:
@@ -111,11 +122,9 @@ Now you should have a fully functional development environment for the Aider pro
111122
Here's an example of following the setup instructions above, for your copy/paste pleasure if your system works the same. Start in the project directory.
112123

113124
```
114-
python3 -m venv ../aider_venv \
125+
uv venv ../aider_venv \
115126
&& source ../aider_venv/bin/activate \
116-
&& pip3 install -e . \
117-
&& pip3 install -r requirements.txt \
118-
&& pip3 install -r requirements/requirements-dev.txt
127+
&& uv sync
119128
```
120129

121130
### Running Tests
@@ -205,26 +214,7 @@ If you need to mock or create test data, consider adding it to the test files or
205214

206215
#### Test Requirements
207216

208-
The project uses `pytest` as the testing framework, which is installed as a development dependency. To install the development dependencies, run the following command:
209-
210-
```
211-
pip install -r requirements-dev.txt
212-
```
213-
214-
### Managing Dependencies
215-
216-
When introducing new dependencies, make sure to add them to the appropriate `requirements.in` file (e.g., `requirements.in` for main dependencies, `requirements-dev.in` for development dependencies). Then, run the following commands to update the corresponding `requirements.txt` file:
217-
218-
```
219-
pip install pip-tools
220-
./scripts/pip-compile.sh
221-
```
222-
223-
You can also pass one argument to `pip-compile.sh`, which will flow through to `pip-compile`. For example:
224-
225-
```
226-
./scripts/pip-compile.sh --upgrade
227-
```
217+
The project uses `pytest` as the testing framework, which is installed as a development dependency by the `uv sync` command.
228218

229219
### Pre-commit Hooks
230220

pyproject.toml

Lines changed: 104 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
21
[project]
32
name = "aider-chat"
43
description = "Aider is AI pair programming in your terminal"
4+
license = { text = "Apache-2.0" }
55
readme = "README.md"
66
classifiers = [
77
"Development Status :: 4 - Beta",
@@ -17,36 +17,119 @@ classifiers = [
1717
"Topic :: Software Development",
1818
]
1919
requires-python = ">=3.9,<3.13"
20-
dynamic = ["dependencies", "optional-dependencies", "version"]
20+
dynamic = ["version"]
21+
dependencies = [
22+
"backoff",
23+
"beautifulsoup4",
24+
"configargparse",
25+
"diff-match-patch",
26+
"diskcache",
27+
"flake8",
28+
"GitPython",
29+
"grep_ast",
30+
"importlib_resources",
31+
"json5",
32+
"jsonschema",
33+
"litellm",
34+
"mixpanel",
35+
"packaging",
36+
"pathspec",
37+
"pexpect",
38+
"pillow",
39+
"pip",
40+
"posthog",
41+
"prompt_toolkit",
42+
"psutil",
43+
"pydub",
44+
"pypandoc",
45+
"pyperclip",
46+
"PyYAML",
47+
"rich",
48+
"socksio",
49+
"sounddevice",
50+
"soundfile",
2151

22-
[project.urls]
23-
Homepage = "https://github.com/Aider-AI/aider"
52+
"tree-sitter (==0.23.2); python_version < '3.10'",
53+
"tree-sitter (>=0.24.0); python_version >= '3.10'",
2454

25-
[project.scripts]
26-
aider = "aider.main:main"
55+
"watchfiles",
2756

28-
[tool.setuptools.dynamic]
29-
dependencies = { file = "requirements.txt" }
57+
# The proper dependency is networkx[default], but this brings
58+
# in matplotlib and a bunch of other deps
59+
# https://github.com/networkx/networkx/blob/d7132daa8588f653eacac7a5bae1ee85a183fa43/pyproject.toml#L57
60+
# We really only need networkx itself and scipy for the repomap.
61+
# Pin below v3.3 to retain python 3.9 compatibility.
62+
"networkx (<3.3)",
3063

31-
[tool.setuptools.dynamic.optional-dependencies]
32-
dev = { file = "requirements/requirements-dev.txt" }
33-
help = { file = "requirements/requirements-help.txt" }
34-
browser = { file = "requirements/requirements-browser.txt" }
35-
playwright = { file = "requirements/requirements-playwright.txt" }
64+
# This is the one networkx dependency that we need.
65+
# Including it here explicitly because we
66+
# didn't specify networkx[default] above.
67+
# Pin below 1.14 to retain python 3.9 compatibility.
68+
"scipy (<1.14)",
3669

37-
[tool.setuptools]
38-
include-package-data = true
70+
# GitHub Release action failing on "KeyError: 'home-page'"
71+
# https://github.com/pypa/twine/blob/6fbf880ee60915cf1666348c4bdd78a10415f2ac/twine/__init__.py#L40
72+
# Uses importlib-metadata
73+
"importlib-metadata (<8.0.0)",
74+
]
3975

40-
[tool.setuptools.packages.find]
41-
include = ["aider"]
76+
[project.optional-dependencies]
77+
help = [
78+
"llama-index-core",
79+
"llama-index-embeddings-huggingface",
80+
81+
# Because sentence-transformers doesn't like >=2
82+
"numpy (<2)",
83+
84+
# Mac x86 only supports 2.2.2
85+
# https://discuss.pytorch.org/t/why-no-macosx-x86-64-build-after-torch-2-2-2-cp39-none-macosx-10-9-x86-64-whl/204546/2
86+
"torch (==2.2.2)",
87+
]
88+
browser = ["streamlit"]
89+
playwright = ["playwright"]
90+
91+
[project.urls]
92+
Homepage = "https://github.com/Aider-AI/aider"
93+
94+
[project.scripts]
95+
aider = "aider.main:main"
4296

4397
[build-system]
44-
requires = ["setuptools>=68", "setuptools_scm[toml]>=8"]
45-
build-backend = "setuptools.build_meta"
98+
requires = ["hatchling", "uv-dynamic-versioning"]
99+
build-backend = "hatchling.build"
46100

47-
[tool.setuptools_scm]
48-
write_to = "aider/_version.py"
101+
[dependency-groups]
102+
dev = [
103+
"codespell",
104+
"cogapp",
105+
"imgcat",
106+
"lox",
107+
"matplotlib",
108+
"pandas",
109+
"pre",
110+
"semver",
111+
"typer",
112+
]
113+
test = [
114+
"pytest",
115+
"pytest-env",
116+
]
49117

50118
[tool.codespell]
51119
skip = "*.svg,Gemfile.lock"
52120
write-changes = true
121+
122+
[tool.hatch.build.hooks.version]
123+
path = "aider/_version.py"
124+
template = '''
125+
version = "{version}"
126+
'''
127+
128+
[tool.hatch.build.targets.wheel]
129+
packages = ["aider"]
130+
131+
[tool.hatch.version]
132+
source = "uv-dynamic-versioning"
133+
134+
[tool.uv]
135+
default-groups = ["dev", "test"]

0 commit comments

Comments
 (0)