Skip to content

Changed install scripts to be consistent with new python installation method #1417

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

Merged
merged 2 commits into from
May 12, 2025

Conversation

nedvedba
Copy link
Collaborator

@nedvedba nedvedba commented May 7, 2025

Summary by Sourcery

Update installation scripts to consistently install Python using a new method across different dependency installation scripts

New Features:

  • Added a new install_python() function in dependency installation scripts

Enhancements:

  • Standardized Python installation process across multiple dependency installation scripts

Chores:

  • Added Python installation check to prevent redundant installations

@nedvedba nedvedba requested a review from JoshuaSBrown May 7, 2025 13:43
@nedvedba nedvedba self-assigned this May 7, 2025
@nedvedba nedvedba added Component: Build Related to the build system Component: CI labels May 7, 2025
Copy link

sourcery-ai bot commented May 7, 2025

Reviewer's Guide

This pull request refactors the Python installation process by introducing a centralized shell function, install_python, within scripts/dependency_install_functions.sh. This function utilizes apt and the deadsnakes PPA to install specified Python versions, including development tools and venv, and creates a marker file to prevent re-installation. This new function is now called by various service-specific installation scripts to ensure a consistent Python setup. Dockerfiles related to dependencies were also modified.

Sequence diagram for Python installation process

sequenceDiagram
    participant CS as Calling Script
    participant IPF as install_python function
    participant APT as System Package Manager (apt)
    participant PPA as PPA (deadsnakes)

    CS->>IPF: Execute install_python
    IPF->>IPF: Check for .python_installed marker
    alt Marker not found
        IPF->>APT: apt update
        APT-->>IPF: Done
        IPF->>APT: apt install software-properties-common
        APT-->>IPF: Done
        IPF->>PPA: add-apt-repository ppa:deadsnakes/ppa
        PPA-->>IPF: Repository added
        IPF->>APT: apt update
        APT-->>IPF: Done
        IPF->>APT: apt install python${DATAFED_PYTHON_VERSION}...
        APT-->>IPF: Python installed
        IPF->>IPF: touch .python_installed marker
    end
Loading

Flow diagram for the new install_python function

graph TD
    A[Start] --> B{Python already installed? Check marker file};
    B -- Yes --> F[End];
    B -- No --> C[apt update];
    C --> D[apt install software-properties-common];
    D --> E[add-apt-repository ppa:deadsnakes/ppa];
    E --> G[apt update];
    G --> H[apt install python, python-dev, python-venv, python-distutils];
    H --> I[Create .python_installed marker file];
    I --> F;
Loading

File-Level Changes

Change Details Files
Introduced a centralized Python installation function.
  • Added a new shell function install_python.
  • The function uses apt and the deadsnakes PPA to install a specified Python version.
  • It installs the Python interpreter, development headers, venv, and distutils.
  • A marker file is created to skip installation if already performed.
scripts/dependency_install_functions.sh
Updated various installation scripts to use the new Python installation method.
  • Added a call to the install_python function at the beginning of each script.
scripts/install_authz_dependencies.sh
scripts/install_client_dependencies.sh
scripts/install_core_dependencies.sh
scripts/install_repo_dependencies.sh
scripts/install_ws_dependencies.sh
Modified Dockerfiles related to dependencies.
  • Updated Dockerfiles (specific content changes not provided in the diff).
docker/Dockerfile.dependencies
repository/docker/Dockerfile.gcs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@@ -64,6 +64,18 @@ else
fi
fi

install_python() {
if [ ! -e "${DATAFED_DEPENDENCIES_INSTALL_PATH}/.python_installed-${DATAFED_PYTHON_VERSION}" ]; then
apt update
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
apt update
"$SUDO_CMD" apt update

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This SUDO piece needs to be added to all of the apt calls.

@nedvedba nedvedba mentioned this pull request May 7, 2025
7 tasks
# Install the configured Python version
RUN apt update
RUN apt install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the motivation for using the deadsnakes PPA for Python installation rather than the default Ubuntu repositories?

Comment on lines +67 to +78
install_python() {
if [ ! -e "${DATAFED_DEPENDENCIES_INSTALL_PATH}/.python_installed-${DATAFED_PYTHON_VERSION}" ]; then
"$SUDO_CMD" apt update
"$SUDO_CMD" apt install -y software-properties-common
"$SUDO_CMD" add-apt-repository ppa:deadsnakes/ppa
"$SUDO_CMD" apt update
"$SUDO_CMD" apt install -y "python${DATAFED_PYTHON_VERSION}" "python${DATAFED_PYTHON_VERSION}-dev" "python${DATAFED_PYTHON_VERSION}-venv" "python${DATAFED_PYTHON_VERSION}-distutils"

touch "${DATAFED_DEPENDENCIES_INSTALL_PATH}/.python_installed-${DATAFED_PYTHON_VERSION}"
fi
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@nedvedba nedvedba merged commit b5d6508 into fix-ci-build May 12, 2025
12 checks passed
JoshuaSBrown added a commit that referenced this pull request May 13, 2025
* updated requirements

* updated requirements

* updated protobuf submodule

* update unit test ci version

* updated protobuf version

* updated setuptools version

* fixed condition

* changed where packages are installed

* used python3.11 to create the virtual environment instead of latest

* reverted protobuf version

* testing specificying version

* removed pyvenv in ci job for consistency

* installed python3.11 in dependencies docker file

* added missing -y flag

* removed unification of install scripts

* added missing python3.11 install

* updated ci job to install python3.11

* changed installed python version to 3.9 since protobuf does not officially support 3.11

* changed installed python version to 3.9 since protobuf does not officially support 3.11

* missed version

* updated includes for newer gcc versions

* updated versions

* updated nlohmann json

* updated json schema version

* changed library search path

* hopefully fixed json dep issues

* updating function signature to match newer version of base class

* updated protobuf

* updated protobuf and cmake

* downgraded cmake

* fixed protobuf version

* fixed protobuf version

* 1398 pin python version (#1405)

* Pin python version

* fixed incorrect path

* Switch to using .tar file install of libsodium (#1414)

* 1413 libsodium build refactor (#1415)

* Switch to using .tar file install of libsodium

* Switch bad option in wget command from -C to -P

* Update scripts/dependency_install_functions.sh

* Update scripts/dependency_install_functions.sh

* Update dependency_install_functions.sh

Libsodium folder version number.

* Update dependency_install_functions.sh

Make paths explicit.

* cleaned up comments

* Update scripts/dependency_install_functions.sh

Co-authored-by: Joshua S Brown <[email protected]>

* Update cmake/JSONSchema.cmake

Co-authored-by: Joshua S Brown <[email protected]>

* Update scripts/dependency_install_functions.sh

Co-authored-by: Joshua S Brown <[email protected]>

* Update cmake/JSONSchema.cmake

Co-authored-by: Joshua S Brown <[email protected]>

* add changes from review

* Changed install scripts to be consistent with new python installation method (#1417)

* changed install scripts to be consistent

* added sudo check

* add apt sources check

---------

Co-authored-by: Blake Nedved <[email protected]>
Co-authored-by: nedvedba <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Build Related to the build system Component: CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants