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

Install Poetry with pipx #47

Merged
merged 2 commits into from
Oct 26, 2021
Merged

Install Poetry with pipx #47

merged 2 commits into from
Oct 26, 2021

Commits on Oct 26, 2021

  1. Install Poetry with pipx

    GitHub Actions
    
    In GitHub Actions, the following steps will be taken to install Poetry
    and verify that the correct version is installed:
    
    1. Set the `PIPX_VERSION` and `POETRY_VERSION` environment variables,
       which will be used to install specific versions of each package
    2. Install `pipx` with `pip`, for the appropriate version of Python
       (`pipx` is included by default in the GitHub Actions environment,
       but only for the default Python version, not necessarily the version
       installed by actions/setup-python)
    3. Install Poetry with `pipx` instead of get-poetry.py/install-poetry.py
    4. Test that the output of `poetry -V` matches `$POETRY_VERSION`
    
    ---
    
    Docker
    
    There are conflicting conventions when working with Poetry in Docker:
    
    1. Docker's convention is to not use virtualenvs, because containers
      themselves provide sufficient isolation.
    2. Poetry's convention is to always use virtualenvs.
    
    This project has previously preferred the Docker convention:
    
    - Poetry itself was installed with the get-poetry.py script, with the
      environment variable `POETRY_HOME=/opt/poetry` used to specify a
      consistent location for Poetry.
    - `poetry install` was used with `POETRY_VIRTUALENVS_CREATE=false` to
      install the project's packages into the system Python directory.
    
    The conventional Docker approach no longer works because:
    
    - The old install script get-poetry.py is deprecated and not compatible
      with Python 3.10.
    - The new install script install-poetry.py has been problematic so far,
      and Poetry doesn't really test it, so problems will likely continue.
    
    In the updated approach:
    
    - `ENV PATH=/opt/pipx/bin:/app/.venv/bin:$PATH` will prepare `$PATH`.
    - `pip` will be used to install a pinned version of `pipx`.
    - `pipx` will be used to install a pinned version of Poetry, with
      `PIPX_BIN_DIR=/opt/pipx/bin` used to specify the location where `pipx`
      installs the Poetry command-line application, and
      `PIPX_HOME=/opt/pipx/home` used as the location for `pipx` itself.
    - `poetry install` will be used with `POETRY_VIRTUALENVS_CREATE=true`,
      `POETRY_VIRTUALENVS_IN_PROJECT=true` and `WORKDIR /app`
      to install the project's packages into a virtualenv at `/app/.venv`.
    
    Subsequent `python` commands will use `app/.venv/bin/python`. As long as
    `POETRY_VIRTUALENVS_IN_PROJECT=true` and `WORKDIR /app` are retained,
    subsequent Poetry commands will use the same virtualenv at `/app/.venv`.
    br3ndonland committed Oct 26, 2021
    Configuration menu
    Copy the full SHA
    af7bedd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ebd8454 View commit details
    Browse the repository at this point in the history