Skip to content

Commit 7c5759c

Browse files
committed
Use uv instead of flit
Signed-off-by: Yu Ishikawa <[email protected]>
1 parent cd2d811 commit 7c5759c

File tree

11 files changed

+109
-133
lines changed

11 files changed

+109
-133
lines changed

.github/workflows/publish.yml

+8-26
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,19 @@ jobs:
1212
run:
1313
shell: bash
1414
steps:
15-
- name: Dump GitHub context
16-
env:
17-
GITHUB_CONTEXT: ${{ toJson(github) }}
18-
run: echo "$GITHUB_CONTEXT"
1915
- uses: actions/checkout@v4
2016
- name: Set up Python
2117
uses: actions/setup-python@v5
2218
with:
2319
python-version: "3.9"
24-
- uses: actions/cache@v4
25-
id: cache
26-
with:
27-
path: ${{ env.pythonLocation }}
28-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-publish
29-
- name: Install Flit
30-
if: steps.cache.outputs.cache-hit != 'true'
31-
run: bash dev/setup.sh
20+
- name: Install uv
21+
run: |
22+
pip install -r requirements.setup.txt
3223
- name: Publish
3324
env:
34-
# SEE https://packaging.python.org/en/latest/specifications/pypirc/?highlight=token#using-a-pypi-token
35-
FLIT_USERNAME: __token__
36-
FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
37-
run: bash dev/publish.sh "pypi"
38-
- name: Dump GitHub context
39-
env:
40-
GITHUB_CONTEXT: ${{ toJson(github) }}
41-
run: echo "$GITHUB_CONTEXT"
25+
UV_PUBLISH_TOKEN: "${{ secrets.PYPI_API_TOKEN }}"
26+
run: |
27+
bash dev/publish.sh "pypi"
4228
4329
test-published-package:
4430
needs:
@@ -48,18 +34,14 @@ jobs:
4834
run:
4935
shell: bash
5036
steps:
51-
- name: Dump GitHub context
52-
env:
53-
GITHUB_CONTEXT: ${{ toJson(github) }}
54-
run: echo "$GITHUB_CONTEXT"
5537
- uses: actions/checkout@v4
5638
- name: Set up Python
5739
uses: actions/setup-python@v5
5840
with:
5941
python-version: "3.9"
60-
- name: Install packages
42+
- name: Install package
6143
run: |
6244
python3 -m pip install -U dbt-artifacts-parser
63-
- name: Test pacakge
45+
- name: Test package
6446
run: |
6547
python -c 'import dbt_artifacts_parser; print(dbt_artifacts_parser.__version__)'

.github/workflows/test-publish.yml

+9-28
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,38 @@ on:
77
description: "dbt-artifacts-parser version"
88
required: true
99

