Skip to content

Commit

Permalink
Disable rust when preparing the python environment (#24775)
Browse files Browse the repository at this point in the history
When setting up the python environment or upgrading pip the build might
fail because rust is not available or recent enough.
We set the `CRYPTOGRAPHY_DONT_BUILD_RUST=1` environment variable as
mitigation whenever we prepare the python test environment.
  • Loading branch information
Steffen Siering authored Mar 26, 2021
1 parent 8184a91 commit eb937f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dev-tools/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ jenkins_setup() {

# Workaround for Python virtualenv path being too long.
export TEMP_PYTHON_ENV=$(mktemp -d)

# Workaround for cryptography package (pip dependency) relying on rust
export CRYPTOGRAPHY_DONT_BUILD_RUST=1

export PYTHON_ENV="${TEMP_PYTHON_ENV}/python-env"

# Write cached magefile binaries to workspace to ensure
Expand Down
6 changes: 6 additions & 0 deletions dev-tools/mage/pytest.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ func PythonVirtualenv() (string, error) {
pythonVirtualenvLock.Lock()
defer pythonVirtualenvLock.Unlock()

// When upgrading pip we might run into an error with the cryptography package
// (pip dependency) will not compile if no recent rust development environment is available.
// We set `CRYPTOGRAPHY_DONT_BUILD_RUST=1`, to disable the need for python.
// See: https://github.com/pyca/cryptography/issues/5771
os.Setenv("CRYPTOGRAPHY_DONT_BUILD_RUST", "1")

// Determine the location of the virtualenv.
ve, err := pythonVirtualenvPath()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions libbeat/scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ load-tests: ## @testing Runs load tests

# Sets up the virtual python environment
.PHONY: python-env
python-env: export CRYPTOGRAPHY_DONT_BUILD_RUST=1
python-env: ${ES_BEATS}/libbeat/tests/system/requirements.txt
@test -e ${PYTHON_ENV}/bin/activate || ${PYTHON_EXE} -m venv ${VENV_PARAMS} ${PYTHON_ENV}
@. ${PYTHON_ENV}/bin/activate && pip install ${PIP_INSTALL_PARAMS} -q --upgrade pip ; \
Expand Down

0 comments on commit eb937f0

Please sign in to comment.