Skip to content

Commit

Permalink
Merge pull request #8 from enerBit/move_to_uv
Browse files Browse the repository at this point in the history
Move to uv
  • Loading branch information
elpablete authored Nov 5, 2024
2 parents cf5eada + 780abcd commit f1e1aaa
Show file tree
Hide file tree
Showing 14 changed files with 801 additions and 314 deletions.
11 changes: 0 additions & 11 deletions .flake8

This file was deleted.

63 changes: 31 additions & 32 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI

on:
release:
types: [published]

permissions:
contents: read
push:
tags:
- "**" # Push events to every tag including hierarchical tags like v1.0/beta

jobs:
deploy:

build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

strategy:
matrix:
# Run in all these versions of Python
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@master

- name: Set Up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Build and wheel
run: uvx --from build pyproject-build --installer uv

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
55 changes: 55 additions & 0 deletions .github/workflows/test-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Test
run-name: ${{ github.actor }} is testing

on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
workflow_dispatch:

jobs:
test:
name: Test code
runs-on: ubuntu-latest

strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# Run in all these versions of Python
python-version: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Test with pytest
run: uv run pytest tests

mypy:
name: Type check code
runs-on: ubuntu-latest

strategy:
matrix:
# Run in all these versions of Python
python-version: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Type check code
run: uv run mypy src
- name: Type check tests
run: uv run mypy tests
82 changes: 82 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
[project]
requires-python = ">=3.10, <3.11"
name = "enerbitdso"
description = "enerBit DSO (Distribution System Operator) API client"
readme = "README.md"
dynamic = ["version"]

license = { file = "LICENSE" }
Homepage = "https://github.com/enerBit/enerbitdso"
Repository = "https://github.com/enerBit/enerbitdso"
authors = [{ name = "CGM enerBit", email = "[email protected]" }]

keywords = [
"enerbit",
"distribution system operator",
"operador de red",
"power",
"energy",
"potencia eléctrica",
"eneergia eléctrica",
"colombia",
"asic",
"xm",
"api",
"client",
"mem",
"fronteras comerciales",
]

dependencies = [
"httpx>=0.27.2",
"orjson>=3.10.10",
"pydantic>=2.9.2",
"rich>=13.9.4",
"urlpath>=1.2.0",
"typer>=0.12.5",
"tzdata>=2024.2",
]

[project.scripts]
enerbitdso = "enerbitdso.cli:cli"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[dependency-groups]
dev = ["ruff", "mypy", "pytest", "pandas", "pandas-stubs"]

[tool.hatch.version]
path = "src/enerbitdso/VERSION"
pattern = "^(?P<version>.+)$"

[tool.hatch.build.targets.wheel]
packages = ["src/enerbitdso"]

[tool.hatch.build.targets.sdist]
packages = ["src/enerbitdso"]
include = ["/tests"]

[tool.pytest.ini_options]
pythonpath = "src"
testpaths = ["tests"]
addopts = ["--import-mode=importlib"]

[tool.ruff]
line-length = 119
max-complexity = 15
indent-width = 4

[tool.ruff.lint]
select = ["B", "C", "E", "F", "W", "B9", "I"]
ignore = ["E203", "E501", "W503"]

[tool.ruff.lint.flake8-bugbear]
extend-immutable-calls = [
# Whitelisted default arguments
"fastapi.Header",
"fastapi.Depends",
"typer.Option",
"typer.Argument",
]
6 changes: 0 additions & 6 deletions requirements-dev.txt

This file was deleted.

Loading

0 comments on commit f1e1aaa

Please sign in to comment.