10-
1110
jobs:
1211
publish:
1312
runs-on: ubuntu-latest
1413
defaults:
1514
run:
1615
shell: bash
1716
steps:
18-
- name: Dump GitHub context
19-
env:
20-
GITHUB_CONTEXT: ${{ toJson(github) }}
21-
run: echo "$GITHUB_CONTEXT"
2217
- uses: actions/checkout@v4
2318
- name: Set up Python
2419
uses: actions/setup-python@v5
2520
with:
2621
python-version: "3.9"
27-
- uses: actions/cache@v4
28-
id: cache
29-
with:
30-
path: ${{ env.pythonLocation }}
31-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-publish
32-
- name: Install Flit
33-
if: steps.cache.outputs.cache-hit != 'true'
34-
run: bash dev/setup.sh
22+
- name: Install uv
23+
run: |
24+
pip install -r requirements.setup.txt
3525
- name: Test publish
3626
env:
37-
# SEE https://packaging.python.org/en/latest/specifications/pypirc/?highlight=token#using-a-pypi-token
38-
FLIT_USERNAME: __token__
39-
FLIT_PASSWORD: ${{ secrets.TESTPYPI_API_TOKEN }}
40-
run: bash dev/publish.sh "testpypi"
41-
- name: Dump GitHub context
42-
env:
43-
GITHUB_CONTEXT: ${{ toJson(github) }}
44-
run: echo "$GITHUB_CONTEXT"
27+
UV_PUBLISH_TOKEN: "${{ secrets.TESTPYPI_API_TOKEN }}"
28+
run: |
29+
bash dev/publish.sh testpypi
4530
4631
test-published-package:
4732
needs:
4833
- publish
4934
runs-on: ubuntu-latest
35+
strategy:
36+
matrix:
37+
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
5038
defaults:
5139
run:
5240
shell: bash
53-
strategy:
54-
matrix:
55-
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
5641
steps:
57-
- name: Dump GitHub context
58-
env:
59-
GITHUB_CONTEXT: ${{ toJson(github) }}
60-
run: echo "$GITHUB_CONTEXT"
6142
- uses: actions/checkout@v4
6243
- name: Set up Python
6344
uses: actions/setup-python@v5

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ jobs:
3333
- uses: actions/cache@v4
3434
id: cache
3535
with:
36-
path: ${{ env.pythonLocation }}
37-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test
36+
path: "${{ env.pythonLocation }}"
37+
key: "${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test"
3838
- name: Install Flit
3939
if: steps.cache.outputs.cache-hit != 'true'
4040
run: bash dev/setup.sh

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ setup: setup-python setup-pre-commit
55
# Set up the python environment.
66
.PHONY: setup-python
77
setup-python:
8-
bash ./dev/setup.sh --deps "develop"
8+
bash ./dev/setup.sh --deps "development"
99

1010
# Set up the pre-commit hooks.
1111
.PHONY: setup-pre-commit
@@ -53,7 +53,7 @@ test:
5353
# Build the package
5454
.PHONY: build
5555
build: clean lint test
56-
flit build
56+
python -m build
5757

5858
# Clean the environment
5959
.PHONY: clean

dbt_artifacts_parser/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@
1717
"""
1818
A dbt artifacts parser in python
1919
"""
20-
__version__ = "0.8.0"

dev/publish.sh

+14-10
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,29 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
set -e
16+
set -Eo pipefail
1717
set -x
1818

19-
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
19+
SCRIPT_FILE="$(readlink -f "$0")"
20+
SCRIPT_DIR="$(dirname "$SCRIPT_FILE")"
2021
MODULE_DIR="$(dirname "$SCRIPT_DIR")"
2122

22-
cd "$MODULE_DIR"
23+
cd "$MODULE_DIR" || exit
2324

2425
# Arguments
2526
target=${1:?"target is not set"}
2627

27-
# SEE https://flit.readthedocs.io/en/latest/reproducible.html
28-
SOURCE_DATE_EPOCH=$(date +%s)
29-
export SOURCE_DATE_EPOCH
28+
# Ensure uv is installed
29+
pip install uv
3030

31-
if [[ "$target" == "pypi" ]] ; then
32-
flit publish --repository "${target}" --pypirc "${MODULE_DIR}/.pypirc" --setup-py
33-
elif [[ "$target" == "testpypi" ]] ; then
34-
flit publish --repository "${target}" --pypirc "${MODULE_DIR}/.pypirc" --setup-py
31+
# Build the package first
32+
uv build
33+
34+
# Publish to the specified target
35+
if [[ "$target" == "pypi" ]]; then
36+
uv publish
37+
elif [[ "$target" == "testpypi" ]]; then
38+
uv publish --publish-url "https://test.pypi.org/legacy/"
3539
else
3640
echo "No such target ${target}"
3741
exit 1

dev/setup.sh

+46-6
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,54 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
set -e
16+
set -Eeuo pipefail
1717

1818
# Constants
1919
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
20-
MODULE_DIR="$(dirname "$SCRIPT_DIR")"
20+
MODULE_DIR="$(dirname "${SCRIPT_DIR}")"
2121

