Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to uv/pyproject.toml #276

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ jobs:
with:
python-version: "3.8.x"

- name: Requirements
run: make requirements
- name: Install uv
run: pipx install uv

- name: Dependencies
run: make dependencies

- name: Build
run: make build
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,24 @@ on:
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.8.18"
python-version: "3.8"

- name: Requirements
run: make requirements
- name: Install uv
run: pipx install uv

- name: Dependencies
run: make dependencies

- name: Build
run: make build

- name: Publish a Python distribution to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
15 changes: 8 additions & 7 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ jobs:
with:
python-version: "3.8"

- uses: actions/cache@v2
- name: Install uv
run: pipx install uv

- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/uv.lock') }}

- name: Requirements
run: make requirements
- name: Dependencies
run: make dependencies

- name: Build
run: make build
Expand Down
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

70 changes: 34 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,65 +1,64 @@
build: clean
python3 -m build
.PHONY: dependencies
dependencies:
uv sync --frozen --no-install-project --all-extras

.PHONY: build
build: clean
uv run python3 -m build

.PHONY: clean
clean:
rm -rf build dist
.PHONY: clean

requirements:
python3 -m pip install \
-r requirements.txt \
-r requirements-test.txt
.PHONY: requirements

fix:
ruff format .
ruff check --fix .
.PHONY: fix
fix:
uv run ruff format .
uv run ruff check --fix .

check-lint:
ruff format --check .
ruff check .
.PHONY: check-lint
check-lint:
uv run ruff format --check .
uv run ruff check .

check-type:
mypy dbtmetabase
.PHONY: check-type
check-type:
uv run mypy dbtmetabase

check: check-lint check-type
.PHONY: check
check: check-lint check-type

.PHONY: test
test:
rm -rf tests/tmp
pytest tests
.PHONY: test
uv run pytest tests

pre: fix check test
.PHONY: pre
pre: fix check test

dist-check: build
twine check dist/*
.PHONY: dist-check
dist-check: build
uv run twine check dist/*

dist-upload: check
twine upload dist/*
.PHONY: dist-upload
dist-upload: check
uv run twine upload dist/*

install: build
python3 -m pip uninstall -y dbt-metabase \
&& python3 -m pip install dist/dbt_metabase-*-py3-none-any.whl
.PHONY: install
install: build
uv pip uninstall dbt-metabase \
&& uv pip install dist/dbt_metabase-*-py3-none-any.whl

.PHONY: sandbox-up
sandbox-up:
( cd sandbox && docker compose up --build --attach app )
.PHONY: sandbox-up

.PHONY: sandbox-up
sandbox-down:
( cd sandbox && docker compose down )
.PHONY: sandbox-up

.PHONY: sandbox-models
sandbox-models:
( . sandbox/.env && python3 -m dbtmetabase models \
( . sandbox/.env && uv run python3 -m dbtmetabase models \
--manifest-path sandbox/target/manifest.json \
--metabase-url http://localhost:$$MB_PORT \
--metabase-username $$MB_USER \
Expand All @@ -69,12 +68,12 @@ sandbox-models:
--http-header x-dummy-key dummy-value \
--order-fields \
--verbose )
.PHONY: sandbox-models

.PHONY: sandbox-exposures
sandbox-exposures:
rm -rf sandbox/models/exposures
mkdir -p sandbox/models/exposures
( . sandbox/.env && python3 -m dbtmetabase exposures \
( . sandbox/.env && uv run python3 -m dbtmetabase exposures \
--manifest-path sandbox/target/manifest.json \
--metabase-url http://localhost:$$MB_PORT \
--metabase-username $$MB_USER \
Expand All @@ -91,8 +90,7 @@ sandbox-exposures:
POSTGRES_PASSWORD=$$POSTGRES_PASSWORD \
POSTGRES_DB=$$POSTGRES_DB \
POSTGRES_SCHEMA=$$POSTGRES_SCHEMA \
dbt docs generate )
.PHONY: sandbox-exposures
uv run dbt docs generate )

sandbox-e2e: sandbox-up sandbox-models sandbox-exposures sandbox-down
.PHONY: sandbox-e2e
sandbox-e2e: sandbox-up sandbox-models sandbox-exposures sandbox-down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[![GitHub Actions](https://github.com/gouline/dbt-metabase/actions/workflows/master.yml/badge.svg)](https://github.com/gouline/dbt-metabase/actions/workflows/master.yml)
[![PyPI](https://img.shields.io/pypi/v/dbt-metabase)](https://pypi.org/project/dbt-metabase/)
[![Downloads](https://pepy.tech/badge/dbt-metabase)](https://pepy.tech/project/dbt-metabase)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/gouline/dbt-metabase/blob/master/LICENSE)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)

Integration between [dbt](https://www.getdbt.com/) and [Metabase](https://www.metabase.com/).

Expand All @@ -14,6 +14,8 @@ If dbt is your source of truth for database schemas and you use Metabase as your

Requires Python 3.8 or above.

For development, you will need [uv](https://docs.astral.sh/uv/getting-started/installation/) installed.

## Usage

You can install dbt-metabase from [PyPI](https://pypi.org/project/dbt-metabase/):
Expand Down
54 changes: 53 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,58 @@
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=60", "setuptools-scm"]

[project]
name = "dbt-metabase"
description = "dbt + Metabase integration."
readme = "README.md"
requires-python = ">=3.8"
dependencies = [
"PyYAML>=5.4.1",
"requests>=2.26.0",
"click>=8.0.0",
"rich>=12.0.0",
]
dynamic = ["version"]
license = { text = "MIT License" }
authors = [{ name = "Mike Gouline" }]
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
]

[project.scripts]
dbt-metabase = "dbtmetabase.__main__:cli"

[project.optional-dependencies]
test = [
"build>=1.0.3",
"twine>=4.0.2",
"ruff>=0.5.5",
"mypy>=1.7.1",
"pytest>=8.3.1",
"molot~=1.0.0",
"dbt-postgres~=1.8.1",
"python-dotenv~=1.0.1",
"types-requests",
"types-PyYAML",
]

[project.urls]
Homepage = "https://github.com/gouline/dbt-metabase"

[tool.setuptools]
packages = ["dbtmetabase"]

[tool.setuptools_scm]
version_file = "dbtmetabase/_version.py"
Expand Down
11 changes: 0 additions & 11 deletions requirements-test.txt

This file was deleted.

4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

10 changes: 6 additions & 4 deletions sandbox/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
FROM python:3.11-slim-bullseye
FROM python:3.12-slim-bullseye

RUN apt-get update && \
apt-get install -y gcc libpq-dev

COPY --from=ghcr.io/astral-sh/uv:0.4.0 /uv /bin/uv

WORKDIR /app

COPY --from=root requirements.txt ./
COPY --from=root requirements-test.txt ./
COPY --from=root pyproject.toml uv.lock ./
RUN uv sync --frozen --no-install-project --all-extras

RUN pip install --no-cache-dir -r requirements.txt -r requirements-test.txt
ENV PATH="/app/.venv/bin:$PATH"

WORKDIR /app/sandbox

Expand Down
47 changes: 0 additions & 47 deletions setup.py

This file was deleted.

Loading
Loading