Skip to content

Commit

Permalink
refactor poetry example for user installation
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-yankee committed Jan 27, 2025
1 parent 52bcccc commit d853e81
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 42 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ jobs:
python-version: '3.12'
- name: poetry setup
working-directory: drake_poetry
run: setup/install_prereqs 3.12
run: |
.github/setup
setup/install_prereqs 3.12
shell: zsh -efuo pipefail {0}
- name: poetry test
working-directory: drake_poetry
Expand All @@ -42,13 +44,14 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
# ubuntu_setup and ci_build_test must occur in one step
# setup and test must occur in one step
# because when poetry is installed, the update to PATH
# does not persist between steps on GHA.
# does not persist between steps on GHA
- name: poetry setup and test
working-directory: drake_poetry
run: |
.github/ubuntu_setup
sudo .github/setup
source $HOME/.profile
setup/install_prereqs
.github/ci_build_test
shell: bash
30 changes: 30 additions & 0 deletions drake_poetry/.github/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# SPDX-License-Identifier: MIT-0

set -euxo pipefail

case "$OSTYPE" in
darwin*)
# Mac-specific installations
brew install pipx
;;

linux*)
if [[ "${EUID:-}" -ne 0 ]]; then
echo 'This script must be run as root' >&2
exit 2
fi

# Ubuntu-specific installations
echo 'APT::Acquire::Retries "4";' > /etc/apt/apt.conf.d/80-acquire-retries
echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes

export DEBIAN_FRONTEND='noninteractive'

apt-get update
apt-get install --no-install-recommends pipx python3
;;
esac

pipx install poetry
pipx ensurepath
11 changes: 0 additions & 11 deletions drake_poetry/.github/ubuntu_setup

This file was deleted.

11 changes: 7 additions & 4 deletions drake_poetry/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ jobs:
python-version: '3.12'
- name: poetry setup
working-directory: drake_poetry
run: setup/install_prereqs 3.12
run: |
.github/setup
setup/install_prereqs 3.12
shell: zsh -efuo pipefail {0}
- name: poetry test
working-directory: drake_poetry
Expand All @@ -53,13 +55,14 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
# ubuntu_setup and ci_build_test must occur in one step
# setup and test must occur in one step
# because when poetry is installed, the update to PATH
# does not persist between steps on GHA.
# does not persist between steps on GHA
- name: poetry setup and test
working-directory: drake_poetry
run: |
.github/ubuntu_setup
sudo .github/setup
source $HOME/.profile
setup/install_prereqs
.github/ci_build_test
shell: bash
10 changes: 5 additions & 5 deletions drake_poetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ The `pyproject.toml` file found in this directory contains all
that is needed to start a Poetry project using the most recent
version of Drake.

First, follow the [Installation Instructions](https://python-poetry.org/docs/#installation)
to install Poetry using your preferred method.

Run the installation script to perform the following:

* install the required system packages for Drake
* install Poetry using `pipx`; see the
[Installation Instructions](https://python-poetry.org/docs/#installation)
for more information
* install the most recent version of Drake using `poetry install`
* install the required system packages for Drake (Ubuntu only)
* set up your Poetry environment and install the most recent version of Drake

```bash
setup/install_prereqs
Expand Down
19 changes: 1 addition & 18 deletions drake_poetry/setup/install_prereqs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ if [[ "${EUID}" -ne 0 ]]; then
maybe_sudo=sudo
fi

case "$OSTYPE" in
darwin*)
# Mac-specific installations
brew install pipx
;;

linux*)
if [[ "$OSTYPE" == "linux"* ]]; then
# Ubuntu-specific installations
# See https://github.com/RobotLocomotion/drake/blob/master/tools/wheel/content/INSTALLATION
# for a complete list of the required libraries to be installed.
Expand All @@ -24,19 +18,8 @@ case "$OSTYPE" in
libglib2.0-0
libsm6
libx11-6
pipx
python3
EOF
)
;;
esac

# Install poetry
pipx install poetry
pipx ensurepath
# Update PATH on Linux in order to run the next steps
if [[ "$OSTYPE" == "linux"* ]]; then
source $HOME/.profile
fi

# If a version of Python other than the default (3) is provided,
Expand Down

0 comments on commit d853e81

Please sign in to comment.