22-
cd "$MODULE_DIR"
22+
# Arguments
23+
deps="production"
24+
use_venv=false
25+
while (($# > 0)); do
26+
if [[ "$1" == "--use-venv" ]]; then
27+
use_venv=true
28+
shift 1
29+
elif [[ "$1" == "--deps" ]]; then
30+
if [[ "$2" != "production" && "$2" != "development" ]]; then
31+
echo "Error: deps must be one of 'production' or 'development'"
32+
exit 1
33+
fi
34+
deps="$2"
35+
shift 2
36+
else
37+
echo "Unknown argument: $1"
38+
exit 1
39+
fi
40+
done
2341

24-
FLIT_VERSION="3.9.0"
25-
pip install -U flit=="$FLIT_VERSION"
26-
flit install --deps develop --symlink
42+
# Change to the module directory
43+
cd "${MODULE_DIR}"
44+
45+
# Install uv and dependencies
46+
pip install --force-reinstall -r "${MODULE_DIR}/requirements.setup.txt"
47+
48+
if [[ "${use_venv}" == true ]]; then
49+
# Create virtual environment
50+
uv venv
51+
# Activate virtual environment
52+
if [[ -f .venv/bin/activate ]]; then
53+
# shellcheck disable=SC1091
54+
source .venv/bin/activate
55+
else
56+
echo "Error: .venv/bin/activate not found"
57+
exit 1
58+
fi
59+
fi
60+
61+
# Install package and dependencies
62+
if [[ "${deps}" == "production" ]]; then
63+
uv pip install --force-reinstall -e "."
64+
else
65+
uv pip install --force-reinstall -e ".[dev,test]"
66+
fi

pyproject.toml

+27-21
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
11
[build-system]
2-
requires = ["flit_core >=3.2,<4"]
3-
build-backend = "flit_core.buildapi"
4-
5-
[tool.flit.module]
6-
name = "dbt_artifacts_parser"
7-
8-
[tool.flit.sdist]
9-
exclude = [
10-
".github/",
11-
".gitignore",
12-
".pre-commit-config.yaml",
13-
".style.yapf",
14-
".pylintrc",
15-
".pypirc",
16-
"Makefile",
17-
"dev/",
18-
"tests/",
19-
]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
204

215
[project]
226
name = "dbt-artifacts-parser"
237
authors = [{name = "yu-iskw"}]
248
readme = "README.md"
259
license = {file = "LICENSE"}
26-
requires-python = ">=3.7.0"
10+
requires-python = ">=3.8.0"
2711
classifiers = [
2812
"Development Status :: 4 - Beta",
2913
"Intended Audience :: Information Technology",
@@ -42,7 +26,8 @@ classifiers = [
4226
"Programming Language :: Python :: 3.12",
4327
"Typing :: Typed",
4428
]
45-
dynamic = ["version", "description"]
29+
version = "0.8.0"
30+
dynamic = ["description"]
4631
dependencies = [
4732
"pydantic >=2.0,<3.0",
4833
]
@@ -61,7 +46,7 @@ test = [
6146
"yapf >=0.29.0",
6247
]
6348
dev = [
64-
"flit ==3.9.0",
49+
"uv>=0.5,<0.6",
6550
"build ==1.2.2",
6651
"yapf >=0.29.0",
6752
"pyyaml >=5.3",
@@ -72,3 +57,24 @@ dev = [
7257

7358
[tool.isort]
7459
profile = "black"
60+
61+
[tool.hatch.build.targets.sdist]
62+
exclude = [
63+
".github/",
64+
".gitignore",
65+
".pre-commit-config.yaml",
66+
".style.yapf",
67+
".pylintrc",
68+
".pypirc",
69+
"Makefile",
70+
"dev/",
71+
"tests/",
72+
".DS_Store",
73+
".vscode/",
74+
".trunk/",
75+
".pytest_cache/",
76+
".mypy_cache/",
77+
"dist/",
78+
"test.json",
79+
"renovate.json"
80+
]

requirements.setup.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uv>=0.5,<0.6

setup.py

-17
This file was deleted.

tests/test_basic.py

-20
This file was deleted.

0 commit comments

Comments
 (0)