Skip to content

Commit f6ed75e

Browse files
authored
migrate to uv (#494)
* migrate to uv * fix tests
1 parent 95d642e commit f6ed75e

File tree

17 files changed

+1155
-258
lines changed

17 files changed

+1155
-258
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "pip"
3+
- package-ecosystem: "uv"
44
directory: "/"
55
schedule:
66
interval: "monthly"
77
groups:
8-
pip:
8+
uv:
99
patterns: ["*"]
1010
- package-ecosystem: "github-actions"
1111
directory: "/"

.github/workflows/bump-version.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@ name: Bump Version
33
on:
44
workflow_dispatch:
55

6+
permissions:
7+
contents: read
8+
69
jobs:
710
bump-version:
811
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
914
steps:
1015
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1116
with:
1217
ref: master
18+
- uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0
19+
with:
20+
activate-environment: true
1321

1422
- name: Bump version
1523
run: |
16-
version_file="cloudsplaining/bin/version.py"
17-
1824
# https://github.com/bridgecrewio/checkov/blob/master/.github/workflows/build.yml#L87-L132
1925
git config --local user.email "action@github.com"
2026
git config --local user.name "GitHub Action"
@@ -25,6 +31,7 @@ jobs:
2531
new_tag=$(echo "$latest_tag" | awk -F. -v a="$1" -v b="$2" -v c="$3" '{printf("%d.%d.%d", $1+a, $2+b , $3+1)}')
2632
echo "new tag: $new_tag"
2733
28-
printf "# pylint: disable=missing-module-docstring\n__version__ = \"%s\"\n""" "$new_tag" > $version_file
29-
git commit -m "Bump to ${new_tag}" $version_file || echo "No changes to commit"
34+
uv version --offline "$new_tag"
35+
36+
git commit -m "Bump to ${new_tag}" pyproject.toml uv.lock || echo "No changes to commit"
3037
git push origin

.github/workflows/publish.yml

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,35 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
18-
19-
- name: Setup Python
20-
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
18+
- uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0
2119
with:
22-
python-version-file: '.python-version'
23-
24-
- name: Install dependencies
25-
run: |
26-
make setup-dev
20+
activate-environment: true
21+
- run: uv sync --frozen
2722

2823
- name: Install the package to make sure nothing is randomly broken
29-
run: |
30-
make install
31-
24+
run: make build
3225
- name: Run pytest (unit tests)
33-
run: |
34-
make test
26+
run: make test
3527

3628

3729
publish-package:
3830
needs: test
3931
runs-on: ubuntu-latest
4032
steps:
4133
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
42-
- name: Set up Python
43-
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
34+
- uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0
4435
with:
45-
python-version-file: '.python-version'
36+
activate-environment: true
37+
- run: uv sync --frozen
4638

47-
- name: Install dependencies
48-
run: |
49-
pip install -r requirements.txt
50-
pip install -r requirements-dev.txt
5139
- name: create python package
5240
run: |
5341
git config --local user.email "action@github.com"
5442
git config --local user.name "GitHub Action"
5543
git fetch --tags
5644
git pull origin master
57-
pip install setuptools wheel twine
58-
python -m setup sdist bdist_wheel
45+
46+
uv build
5947
- name: Publish package
6048
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
6149
with:
@@ -68,8 +56,7 @@ jobs:
6856
contents: write
6957
steps:
7058
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
71-
- name: Set up Python
72-
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
59+
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
7360
with:
7461
python-version-file: '.python-version'
7562
- name: publish brew
@@ -98,11 +85,12 @@ jobs:
9885
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
9986
with:
10087
ref: master
88+
- uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0
89+
with:
90+
activate-environment: true
10191

10292
- name: Bump version
10393
run: |
104-
version_file="cloudsplaining/bin/version.py"
105-
10694
# https://github.com/bridgecrewio/checkov/blob/master/.github/workflows/build.yml#L87-L132
10795
git config --local user.email "action@github.com"
10896
git config --local user.name "GitHub Action"
@@ -113,6 +101,7 @@ jobs:
113101
new_tag=$(echo "$latest_tag" | awk -F. -v a="$1" -v b="$2" -v c="$3" '{printf("%d.%d.%d", $1+a, $2+b , $3+1)}')
114102
echo "new tag: $new_tag"
115103
116-
printf "# pylint: disable=missing-module-docstring\n__version__ = \"%s\"\n""" "$new_tag" > $version_file
117-
git commit -m "Bump to ${new_tag}" $version_file || echo "No changes to commit"
104+
uv version --offline "$new_tag"
105+
106+
git commit -m "Bump to ${new_tag}" pyproject.toml uv.lock || echo "No changes to commit"
118107
git push origin

.github/workflows/test.yml

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,17 @@ jobs:
3232
timeout-minutes: 15
3333
steps:
3434
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
35-
36-
- name: Setup Python
37-
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
35+
- uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0
3836
with:
39-
python-version-file: '.python-version'
40-
41-
- name: Install dependencies
42-
run: |
43-
make setup-dev
37+
activate-environment: true
38+
- run: uv sync --frozen
4439

4540
- name: Install the package to make sure nothing is randomly broken
46-
run: |
47-
make install
48-
41+
run: make build
4942
- name: Run pytest (unit tests)
50-
run: |
51-
make test
52-
43+
run: make test
5344
- name: Run mypy (static type check)
54-
run: |
55-
make type-check
45+
run: make type-check
5646

5747
python-version:
5848
needs: prek
@@ -65,19 +55,13 @@ jobs:
6555
python: ['3.11', '3.12', '3.13', '3.14']
6656
steps:
6757
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
68-
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
58+
- uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0
6959
with:
7060
python-version: ${{ matrix.python }}
71-
allow-prereleases: true
72-
73-
- name: Install dependencies
74-
run: |
75-
make setup-dev
61+
activate-environment: true
62+
- run: uv sync --frozen
7663

7764
- name: Install the package to make sure nothing is randomly broken
78-
run: |
79-
make install
80-
65+
run: make build
8166
- name: Run pytest (unit tests)
82-
run: |
83-
make test
67+
run: make test

.github/workflows/update-bundle-report.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,15 @@ on:
99
permissions:
1010
contents: read
1111

12-
env:
13-
MIN_PYTHON_VERSION: "3.10"
14-
1512
jobs:
1613
update:
1714
runs-on: ubuntu-latest
1815
steps:
1916
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
20-
21-
- name: Setup python
22-
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
17+
- uses: astral-sh/setup-uv@3259c6206f993105e3a61b142c2d97bf4b9ef83d # v7.1.0
2318
with:
24-
python-version-file: '.python-version'
25-
26-
- name: Install dependencies
27-
run: |
28-
pip install -r requirements.txt
29-
pip install -r requirements-dev.txt
19+
activate-environment: true
20+
- run: uv sync --frozen
3021

3122
- name: Update the JavaScript bundle
3223
run: |

.pyup.yml

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

MANIFEST.in

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

Makefile

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,30 @@
11
SHELL:=/bin/bash
22

33
PROJECT := cloudsplaining
4-
PROJECT_UNDERSCORE := cloudsplaining
54

6-
virtualenv:
7-
python3 -m venv ./venv && source venv/bin/activate
8-
9-
setup-env: virtualenv
10-
python3 -m pip install -r requirements.txt
11-
12-
setup-dev: setup-env
13-
python3 -m pip install -r requirements-dev.txt
5+
setup-env:
6+
uv sync --frozen
147

158
# Create the documentation files and open them locally
16-
build-docs: clean virtualenv
9+
build-docs: clean
1710
mkdocs build
1811

1912
# Serve the docs locally as you edit them
20-
serve-docs: clean virtualenv
13+
serve-docs: clean
2114
mkdocs serve --dev-addr "127.0.0.1:8001"
2215

2316
# Build the cloudsplaining package from the current directory contents for use with PyPi
2417
build: setup-env clean
25-
python3 -m pip install --upgrade setuptools wheel
26-
python3 -m setup -q sdist bdist_wheel
18+
uv build
2719

2820
# Install the package locally
2921
install: build
30-
python3 -m pip install -q ./dist/${PROJECT}*.tar.gz
22+
uv pip install -q ./dist/${PROJECT}*.tar.gz
3123
${PROJECT} --help
3224

3325
# Uninstall the package
34-
uninstall: virtualenv
35-
python3 -m pip uninstall ${PROJECT} -y
36-
python3 -m pip uninstall -r requirements.txt -y
37-
python3 -m pip uninstall -r requirements-dev.txt -y
38-
python3 -m pip freeze | xargs python3 -m pip uninstall -y
26+
uninstall:
27+
uv pip uninstall ${PROJECT} -y
3928

4029
# Clean the directory of extra python files
4130
clean:
@@ -49,18 +38,17 @@ clean:
4938
find . -name '*.pyo' -exec rm --force {} +
5039

5140
# Run unit tests
52-
test: setup-dev
53-
python3 -m coverage run -m pytest -v
54-
python3 -m coverage report -m
41+
test: setup-env
42+
coverage run -m pytest -v
43+
coverage report -m
5544

56-
type-check: setup-dev
45+
type-check: setup-env
5746
mypy
5847

5948
# Publish to PyPi
6049
publish: build
61-
python3 -m pip install --upgrade twine
62-
python3 -m twine upload dist/*
63-
python3 -m pip install ${PROJECT}
50+
uv publish
51+
uv pip install ${PROJECT}
6452

6553
# count lines of code
6654
count-loc:
@@ -70,8 +58,8 @@ count-loc:
7058

7159
# Generate the example report
7260
generate-report:
73-
python3 ./utils/generate_example_iam_data.py
74-
python3 ./utils/generate_example_report.py
61+
python ./utils/generate_example_iam_data.py
62+
python ./utils/generate_example_report.py
7563
# ---------------------------------------------------------------------------------------------------------------------
7664
# JavaScript
7765
# ---------------------------------------------------------------------------------------------------------------------
@@ -89,7 +77,7 @@ install-js-production: clean-js
8977

9078
# Generate the updated Javascript bundle
9179
build-js: setup-env install-js-production
92-
python3 ./utils/generate_example_iam_data.py
80+
python ./utils/generate_example_iam_data.py
9381
npm run build
9482

9583
# Run Javascript unit tests
@@ -104,8 +92,8 @@ serve-js: install-js-production
10492

10593
# Update Homebrew file. Does not commit to Git
10694
update-homebrew-file: uninstall
107-
python3 -m pip install homebrew-pypi-poet
108-
python3 -m pip install cloudsplaining -U
95+
uv pip install homebrew-pypi-poet
96+
uv pip install cloudsplaining -U
10997
git fetch origin
11098
latest_tag := $(git describe --tags `git rev-list --tags --max-count=1`)
11199
echo "latest tag: $latest_tag"

cloudsplaining/bin/version.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
# pylint: disable=missing-module-docstring
2-
__version__ = "0.8.3"
1+
import importlib.metadata
2+
3+
try:
4+
__version__ = importlib.metadata.version("cloudsplaining")
5+
except Exception:
6+
# needed for local dev
7+
__version__ = "0.0.0"

docs/contributing/documentation.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ get set up with Mkdocs, our documentation tool. First you will want to
77
make sure you have a few things on your local system:
88

99
- python-dev (if you're on OS X, you already have this)
10-
- pip
10+
- [uv](https://docs.astral.sh/uv/getting-started/installation/)
1111

1212
Once you've got all that, the rest is simple:
1313

@@ -17,8 +17,7 @@ git clone git@github.com:salesforce/cloudsplaining.git
1717

1818
# Set up the virtual environment
1919
python3 -m venv ./venv && source venv/bin/activate
20-
pip3 install -r requirements.txt
21-
pip3 install -r requirements-dev.txt
20+
uv sync --frozen
2221

2322
# Create the HTML files
2423
make build-docs

0 commit comments

Comments
 (0)