Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-4646

Improve usage of hatch in evergreen

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.11
    • Affects Version/s: None
    • Component/s: None
    • Python Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Context

      After PYTHON-4631 we should create a single virtual environment for hatch and add it to PATH, and then use that subsequently in tests.  We should install rust if installing hatch fails, and then re-install hatch.  We can then remove the usages of "SKIP_HATCH" as well.

       

      Example script:

       

      CARGO_HOME=${CARGO_HOME:-${DRIVERS_TOOLS}/.cargo}
      # Handle paths on Windows.
      if [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin
         CARGO_HOME=$(cygpath -m $CARGO_HOME)
      fi 
      
      # Ensure "hatch" is installed.
      if ! command -v hatch > /dev/null; then
        # Ensure there is a python venv.
        if [ ! -d ${PYTHON_BIN} ]; then
          echo "Creating virtual environment..."
          . ${DRIVERS_TOOLS}/.evergreen/find-python3.sh
          PYTHON_BINARY=$(ensure_python3)
          $PYTHON_BINARY -m venv .venv
          echo "Creating virtual environment... done."
        fi
        python --version
      
        echo "Installing hatch..."
        python -m pip install -U pip
        python -m pip install hatch || {
          # Install rust and try again.
          export RUSTUP_HOME="${CARGO_HOME}/.rustup"
          ${DRIVERS_TOOLS}/.evergreen/install-rust.sh
          source "${CARGO_HOME}/env"
          python -m pip install hatch
        }
        echo "Installing hatch... done."
      fi
      hatch --version
      

       

      Definition of done

      Ensure hatch is installed once and available on each platform.

      Pitfalls

      None

            Assignee:
            steve.silvester@mongodb.com Steve Silvester
            Reporter:
            steve.silvester@mongodb.com Steve Silvester
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: