Skip to content

Commit

Permalink
[CI] Migrate to pyproject.toml and poetry for deterministic builds
Browse files Browse the repository at this point in the history
  • Loading branch information
john-bodley committed Aug 31, 2022
1 parent 25fac12 commit f97d3da
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 82 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ concurrency:
cancel-in-progress: true

jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: "Checkout the source code"
uses: actions/checkout@v2

- name: "Install Python"
uses: actions/setup-python@v2

build:
runs-on: ubuntu-latest
strategy:
Expand All @@ -43,6 +34,7 @@ jobs:
# Test with older Trino versions for backward compatibility
- { python: "3.10", trino: "351" } # first Trino version
env:
TOX_PARALLEL_NO_SPINNER: 1
TRINO_VERSION: "${{ matrix.trino }}"
steps:
- uses: actions/checkout@v2
Expand All @@ -53,7 +45,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install libkrb5-dev
sudo curl -sSL https://install.python-poetry.org | python3 - --preview
- name: Run tests
sudo curl -sSL https://install.python-poetry.org | python3
poetry install
- name: Run tox
run: |
poetry run tox --parallel
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,3 @@ repos:
additional_dependencies:
- "types-pytz"
- "types-requests"

- repo: "https://github.com/python-poetry/poetry"
rev: "1.2.0b3"
hooks:
- id: poetry-check
- id: poetry-lock
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ the [`JWT` authentication type](https://trino.io/docs/current/security/jwt.html)
from sqlalchemy import create_engine

engine = create_engine("trino://<username>@<host>:<port>/<catalog>/<schema>?access_token=<jwt_token>")

# or
from trino.auth import JWTAuthentication
engine = create_engine(
Expand Down Expand Up @@ -419,10 +419,10 @@ Start by forking the repository and then modify the code in your fork.

Clone the repository and go inside the code directory.

Python dependencies are managed using [Poetry](https://python-poetry.org/) which helps to ensure the project is managed in a deterministic way. Currently this project leverages [dependency groups](https://python-poetry.org/docs/master/managing-dependencies/) which are a pre-release feature and thus Poetry should be installed via:
Python dependencies are managed using [Poetry](https://python-poetry.org/) which helps to ensure the project is managed in a deterministic way. Poetry [creates a virtual environment](https://python-poetry.org/docs/managing-environments/) to aid with the process. Poetry should be installed via:

```
$ curl -sSL https://install.python-poetry.org | python3 - --preview
$ curl -sSL https://install.python-poetry.org | python3
```

When the code is ready, submit a Pull Request.
Expand Down Expand Up @@ -477,7 +477,7 @@ poetry run tox -e pre-commit
```bash
git fetch -a && git status
```
- Change version in `trino/__init__.py` to a new version, e.g. `0.123.0`.
- Change version in `trino/pyproject.toml` to a new version, e.g. `0.123.0`.
- Commit
```bash
git commit -a -m "Bump version to 0.123.0"
Expand All @@ -488,7 +488,7 @@ poetry run tox -e pre-commit
```
- Create release package and upload it to PyPI
```bash
poetry publish &&
poetry publish --build &&
open https://pypi.org/project/trino/ &&
echo "Released!"
```
Expand Down
67 changes: 23 additions & 44 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 16 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

[build-system]
requires = ["poetry-core>=1.1.0b3"]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
Expand Down Expand Up @@ -45,23 +44,28 @@ requests = "*"
requests_kerberos = { version = "*", optional = true }
sqlalchemy = { version = "~1.4", optional = true }

[tool.poetry.extras]
external-authentication-token-cache = ["keyring"]
kerberos = ["requests_kerberos"]
sqlalchemy = ["sqlalchemy"]

[tool.poetry.group.dev]
optional = true

[tool.poetry.group.dev.dependencies]
[tool.poetry.dev-dependencies]
# In Poetry 1.2 these should be defined via:
#
# [tool.poetry.group.dev]
# optional = true
#
# [tool.poetry.group.dev.dependencies]
pre-commit = "*"
tox = "*"
tox-gh-actions = "*"

[tool.poetry.group.test.dependencies]
# In Poetry 1.2 these should be defined via:
#
# [tool.poetry.group.test.dependencies]
click = "*"
httpretty = "<1.1"
pytest = "*"

[tool.poetry.extras]
external-authentication-token-cache = ["keyring"]
kerberos = ["requests_kerberos"]
sqlalchemy = ["sqlalchemy"]

[tool.poetry.plugins."sqlalchemy.dialects"]
trino = "trino.sqlalchemy.dialect:TrinoDialect"
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ python =
3.8: py38
3.9: py39
3.10: py310
pypy-3.7: py37
pypy-3.8: py38
pypy-3.7: pypy37
pypy-3.8: pypy38

[testenv]
allowlist_externals =
Expand All @@ -17,7 +17,7 @@ parallel_show_output = true

[testenv:pre-commit]
commands =
poetry install --only=dev
poetry install
poetry run pre-commit run --all-files --show-diff-on-failure

[tox]
Expand Down
1 change: 0 additions & 1 deletion trino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@
from . import logging

__all__ = ['auth', 'dbapi', 'client', 'constants', 'exceptions', 'logging']

0 comments on commit f97d3da

Please sign in to comment.