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

use python virtualenv #80

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/commands/set-parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ steps:
MAPPING: << parameters.mapping >>
OUTPUT_PATH: << parameters.output-path >>
CONFIG_PATH: << parameters.config-path >>
shell: /usr/bin/env python3
command: <<include(scripts/create-parameters.py)>>
CREATE_PIPELINE_SCRIPT: <<include(scripts/create-parameters.py)>>
command: <<include(scripts/create-parameters.sh)>>
17 changes: 8 additions & 9 deletions src/scripts/create-parameters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python3

import json
import os
import re
Expand Down Expand Up @@ -137,10 +135,11 @@ def create_parameters(output_path, config_path, head, base, mapping):
write_parameters_from_mappings(mappings, changes, output_path, config_path)


create_parameters(
os.environ.get('OUTPUT_PATH'),
os.environ.get('CONFIG_PATH'),
os.environ.get('CIRCLE_SHA1'),
os.environ.get('BASE_REVISION'),
os.environ.get('MAPPING')
)
if __name__ == "__main__":
create_parameters(
os.environ.get('OUTPUT_PATH'),
os.environ.get('CONFIG_PATH'),
os.environ.get('CIRCLE_SHA1'),
os.environ.get('BASE_REVISION'),
os.environ.get('MAPPING')
)
35 changes: 35 additions & 0 deletions src/scripts/create-parameters.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
set -e
set -o pipefail

if [ -f .python-version ]; then
# Create a temp directory
circleci_temp_dir="$(mktemp -d)"
# Move .python-version out of the directory
mv .python-version "$circleci_temp_dir"/.python-version
fi

curl "https://bootstrap.pypa.io/get-pip.py" -o "circleci_get_pip.py"
python3 circleci_get_pip.py --user

python3 -m pip install --user virtualenv

echo "Create python virtual environment for path-filtering"
virtualenv path-filtering-venv -p /usr/bin/python3

echo "Activate python virtual environment"
# shellcheck source=/dev/null
. path-filtering-venv/bin/activate

echo "${CREATE_PIPELINE_SCRIPT}" > circleci_create_parameters_script.py

echo "Creating pipeline parameters"
python3 circleci_create_parameters_script.py

if [ -f "$circleci_temp_dir"/.python-version ]; then
# Move .python-version back
mv "$circleci_temp_dir"/.python-version .python-version
fi

echo "Deactivate python virtual environment for path-filtering"
deactivate