Skip to content

Commit 4bf2c87

Browse files
authored
Switch to poetry (#48)
* feat: poetry * fix: fix workflows to align with poetry * fix: update readme * fix: prod pypi * fix: docker samples Signed-off-by: Omer Cohen <[email protected]>
1 parent 9337401 commit 4bf2c87

File tree

13 files changed

+1505
-246
lines changed

13 files changed

+1505
-246
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 98 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
1-
name: Python package on pull request
1+
name: Python
22

3-
on: [pull_request]
3+
on:
4+
pull_request:
45

56
jobs:
67
build:
7-
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
12-
11+
python-version: ["3.7", "3.8", "3.9", "3.10"]
1312
steps:
14-
- uses: actions/checkout@v3
15-
- name: Set up Python ${{ matrix.python-version }}
16-
uses: actions/setup-python@v4
13+
- name: Poetry
14+
uses: descope/.github/.github/actions/python/poetry/setup@main
1715
with:
1816
python-version: ${{ matrix.python-version }}
19-
- name: Install dependencies
20-
run: |
21-
python -m pip install --upgrade pip
22-
pip install -r requirements-dev.txt
2317

2418
- name: Build coverage file
2519
run: |
26-
python -m pytest --junitxml=/tmp/pytest.xml --cov-report=term-missing:skip-covered --cov=descope tests/ | tee /tmp/pytest-coverage.txt
20+
poetry run pytest --junitxml=/tmp/pytest.xml --cov-report=term-missing:skip-covered --cov=descope tests/ | tee /tmp/pytest-coverage.txt
2721
2822
- name: Pytest coverage comment
2923
id: coverageComment
@@ -46,13 +40,14 @@ jobs:
4640
echo "Coverage Time - ${{ steps.coverageComment.outputs.time }}"
4741
echo "Not Success Test Info - ${{ steps.coverageComment.outputs.notSuccessTestInfo }}"
4842
49-
#- name: Create the Badge
50-
# uses: schneegans/[email protected]
51-
# with:
52-
# auth: ${{ secrets.CI_READ_COMMON }}
53-
# gistID: 277ec23e4e70728824362a0d24fbd0f9
54-
# filename: pytest-coverage-comment.json
55-
# label: Coverage Report
56-
# message: ${{ steps.coverageComment.outputs.coverage }}
57-
# color: ${{ steps.coverageComment.outputs.color }}
58-
# namedLogo: pytest
43+
pkg:
44+
runs-on: ubuntu-latest
45+
needs: build
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v3
49+
- name: Docker build and push
50+
uses: descope/.github/.github/actions/docker/build@main
51+
with:
52+
push: true
53+
token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Python Publish
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read # to detect changes files
10+
11+
jobs:
12+
pypi:
13+
name: Pypi
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Setup
17+
uses: descope/.github/.github/actions/python/poetry/setup@main
18+
- name: Autobump version
19+
run: |
20+
poetry version $(git describe --tags --abbrev=0)
21+
- name: Build
22+
uses: descope/.github/.github/actions/python/poetry/build@main
23+
- name: Publish
24+
uses: descope/.github/.github/actions/python/poetry/publish@main
25+
with:
26+
test: true
27+
token: ${{ secrets.PYPI_TEST_TOKEN }}

.pre-commit-config.yaml

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,60 @@
1-
exclude: 'docs/'
1+
exclude: "docs/"
22

33
repos:
4-
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.3.0
6-
hooks:
7-
- id: check-yaml
8-
- id: debug-statements
9-
- id: end-of-file-fixer
10-
- id: trailing-whitespace
11-
- repo: https://github.com/PyCQA/isort
12-
rev: 5.10.1
13-
hooks:
14-
- id: isort
15-
args: ["--profile", "black"]
16-
- repo: https://github.com/psf/black
17-
rev: 22.6.0
18-
hooks:
19-
- id: black
20-
language_version: python3
21-
- repo: https://github.com/asottile/pyupgrade
22-
rev: v2.37.3
23-
hooks:
24-
- id: pyupgrade
25-
args: [--py37-plus]
26-
- repo: https://gitlab.com/pycqa/flake8
27-
rev: 3.9.2
28-
hooks:
29-
- id: flake8
30-
- repo: https://github.com/dhatim/python-license-check
31-
rev: 0.7.2
32-
hooks:
33-
- id: liccheck
34-
language: system
35-
args: ["-r./requirements-dev.txt", "-lparanoid"]
36-
- repo: local
37-
hooks:
38-
- id: print_statement
39-
name: Check that print statement isnt in source code
40-
types: [python]
41-
entry: 'print'
42-
language: pygrep
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.3.0
6+
hooks:
7+
- id: check-yaml
8+
- id: check-toml
9+
- id: debug-statements
10+
- id: end-of-file-fixer
11+
- id: trailing-whitespace
12+
- repo: https://github.com/PyCQA/isort
13+
rev: 5.10.1
14+
hooks:
15+
- id: isort
16+
args: ["--profile", "black"]
17+
- repo: https://github.com/psf/black
18+
rev: 22.6.0
19+
hooks:
20+
- id: black
21+
language_version: python3
22+
- repo: https://github.com/asottile/pyupgrade
23+
rev: v2.37.3
24+
hooks:
25+
- id: pyupgrade
26+
args: [--py37-plus]
27+
- repo: https://gitlab.com/pycqa/flake8
28+
rev: 3.9.2
29+
hooks:
30+
- id: flake8
31+
- repo: https://github.com/dhatim/python-license-check
32+
rev: 0.7.2
33+
hooks:
34+
- id: liccheck
35+
language: system
36+
args: ["-r./requirements-dev.txt", "-lparanoid"]
37+
- repo: https://github.com/python-poetry/poetry
38+
rev: 1.2.0 # add version here
39+
hooks:
40+
- id: poetry-check
41+
- id: poetry-lock
42+
- id: poetry-export
43+
args: ["-f", "requirements.txt", "-o", "requirements.txt"]
44+
- id: poetry-export
45+
args:
46+
[
47+
"-f",
48+
"requirements.txt",
49+
"-o",
50+
"requirements-dev.txt",
51+
"--only",
52+
"dev",
53+
]
54+
- repo: local
55+
hooks:
56+
- id: print_statement
57+
name: Check that print statement isnt in source code
58+
types: [python]
59+
entry: "print"
60+
language: pygrep

Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
ARG PYTHON_VERSION=3.9
2+
3+
FROM python:${PYTHON_VERSION}-slim as python-base
4+
ENV PYTHONUNBUFFERED=1 \
5+
PYTHONDONTWRITEBYTECODE=1 \
6+
PIP_NO_CACHE_DIR=off \
7+
PIP_DISABLE_PIP_VERSION_CHECK=on \
8+
PIP_DEFAULT_TIMEOUT=100 \
9+
POETRY_HOME="/opt/poetry" \
10+
POETRY_VIRTUALENVS_IN_PROJECT=true \
11+
POETRY_NO_INTERACTION=1 \
12+
PYSETUP_PATH="/opt/pysetup" \
13+
VENV_PATH="/opt/pysetup/.venv"
14+
15+
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
16+
17+
FROM python-base as builder-base
18+
RUN apt-get update \
19+
&& apt-get install --no-install-recommends -y \
20+
curl \
21+
build-essential \
22+
libpq-dev \
23+
git
24+
25+
# Install Poetry - respects $POETRY_VERSION & $POETRY_HOME
26+
ENV POETRY_VERSION=1.2.0
27+
RUN curl -sSL https://install.python-poetry.org | python
28+
29+
# We copy our Python requirements here to cache them
30+
# and install only runtime deps using poetry
31+
WORKDIR $PYSETUP_PATH
32+
COPY . .
33+
RUN poetry install
34+
35+
FROM python-base as production
36+
ENV FASTAPI_ENV=production
37+
38+
COPY --from=builder-base $VENV_PATH $VENV_PATH
39+
40+
COPY . /app
41+
WORKDIR /app
42+
43+
CMD python samples/otp_web_sample_app.py

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ Replace any instance of `<ProjectID>` in the code below with your company's Proj
1111
Run the following code in your project. These commands will add the Descope ExpresSDK for Python as a project dependency, and set the `DESCOPE_PROJECT_ID` variable to a valid \<ProjectID\>.
1212

1313
```code
14-
pip install Descope-Auth
14+
pip install descope
1515
export DESCOPE_PROJECT_ID=<ProjectID>
1616
```
1717

1818
## What do you want to implement?
1919

20-
Click one of the following links to open the documentation for that specific functionality.
20+
Click one of the following links to open the documentation for that specific functionality.
2121

2222
- [x] [One time passwords (OTP)](./docs/otp.md)
2323
- [x] [Magic Links](./docs/magiclink.md)

0 commit comments

Comments
 (0)