From 98c63c685f406e2eb158a2b7bb60a98acb3b0c08 Mon Sep 17 00:00:00 2001 From: Zizou <111426680+zizou0x@users.noreply.github.com> Date: Thu, 16 Jan 2025 10:07:57 +0100 Subject: [PATCH] refactor: stop using private pypi (#132) * refactor: stop using private pypi This was required because our repos were not public. Now that they are, people can directly access our Python packages and therefore they don't need access to our private codeartifact anymore * docs: add a list of dependencies in the readme and early check in the setup env script --------- Co-authored-by: zizou <111426680+flopell@users.noreply.github.com> --- substreams/crates/tycho-substreams/Readme.md | 2 +- testing/.env.default | 1 - testing/README.md | 21 +++++++------- testing/pre_build.sh | 26 ----------------- testing/requirements.txt | 4 +-- testing/setup_env.sh | 30 ++++++++++++++++++-- 6 files changed, 42 insertions(+), 42 deletions(-) delete mode 100755 testing/pre_build.sh diff --git a/substreams/crates/tycho-substreams/Readme.md b/substreams/crates/tycho-substreams/Readme.md index 44394fce..5b07f57d 100644 --- a/substreams/crates/tycho-substreams/Readme.md +++ b/substreams/crates/tycho-substreams/Readme.md @@ -11,5 +11,5 @@ To generate the rust structs run the following command from within the root directory: ```bash -buf generate --template substreams/crates/tycho-substreams/buf.gen.yaml --output substreams/crates/tycho-substreams/ +buf generate --template substreams/crates/tycho-substreams/buf.gen.yaml --output substreams/crates/tycho-substreams/ ``` diff --git a/testing/.env.default b/testing/.env.default index d24058b2..0e246f99 100644 --- a/testing/.env.default +++ b/testing/.env.default @@ -1,3 +1,2 @@ export RPC_URL=https://mainnet.infura.io/v3/your-infura-key export SUBSTREAMS_API_TOKEN="changeme" -export DOMAIN_OWNER="AWSAccountId" diff --git a/testing/README.md b/testing/README.md index 0fb0ee13..af848d8d 100644 --- a/testing/README.md +++ b/testing/README.md @@ -36,21 +36,22 @@ The script to generate this file manually is available under `evm/scripts/buildR ## Setup testing environment -### Step 1: Export Environment Variables - -**DOMAIN_OWNER** +## Prerequisites -- **Description**: The domain owner identifier for Propellerhead's AWS account, used for authenticating on the private - PyPI repository. -- **Example**: `export DOMAIN_OWNER=123456789` +Before setting up the Python environment, ensure the following tools and libraries are installed on your system: -### Step 2: Create python virtual environment for testing +- **Git**: Version control tool (https://git-scm.com/) +- **Rust**: Programming language and toolchain (https://www.rust-lang.org/) +- **GCC**: GNU Compiler Collection (https://gcc.gnu.org/) +- **libpq**: PostgreSQL client library (https://www.postgresql.org/docs/9.5/libpq.html) +- **OpenSSL (libssl)**: OpenSSL development library (https://github.com/openssl/openssl) +- **pkg-config**: Helper tool for managing compiler flags (https://www.freedesktop.org/wiki/Software/pkg-config/) +- **Conda**: Python package manager (https://docs.conda.io/en/latest/) +- **pip**: Python package installer (https://pip.pypa.io/) -Run setup env script. It will create a conda virtual env and install all dependencies. +Run the setup env script. It will create a conda virtual env and install all dependencies. This script must be run from within the `tycho-protocol-sdk/testing` directory. -Please note that some dependencies require access to our private PyPI repository. - ``` setup_env.sh ``` diff --git a/testing/pre_build.sh b/testing/pre_build.sh deleted file mode 100755 index 342aed4e..00000000 --- a/testing/pre_build.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# Enable automatic export of all defined variables -set -a - -# Source the .env file -source .env - -# Disable automatic export (optional, if you want to stop exporting variables) -set +a - -# Check if DOMAIN_OWNER is set -if [ -z "$DOMAIN_OWNER" ]; then - echo "DOMAIN_OWNER environment variable is not set." - return 1 -fi - -# Fetch the CODEARTIFACT_AUTH_TOKEN -CODEARTIFACT_AUTH_TOKEN=$(aws --region eu-central-1 codeartifact get-authorization-token --domain propeller --domain-owner $DOMAIN_OWNER --query authorizationToken --output text --duration 1800) - -# Set the PIP_INDEX_URL -PIP_INDEX_URL="https://aws:${CODEARTIFACT_AUTH_TOKEN}@propeller-${DOMAIN_OWNER}.d.codeartifact.eu-central-1.amazonaws.com/pypi/protosim/simple/" - -# Export the variables -export CODEARTIFACT_AUTH_TOKEN -export PIP_INDEX_URL \ No newline at end of file diff --git a/testing/requirements.txt b/testing/requirements.txt index f1366ad1..32a4fac2 100644 --- a/testing/requirements.txt +++ b/testing/requirements.txt @@ -2,5 +2,5 @@ psycopg2==2.9.9 PyYAML==6.0.1 Requests==2.32.2 web3==5.31.3 -tycho-indexer-client>=0.7.2 -tycho-simulation-py>=0.32.0 +git+https://github.com/propeller-heads/tycho-indexer.git@0.49.0#subdirectory=tycho-client-py +git+https://github.com/propeller-heads/tycho-simulation.git@0.69.0#subdirectory=tycho_simulation_py \ No newline at end of file diff --git a/testing/setup_env.sh b/testing/setup_env.sh index 6c7be542..7e7df067 100755 --- a/testing/setup_env.sh +++ b/testing/setup_env.sh @@ -1,5 +1,32 @@ #!/bin/bash +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + +# Map of dependencies to their binaries (used to check if they are installed) +declare -A dependencies=( + ["git"]="git" + ["rust"]="rustc" + ["gcc"]="gcc" + ["openssl"]="openssl" + ["pkg-config"]="pkg-config" + ["conda"]="conda" + ["pip"]="pip" + ["libpq"]="pg_config" +) + +# Check each dependency +for dep in "${!dependencies[@]}"; do + binary=${dependencies[$dep]} + if ! command_exists "$binary"; then + echo "Error: '$dep' is not installed." + exit 1 + fi +done + +echo "All dependencies are installed. Proceeding with setup..." + # Variables ENV_NAME="tycho-protocol-sdk-testing" PYTHON_VERSION="3.9" @@ -15,8 +42,7 @@ source activate $ENV_NAME # Install the requirements echo "Installing the requirements from ${REQUIREMENTS_FILE}..." -source ./pre_build.sh -pip install -r $REQUIREMENTS_FILE +pip install -r $REQUIREMENTS_FILE --index-url https://pypi.org/simple conda activate $ENV_NAME echo "Setup complete." \ No newline at end of file