Skip to content

Commit 974a760

Browse files
committed
migrate from pip-compile to uv
1 parent 8f547ba commit 974a760

File tree

12 files changed

+4070
-310
lines changed

12 files changed

+4070
-310
lines changed

.github/workflows/code_coverage.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ jobs:
5555
- name: Install Dependencies (Python)
5656
run: |
5757
python3 -m pip install --upgrade pip
58+
# Pin setuptools to keep pkg_resources available (needed by ansible-risk-insight)
59+
pip install "setuptools<81"
5860
pip install -r requirements.txt
5961
pip install .[dev]
6062

.github/workflows/pip_audit.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- .github/workflows/pip_audit.yml
1111
- ansible_ai_connect/**
1212
- pyproject.toml
13+
- uv.lock
1314
- requirements.txt
1415
pull_request:
1516
branches:
@@ -18,6 +19,7 @@ on:
1819
- .github/workflows/pip_audit.yml
1920
- ansible_ai_connect/**
2021
- pyproject.toml
22+
- uv.lock
2123
- requirements.txt
2224
permissions:
2325
contents: read
@@ -35,7 +37,8 @@ jobs:
3537
run: |
3638
python -m venv env/
3739
source env/bin/activate
38-
python -m pip install . -r requirements.txt
40+
python -m pip install -r requirements.txt
41+
python -m pip install -e .
3942
# See: https://github.com/advisories/GHSA-r9hx-vwmv-q579
4043
pip install --upgrade setuptools
4144
- name: Create CA symlink to use RH's certifi on ubuntu-latest
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
name: wisdom-service - pip-compile
1+
name: wisdom-service - uv-export
22

33
on:
44
push:
55
branches:
66
- main
77
paths:
88
- ansible_ai_connect/**
9-
- requirements.in
9+
- pyproject.toml
10+
- uv.lock
1011
- requirements.txt
1112
- Makefile
1213
pull_request:
1314
branches:
1415
- main
1516
paths:
1617
- ansible_ai_connect/**
17-
- requirements.in
18+
- pyproject.toml
19+
- uv.lock
1820
- requirements.txt
1921
- Makefile
2022
permissions:
@@ -29,9 +31,10 @@ jobs:
2931
uses: actions/setup-python@v4
3032
with:
3133
python-version: 3.12
32-
- name: install
34+
- name: Install uv
35+
uses: astral-sh/setup-uv@v4
36+
- name: Compile requirements
3337
run: |
34-
pip install --upgrade "pip<24.1"
35-
pip install pip-tools
36-
pip-compile --quiet -o requirements.txt requirements.in
37-
git diff --exit-code -- requirements.txt
38+
uv lock --python 3.12
39+
uv export --format requirements-txt --no-hashes --no-emit-project -o requirements.txt
40+
git diff --exit-code -- uv.lock requirements.txt

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ update-openapi-schema:
9999
docker-compose-clean:
100100
${COMPOSE_RUNTIME} -f ${PWD}/tools/docker-compose/compose.yaml down
101101

102-
.PHONY: pip-compile
103-
pip-compile:
102+
.PHONY: export
103+
export:
104104
${CONTAINER_RUNTIME} run --arch amd64 --os linux \
105105
--volume $(PWD):/var/www/wisdom:Z \
106106
--workdir /var/www/wisdom \
107107
registry.access.redhat.com/ubi9/ubi:latest \
108-
/var/www/wisdom/tools/scripts/pip-compile.sh
108+
/var/www/wisdom/tools/scripts/uv-export.sh
109109

110110
# DEPRECATED: Please use create-superuser-containerized instead
111111
docker-create-superuser: create-superuser-containerized DEPRECATED

README.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,30 +194,44 @@ pre-commit autoupdate && pre-commit run -a
194194

195195
## Updating the Python dependencies
196196

197-
We are using pip-compile in order to manage our Python dependencies.
197+
We use [uv](https://github.com/astral-sh/uv) to manage Python dependencies,
198+
following the same approach as [ansible-chatbot-stack](https://github.com/ansible/ansible-chatbot-stack).
199+
All dependencies are defined in `pyproject.toml`.
198200

199-
The specification of what packages we need lives in the
200-
`requirements.in` file. Use your preferred editor to make the needed
201-
changes in that file, then run:
201+
To update the pinned dependencies, run:
202202

203203
```bash
204-
make pip-compile
204+
make export
205205
```
206206

207207
This will spin up a container and run the equivalent of:
208208

209209
```bash
210-
pip-compile requirements.in
210+
uv lock --python 3.12
211+
uv export --format requirements-txt --no-hashes -o requirements.txt
211212
```
212213

213-
This command will produce a fully populated and pinned `requirements.txt`
214-
file, containing all of the dependencies of our dependencies.
215-
Due to differences in architecture and version of Python between
216-
developers' machines, we do not recommend running pip-compile directly.
214+
This generates:
215+
- `uv.lock` - The lock file with exact pinned versions (commit this file)
216+
- `requirements.txt` - Exported for pip compatibility
217217

218-
### Use of `pyproject.toml`
218+
### Security constraints
219219

220-
`pyproject.toml` contains the dependencies used by downstream builds. Changes to any of the top level dependencies in `requirements.in` must there also be reflected in `pyproject.toml` too. See [PEP-518](https://peps.python.org/pep-0518/) for details.
220+
Security-pinned transitive dependencies are defined in the `[tool.uv]`
221+
section of `pyproject.toml` using `constraint-dependencies`. These constraints
222+
are automatically applied when running `uv lock`.
223+
224+
### Development dependencies
225+
226+
Development dependencies (testing, linting, etc.) are defined as optional
227+
dependencies in `pyproject.toml` under `[project.optional-dependencies]`.
228+
Install them with:
229+
230+
```bash
231+
pip install .[dev]
232+
# or with uv:
233+
uv pip install -e .[dev]
234+
```
221235

222236
# Using the VS Code extension
223237

ansible_ai_connect/main/templates/chatbot/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
content="{{bot_name}}"
1010
/>
1111
<title>{{bot_name}}</title>
12-
<script type="module" crossorigin src="/static/chatbot/index-ecUyj60O.js"></script>
13-
<link rel="stylesheet" crossorigin href="/static/chatbot/index-Dm-_Ojks.css">
12+
<script type="module" crossorigin src="/static/chatbot/index-YdyFlNn2.js"></script>
13+
<link rel="stylesheet" crossorigin href="/static/chatbot/index-DBhoCAvz.css">
1414
</head>
1515
<body>
1616
<noscript>You need to enable JavaScript to run this app.</noscript>

pyproject.toml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ description = "Ansible Lightspeed with IBM watsonx Code Assistant."
88
version = "0.1.0"
99
dependencies = [
1010
'aiohttp~=3.12.14',
11-
'ansible-core~=2.15.9',
11+
'ansible-core~=2.16.5',
1212
'ansible-anonymizer~=1.5.0',
13-
'ansible-risk-insight~=0.2.7',
14-
'ansible-lint~=24.2.2',
13+
'ansible-risk-insight==0.2.7',
14+
'ansible-lint~=25.5.0',
1515
'boto3~=1.40',
1616
'cython',
1717
'daphne~=4.1.2',
@@ -68,7 +68,6 @@ dev = [
6868
'flake8~=6.0.0',
6969
'grpcio-tools~=1.68.1',
7070
'isort~=5.10.1',
71-
'pip-tools',
7271
'pre-commit',
7372
'responses~=0.24.1',
7473
'torch-model-archiver',
@@ -85,6 +84,25 @@ wisdom-manage = "ansible_ai_connect.manage:main"
8584

8685
[tool]
8786

87+
[tool.uv]
88+
# Security-pinned transitive dependencies
89+
constraint-dependencies = [
90+
# Use Red Hat's system-certifi for certificate handling
91+
'certifi @ git+https://github.com/ansible/system-certifi@5aa52ab91f9d579bfe52b5acf30ca799f1a563d9',
92+
# Pin cryptography to address security vulnerabilities
93+
'cryptography==43.0.1',
94+
# Pin idna to address GHSA-jjg7-2v4v-x38h
95+
'idna==3.7',
96+
# Pin jsonpickle to address SNYK-PYTHON-JSONPICKLE-8136229
97+
'jsonpickle==3.3.0',
98+
# Pin pyjwt for compatibility
99+
'pyjwt==2.8.0',
100+
# Pin pyOpenSSL for compatibility
101+
'pyOpenSSL==24.2.1',
102+
# Pin sqlparse to address GHSA-2m57-hf25-phgg
103+
'sqlparse==0.5.2',
104+
]
105+
88106
[tool.setuptools.packages.find]
89107
include = ["ansible_ai_connect*"]
90108

requirements.in

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +0,0 @@
1-
# ======================================================================
2-
# If any top level dependency is added, updated or deleted be
3-
# sure to check pyproject.toml too. pyproject.toml is the *only*
4-
# dependencies file used by downstream and hence *must* be synchronized.
5-
# It is also recommended that dependencies in pyproject.toml use the '~=' version qualifier.
6-
#
7-
# See the following for details:
8-
# - https://peps.python.org/pep-0518
9-
# - https://peps.python.org/pep-0631
10-
# - https://peps.python.org/pep-0508
11-
# ======================================================================
12-
aiohttp==3.12.14
13-
ansible-anonymizer==1.5.0
14-
ansible-risk-insight==0.2.7
15-
ansible-lint==24.2.2
16-
boto3==1.40.63
17-
# pin black on 24.3.0 to address PYSEC-2024-48.
18-
black==24.3.0
19-
certifi@git+https://github.com/ansible/system-certifi@5aa52ab91f9d579bfe52b5acf30ca799f1a563d9
20-
cryptography==43.0.1
21-
daphne==4.1.2
22-
Django==4.2.27
23-
django-deprecate-fields==0.1.1
24-
django-extensions==3.2.1
25-
django-health-check==3.17.0
26-
django-import-export==3.2.0
27-
django-oauth-toolkit==3.0.1
28-
django_prometheus==2.2.0
29-
django-test-migrations==1.3.0
30-
djangorestframework==3.15.2
31-
drf-spectacular==0.27.2
32-
fire==0.7.0
33-
# pin idna on 3.7 to address GHSA-jjg7-2v4v-x38h
34-
# remove this once requests and yarl is updated to properly
35-
# pull a version of idna >= 3.7.
36-
idna==3.7
37-
ipython==8.10.0
38-
# pin jwcrypto on 1.5.6 to address GHSA-j857-7rvv-vj97
39-
# remove this once django-oauth-toolkit is updated to properly
40-
# pull a version of jwcrypto >= 1.5.6.
41-
jwcrypto==1.5.6
42-
# pin jinja2 on 3.1.6 to address GHSA-cpwx-vrp4-4pq7
43-
# remove this once ansible-core or torch are updated
44-
jinja2==3.1.6
45-
# pin jsonpickle on 3.3.0 to address SNYK-PYTHON-JSONPICKLE-8136229
46-
# remove this once ansible-risk-insight is updated
47-
jsonpickle==3.3.0
48-
langchain==0.3.26
49-
langchain-core==0.3.80
50-
langchain-ollama==0.3.5
51-
# CVE-2025-6985: XXE Vulnerability fixed in 0.3.9+
52-
langchain-text-splitters==0.3.11
53-
launchdarkly-server-sdk==8.3.0
54-
llama-stack-client>=0.2.12
55-
protobuf==5.29.5
56-
psycopg[binary]==3.2.3
57-
pydantic==2.9.2
58-
PyDrive2==1.20.0
59-
pytz
60-
pyjwt==2.8.0
61-
pyOpenSSL==24.2.1
62-
PyYAML==6.0.2
63-
requests==2.32.3
64-
segment-analytics-python==2.2.2
65-
# pin sqlparse on 0.5.0 to address GHSA-2m57-hf25-phgg
66-
# Remove once a Django>4.2.11 is released with an updated dep on sqlparse
67-
sqlparse==0.5.2
68-
social-auth-app-django==5.4.1
69-
social-auth-core==4.5.4
70-
slack-sdk==3.31.0
71-
urllib3==2.6.0
72-
uwsgi==2.0.28
73-
uwsgi-readiness-check==0.2.0
74-
django-allow-cidr==0.6.0
75-
django-csp==3.7
76-
django-ansible-base[jwt-consumer,resource-registry]==2025.8.18

0 commit comments

Comments
 (0)