Skip to content

Commit

Permalink
Update Poetry installs for Python 3.10
Browse files Browse the repository at this point in the history
python-poetry/poetry#3706
python-poetry/poetry#3870
python-poetry/poetry#4056

Poetry has a new install script, added in python-poetry/poetry#3706.
The old get-poetry.py install script is not compatible with Python 3.10,
so the new install-poetry.py script will be used.

Docker builds and GitHub Actions workflows will be updated to use
`POETRY_HOME=/opt/poetry` consistently.

As of Poetry 1.1.7, there may be complications in Docker when using
install-poetry.py without venvs (`POETRY_VIRTUALENVS_CREATE=false`).
While installing dependencies, the following error is frequently seen:

```text
OSError

Could not find a suitable TLS CA certificate bundle, invalid path:
/opt/poetry/venv/lib/python3.9/site-packages/certifi/cacert.pem

at /opt/poetry/venv/lib/python3.9/site-packages/requests/adapters.py:227
in cert_verify
```

Poetry may be incorrectly attempting to read from its virtualenv if it's
not respecting `POETRY_VIRTUALENVS_CREATE` (python-poetry/poetry#3870).
Downstream steps also do not respect `POETRY_VIRTUALENVS_CREATE`, so the
application does not run.
  • Loading branch information
br3ndonland committed Jul 5, 2021
1 parent 5891d93 commit c0acd4a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
matrix:
python-version: [3.8, 3.9, "3.10.0-beta - 3.10"]
env:
POETRY_HOME: /opt/poetry
POETRY_VIRTUALENVS_CREATE: false
steps:
- uses: actions/checkout@v2
Expand All @@ -37,10 +38,10 @@ jobs:
restore-keys: ${{ runner.os }}-pre-commit-
- name: Install Poetry
run: |
curl -fsS -o get-poetry.py \
https://raw.githubusercontent.com/python-poetry/poetry/HEAD/get-poetry.py
python get-poetry.py -y
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
curl -fsS -o install-poetry.py \
https://raw.githubusercontent.com/python-poetry/poetry/HEAD/install-poetry.py
python install-poetry.py -y
echo "$POETRY_HOME/bin" >> $GITHUB_PATH
- name: Install dependencies
run: poetry install --no-interaction -E fastapi
- name: Run pre-commit hooks
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/hooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
matrix:
python-version: [3.8, 3.9, "3.10.0-beta - 3.10"]
env:
POETRY_HOME: /opt/poetry
POETRY_VIRTUALENVS_CREATE: false
steps:
- uses: actions/checkout@v2
Expand All @@ -35,9 +36,9 @@ jobs:
restore-keys: ${{ runner.os }}-pre-commit-
- name: Install Poetry
run: |
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/HEAD/get-poetry.py
python get-poetry.py -y
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
curl -fsS -o install-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/HEAD/install-poetry.py
python install-poetry.py -y
echo "$POETRY_HOME/bin" >> $GITHUB_PATH
- name: Install dependencies
run: poetry install --no-interaction -E fastapi
- name: Run pre-commit hooks
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
matrix:
python-version: [3.8, 3.9, "3.10.0-beta - 3.10"]
env:
POETRY_HOME: /opt/poetry
POETRY_VIRTUALENVS_CREATE: false
steps:
- uses: actions/checkout@v2
Expand All @@ -32,9 +33,9 @@ jobs:
restore-keys: ${{ runner.os }}-poetry-
- name: Install Poetry
run: |
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/HEAD/get-poetry.py
python get-poetry.py -y
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
curl -fsS -o install-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/HEAD/install-poetry.py
python install-poetry.py -y
echo "$POETRY_HOME/bin" >> $GITHUB_PATH
- name: Install dependencies
run: poetry install --no-interaction -E fastapi
- name: Run unit tests
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.source="https://github.com/br3ndonland/inboard"
LABEL org.opencontainers.image.title="inboard"
LABEL org.opencontainers.image.url="https://github.com/users/br3ndonland/packages/container/package/inboard"
ENV APP_MODULE=inboard.app.main_base:app POETRY_HOME=/opt/poetry POETRY_VIRTUALENVS_CREATE=false PYTHONPATH=/app
ENV APP_MODULE=inboard.app.main_base:app PATH=/opt/poetry/bin:$PATH POETRY_HOME=/opt/poetry POETRY_VIRTUALENVS_CREATE=false PYTHONPATH=/app
COPY poetry.lock pyproject.toml /app/
WORKDIR /app/
RUN curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/HEAD/get-poetry.py && \
python get-poetry.py -y && . $POETRY_HOME/env && poetry install --no-dev --no-interaction --no-root
RUN curl -fsS -o install-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/HEAD/install-poetry.py && \
python install-poetry.py -y && poetry install --no-dev --no-interaction --no-root
COPY inboard /app/inboard
ENTRYPOINT ["python"]
CMD ["-m", "inboard.start"]

FROM base AS fastapi
ENV APP_MODULE=inboard.app.main_fastapi:app PATH=$POETRY_HOME/bin:$PATH
ENV APP_MODULE=inboard.app.main_fastapi:app
RUN poetry install --no-dev --no-interaction --no-root -E fastapi

FROM base AS starlette
ENV APP_MODULE=inboard.app.main_starlette:app PATH=$POETRY_HOME/bin:$PATH
ENV APP_MODULE=inboard.app.main_starlette:app
RUN poetry install --no-dev --no-interaction --no-root -E starlette

0 comments on commit c0acd4a

Please sign in to comment.