From c64cea49a55fd3dbccba8b4ffd7b0246169cb28a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jun 2023 13:11:50 -0300 Subject: [PATCH 01/23] Add installation instructions to README --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7e8493de99..c2c30c1275 100644 --- a/README.md +++ b/README.md @@ -67,18 +67,24 @@ It's Turing-complete and it was created by [Starkware](https://starkware.co/) as ### Dependencies -**Required** +#### Required -- [Rust 1.66.1](https://www.rust-lang.org/tools/install) +These are needed in order to compile and use the project. + +- [Rust 1.69.0 or newer](https://www.rust-lang.org/tools/install) - Cargo -**Optional** +#### Optional These dependencies are only necessary in order to run the original VM, compile Cairo programs, and run tests. - PyEnv with Python 3.9 - cairo-lang +#### Installation script + +You can install all of the required and optional dependencies by running the script `install.sh` while in the repository root. + ## 🚀 Usage ### Adding cairo-vm as a dependency From 32c168070c1f3878ed3c7a9d0957535cfa5a83a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jun 2023 13:18:21 -0300 Subject: [PATCH 02/23] Add compilation step to installation testing --- .github/workflows/test_install.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index c1ffd74958..607900f5eb 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -24,6 +24,9 @@ jobs: - if: matrix.os == 'macos-12' name: "Install on macos-12" run: install-scripts/install-macos.sh + + - name: "Compile project" + run: cargo build --release install_debian: name: "Install on debian-11" @@ -36,3 +39,6 @@ jobs: - name: "Install on debian-11" run: install-scripts/install-debian.sh + + - name: "Compile project" + run: cargo build --release From db1c9a3e60e9eca4c676f4458b5a936cb8da79a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jun 2023 15:28:10 -0300 Subject: [PATCH 03/23] Add script for universal dependency installation --- .github/workflows/test_install.yml | 22 ++++---- install-scripts/install-debian.sh | 1 - install-scripts/install-macos.sh | 1 - install.sh | 86 ++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 13 deletions(-) create mode 100755 install.sh diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index 607900f5eb..ec56b98120 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -17,13 +17,8 @@ jobs: steps: - uses: actions/checkout@v3 - - if: matrix.os == 'ubuntu-22.04' - name: "Install on ubuntu-22.04" - run: install-scripts/install-ubuntu.sh - - - if: matrix.os == 'macos-12' - name: "Install on macos-12" - run: install-scripts/install-macos.sh + - name: "Install dependencies" + run: bash install.sh - name: "Compile project" run: cargo build --release @@ -33,12 +28,17 @@ jobs: runs-on: ubuntu-22.04 container: image: debian:11 + defaults: + run: + shell: bash {0} steps: - uses: actions/checkout@v3 - - name: "Install on debian-11" - run: install-scripts/install-debian.sh - + - name: "Install dependencies" + run: bash install.sh + - name: "Compile project" - run: cargo build --release + run: | + . "$HOME/.cargo/env" + cargo build --release diff --git a/install-scripts/install-debian.sh b/install-scripts/install-debian.sh index 466f35d3c2..aa2a9a97eb 100755 --- a/install-scripts/install-debian.sh +++ b/install-scripts/install-debian.sh @@ -41,4 +41,3 @@ source ~/cairo_venv/bin/activate # Install cairo & its dependencies apt install -y libgmp3-dev pip3 install -r requirements.txt - diff --git a/install-scripts/install-macos.sh b/install-scripts/install-macos.sh index 90e23d88f0..d5cc1413fc 100755 --- a/install-scripts/install-macos.sh +++ b/install-scripts/install-macos.sh @@ -26,4 +26,3 @@ source ~/cairo_venv/bin/activate # Install cairo & its dependencies pip3 install -r requirements.txt - diff --git a/install.sh b/install.sh new file mode 100755 index 0000000000..8351f432a4 --- /dev/null +++ b/install.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +# Print an error message and exit with 1 +unsupported_os () { + echo "Detected OS ($1) is unsupported." + echo "Please open an issue (PRs welcome ❤️) on:" + echo " https://github.com/lambdaclass/cairo-vm/issues" + echo "" + echo "NOTE: you can still try installing dependencies manually" + echo "If your OS differs from the detected one, you can look \ +for the installation script for your OS in the install-scripts folder." + exit 1 +} + +# Print the detected OS +print_os() { + echo "Detected OS: $1" +} + +# Print a message and run the script +run_script() { + echo "Running $1..." + . $1 +} + +# Detect Linux distro +install_linux() { + # taken from: https://unix.stackexchange.com/a/6348 + # tries different methods to detect the Linux distro + if [ -f /etc/os-release ]; then + # freedesktop.org and systemd + . /etc/os-release + OS=$NAME + VER=$VERSION_ID + elif type lsb_release >/dev/null 2>&1; then + # linuxbase.org + OS=$(lsb_release -si) + VER=$(lsb_release -sr) + elif [ -f /etc/lsb-release ]; then + # For some versions of Debian/Ubuntu without lsb_release command + . /etc/lsb-release + OS=$DISTRIB_ID + VER=$DISTRIB_RELEASE + elif [ -f /etc/debian_version ]; then + # Older Debian/Ubuntu/etc. + OS=Debian + VER=$(cat /etc/debian_version) + elif [ -f /etc/SuSe-release ]; then + # Older SuSE/etc. + OS="Old SuSE" + elif [ -f /etc/redhat-release ]; then + # Older Red Hat, CentOS, etc. + OS="Old RedHat" + else + # Fall back to uname, e.g. "Linux ", also works for BSD, etc. + OS=$(uname -s) + VER=$(uname -r) + fi + + print_os $OS + + # NOTE: we don't use $VER for now, but this might change + case "$OS" in + Ubuntu*) run_script "install-scripts/install-ubuntu.sh" ;; + Debian*) run_script "install-scripts/install-debian.sh" ;; + *) unsupported_os "linux: $OS" ;; + esac + + make deps +} + +install_macos() { + print_os "MacOS" + run_script install-scripts/install-macos.sh + + make deps-macos +} + +case "$OSTYPE" in + linux*) install_linux ;; + darwin*) install_macos ;; + msys*|cygwin*) unsupported_os "Windows" ;; + solaris*) unsupported_os "Solaris" ;; + bsd*) unsupported_os "BSD" ;; + *) unsupported_os "unknown: ${OSTYPE}" ;; +esac From dfd1c8f43d7693e052977152868e273f3be809d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jun 2023 16:20:57 -0300 Subject: [PATCH 04/23] Update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8939b8e053..b7f03bd1a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,15 @@ #### Upcoming Changes +* feat: add dependency installation script `install.sh` [#1298](https://github.com/lambdaclass/cairo-vm/pull/1298) + #### [0.8.1] - 2023-6-29 * chore: change mentions of *cairo-rs-py* to *cairo-vm-py* [#1296](https://github.com/lambdaclass/cairo-vm/pull/1296) * rename github repo from https://github.com/lambdaclass/cairo-rs to https://github.com/lambdaclass/cairo-vm [#1289](https://github.com/lambdaclass/cairo-vm/pull/1289) -* fix(security): avoid OOM crashes when programs jump to very high invalid addresses. +* fix(security): avoid OOM crashes when programs jump to very high invalid addresses [#1285](https://github.com/lambdaclass/cairo-vm/pull/1285) * fix: add `to_bytes_be` to the felt when `lambdaworks-felt` feature is active [#1290](https://github.com/lambdaclass/cairo-vm/pull/1290) From 3a52a42cf25d28e93461b817ecaf5876649c7104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jun 2023 20:17:34 -0300 Subject: [PATCH 05/23] Enable test_install workflow only on main --- .github/workflows/test_install.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index ec56b98120..285940ec32 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -4,8 +4,6 @@ on: merge_group: push: branches: [ main ] - pull_request: - branches: [ '*' ] jobs: install: From 04ae709d6a74c9ea52822f4f18ae64a3bf266676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Thu, 29 Jun 2023 20:31:56 -0300 Subject: [PATCH 06/23] Update optional dependencies Just having PyEnv and make installed suffices for running `make deps`. I don't think we need to list cairo-lang as a dependency. --- Makefile | 4 ++-- README.md | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 0b076a8c8a..0c9d982c12 100644 --- a/Makefile +++ b/Makefile @@ -124,11 +124,11 @@ cargo-deps: cargo install --version 0.11.0 wasm-pack deps: cargo-deps build-cairo-1-compiler - pyenv install -s pypy3.9-7.3.9 + pyenv install -s pypy3.9-7.3.9 PYENV_VERSION=pypy3.9-7.3.9 python -m venv cairo-vm-pypy-env . cairo-vm-pypy-env/bin/activate ; \ pip install -r requirements.txt ; \ - pyenv install -s 3.9.15 + pyenv install -s 3.9.15 PYENV_VERSION=3.9.15 python -m venv cairo-vm-env . cairo-vm-env/bin/activate ; \ pip install -r requirements.txt ; \ diff --git a/README.md b/README.md index c2c30c1275..a91f52b401 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,8 @@ A faster and safer implementation of the Cairo VM in Rust - [Getting Started](#-getting-started) - [Dependencies](#dependencies) - [Usage](#-usage) - - [Running cairo-vm](#running-cairo-vm) + - [Adding cairo-vm as a dependency](#adding-cairo-vm-as-a-dependency) + - [Running cairo-vm from the CLI](#running-cairo-vm-from-cli) - [Using hints](#using-hints) - [Running a function in a Cairo program with arguments](#running-a-function-in-a-cairo-program-with-arguments) - [WebAssembly Demo](#webassembly-demo) @@ -78,8 +79,8 @@ These are needed in order to compile and use the project. These dependencies are only necessary in order to run the original VM, compile Cairo programs, and run tests. -- PyEnv with Python 3.9 -- cairo-lang +- make +- PyEnv #### Installation script From 22d2ac61a025d73dcffb76dc4f183e76fe2f2bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 11:16:04 -0300 Subject: [PATCH 07/23] Don't compile, only check --- .github/workflows/test_install.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index 285940ec32..3844aa843b 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -4,6 +4,8 @@ on: merge_group: push: branches: [ main ] + pull_request: + branches: [ '*' ] jobs: install: @@ -19,7 +21,7 @@ jobs: run: bash install.sh - name: "Compile project" - run: cargo build --release + run: cargo check install_debian: name: "Install on debian-11" @@ -39,4 +41,4 @@ jobs: - name: "Compile project" run: | . "$HOME/.cargo/env" - cargo build --release + cargo check From 98de9e8a5535419ac2d5aa2ab49209219d3a614a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 11:30:55 -0300 Subject: [PATCH 08/23] Push again From bfe9f88aa03d94596a00349265a0f34bee965aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 11:38:17 -0300 Subject: [PATCH 09/23] Use swatinem cache --- .github/workflows/test_install.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index 3844aa843b..a6e358d3f2 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -17,10 +17,13 @@ jobs: steps: - uses: actions/checkout@v3 - - name: "Install dependencies" + - name: Set up Cargo cache + uses: Swatinem/rust-cache@v2 + + - name: Install dependencies run: bash install.sh - - name: "Compile project" + - name: Compile project run: cargo check install_debian: @@ -35,10 +38,13 @@ jobs: steps: - uses: actions/checkout@v3 - - name: "Install dependencies" + - name: Set up Cargo cache + uses: Swatinem/rust-cache@v2 + + - name: Install dependencies run: bash install.sh - - name: "Compile project" + - name: Compile project run: | . "$HOME/.cargo/env" cargo check From e72b176584739a0e1e0862ce9719f740492b6288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 12:14:37 -0300 Subject: [PATCH 10/23] Cache all crates even on failure --- .github/workflows/test_install.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index a6e358d3f2..7b34f53461 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -19,6 +19,9 @@ jobs: - name: Set up Cargo cache uses: Swatinem/rust-cache@v2 + with: + cache-all-crates: 'true' + cache-on-failure: 'true' - name: Install dependencies run: bash install.sh @@ -40,6 +43,9 @@ jobs: - name: Set up Cargo cache uses: Swatinem/rust-cache@v2 + with: + cache-all-crates: 'true' + cache-on-failure: 'true' - name: Install dependencies run: bash install.sh From 1cbc0414a5e75ee7d3380c392ca13c4fd80ffdf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 15:05:37 -0300 Subject: [PATCH 11/23] Fix debian rust cache --- .github/workflows/test_install.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index 7b34f53461..26a63572b5 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -41,6 +41,9 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Install Rust + uses: dtolnay/rust-toolchain@1.66.0 # just so cache works + - name: Set up Cargo cache uses: Swatinem/rust-cache@v2 with: From 28e9ca5075a69c36605e8a0214e96c1f433c22c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 15:20:36 -0300 Subject: [PATCH 12/23] Use manual cache --- .github/workflows/test_install.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index 26a63572b5..cc8cde85b8 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -41,14 +41,16 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Install Rust - uses: dtolnay/rust-toolchain@1.66.0 # just so cache works - - - name: Set up Cargo cache - uses: Swatinem/rust-cache@v2 + # we don't use swatinem because rustc isn't installed yet + - name: Cache rust dependencies + uses: actions/cache@v3 + id: cache with: - cache-all-crates: 'true' - cache-on-failure: 'true' + path: | + ${HOME}/.cargo/ + ./target/ + key: ${{ runner.os }}-install-${{ github.sha }} + restore-keys: ${{ runner.os }}-install- - name: Install dependencies run: bash install.sh From 6a68c9ac0a266f7251fc28e76c87ad8a1a4b3303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 15:50:09 -0300 Subject: [PATCH 13/23] Test cache From 9af1c088a821556c78aa9f13b6603ad2560a2be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 16:43:36 -0300 Subject: [PATCH 14/23] Cache cairo compiler --- .github/workflows/test_install.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index cc8cde85b8..fcad7b1b9d 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -22,6 +22,7 @@ jobs: with: cache-all-crates: 'true' cache-on-failure: 'true' + cache-directories: ./cairo/target/ - name: Install dependencies run: bash install.sh @@ -49,6 +50,7 @@ jobs: path: | ${HOME}/.cargo/ ./target/ + ./cairo/target/ key: ${{ runner.os }}-install-${{ github.sha }} restore-keys: ${{ runner.os }}-install- From d2a1728470554dfd0dd40eb71ab6b6aa9d21e6a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 17:17:49 -0300 Subject: [PATCH 15/23] Add pyenv dependency caching --- .github/workflows/test_install.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index fcad7b1b9d..ef008aeda3 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -23,6 +23,16 @@ jobs: cache-all-crates: 'true' cache-on-failure: 'true' cache-directories: ./cairo/target/ + + - name: Create PyEnv cache dir + run: mkdir -p ${HOME}/.pyenv/cache + - name: Cache PyEnv dependencies + uses: actions/cache@v3 + with: + path: | + ${HOME}/.pyenv/cache + key: ${{ runner.os }}-pyenv-install-${{ github.sha }} + restore-keys: ${{ runner.os }}-pyenv-install- - name: Install dependencies run: bash install.sh @@ -43,9 +53,8 @@ jobs: - uses: actions/checkout@v3 # we don't use swatinem because rustc isn't installed yet - - name: Cache rust dependencies + - name: Cache Rust dependencies uses: actions/cache@v3 - id: cache with: path: | ${HOME}/.cargo/ @@ -53,6 +62,16 @@ jobs: ./cairo/target/ key: ${{ runner.os }}-install-${{ github.sha }} restore-keys: ${{ runner.os }}-install- + + - name: Create PyEnv cache dir + run: mkdir -p ${HOME}/.pyenv/cache + - name: Cache PyEnv dependencies + uses: actions/cache@v3 + with: + path: | + ${HOME}/.pyenv/cache + key: ${{ runner.os }}-pyenv-install-${{ github.sha }} + restore-keys: ${{ runner.os }}-pyenv-install- - name: Install dependencies run: bash install.sh From 6030c72faea57a51b101b2f9edfe30196a9b3610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 17:40:17 -0300 Subject: [PATCH 16/23] Cache pip instead of pyenv --- .github/workflows/test_install.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index ef008aeda3..7a7832e3b8 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -24,15 +24,15 @@ jobs: cache-on-failure: 'true' cache-directories: ./cairo/target/ - - name: Create PyEnv cache dir - run: mkdir -p ${HOME}/.pyenv/cache - - name: Cache PyEnv dependencies + - name: Cache Python dependencies uses: actions/cache@v3 with: + # first one is unix and second one macos path: | - ${HOME}/.pyenv/cache - key: ${{ runner.os }}-pyenv-install-${{ github.sha }} - restore-keys: ${{ runner.os }}-pyenv-install- + ${HOME}/.cache/pip/wheels/ + ${HOME}/Library/Caches/pip/wheels/ + key: ${{ runner.os }}-python-install-${{ github.sha }} + restore-keys: ${{ runner.os }}-python-install- - name: Install dependencies run: bash install.sh @@ -63,15 +63,13 @@ jobs: key: ${{ runner.os }}-install-${{ github.sha }} restore-keys: ${{ runner.os }}-install- - - name: Create PyEnv cache dir - run: mkdir -p ${HOME}/.pyenv/cache - - name: Cache PyEnv dependencies + - name: Cache Python dependencies uses: actions/cache@v3 with: path: | - ${HOME}/.pyenv/cache - key: ${{ runner.os }}-pyenv-install-${{ github.sha }} - restore-keys: ${{ runner.os }}-pyenv-install- + ${HOME}/.cache/pip/wheels + key: ${{ runner.os }}-python-install-${{ github.sha }} + restore-keys: ${{ runner.os }}-python-install- - name: Install dependencies run: bash install.sh From 60ac9acfa1534b59cca83d06017a530d463bd91d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 18:35:58 -0300 Subject: [PATCH 17/23] Try fixing cache --- .github/workflows/test_install.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index 7a7832e3b8..ec14406413 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -27,10 +27,10 @@ jobs: - name: Cache Python dependencies uses: actions/cache@v3 with: - # first one is unix and second one macos + # first one is ubuntu and second one macos path: | - ${HOME}/.cache/pip/wheels/ - ${HOME}/Library/Caches/pip/wheels/ + /home/runner/.cache/pip/wheels/ + /Users/runner/Library/Caches/pip/wheels/ key: ${{ runner.os }}-python-install-${{ github.sha }} restore-keys: ${{ runner.os }}-python-install- @@ -63,11 +63,16 @@ jobs: key: ${{ runner.os }}-install-${{ github.sha }} restore-keys: ${{ runner.os }}-install- + - name: Enable pip cache + run: | + mkdir -p /github/home/.cache/pip + chown -R 1000:1000 /github/home/.cache/pip + - name: Cache Python dependencies uses: actions/cache@v3 with: path: | - ${HOME}/.cache/pip/wheels + /github/home/.cache/pip/wheels key: ${{ runner.os }}-python-install-${{ github.sha }} restore-keys: ${{ runner.os }}-python-install- From 7362bd99d1e297aa60b90f341e4d9d9c96c3d831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 18:59:07 -0300 Subject: [PATCH 18/23] Use setup-python action --- .github/workflows/test_install.yml | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index ec14406413..bae5130161 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -24,15 +24,11 @@ jobs: cache-on-failure: 'true' cache-directories: ./cairo/target/ - - name: Cache Python dependencies - uses: actions/cache@v3 + - name: Install python + uses: actions/setup-python@v4 with: - # first one is ubuntu and second one macos - path: | - /home/runner/.cache/pip/wheels/ - /Users/runner/Library/Caches/pip/wheels/ - key: ${{ runner.os }}-python-install-${{ github.sha }} - restore-keys: ${{ runner.os }}-python-install- + python-version: '3.9' + cache: 'pip' - name: Install dependencies run: bash install.sh @@ -63,18 +59,11 @@ jobs: key: ${{ runner.os }}-install-${{ github.sha }} restore-keys: ${{ runner.os }}-install- - - name: Enable pip cache - run: | - mkdir -p /github/home/.cache/pip - chown -R 1000:1000 /github/home/.cache/pip - - - name: Cache Python dependencies - uses: actions/cache@v3 + - name: Install Python + uses: actions/setup-python@v4 with: - path: | - /github/home/.cache/pip/wheels - key: ${{ runner.os }}-python-install-${{ github.sha }} - restore-keys: ${{ runner.os }}-python-install- + python-version: '3.9' + cache: 'pip' - name: Install dependencies run: bash install.sh From 9c4631eb82928975a252c3555937c8850167bc67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 19:08:28 -0300 Subject: [PATCH 19/23] Use ~ instead of ${HOME} --- .github/workflows/test_install.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index bae5130161..c5baf065ad 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -53,7 +53,7 @@ jobs: uses: actions/cache@v3 with: path: | - ${HOME}/.cargo/ + ~/.cargo/ ./target/ ./cairo/target/ key: ${{ runner.os }}-install-${{ github.sha }} From b15d1d8f3a9a4a13efb76cfc9e5c683d7fa59f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 19:12:56 -0300 Subject: [PATCH 20/23] Use manual cache in Debian container --- .github/workflows/test_install.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index c5baf065ad..0a84f38761 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -59,11 +59,18 @@ jobs: key: ${{ runner.os }}-install-${{ github.sha }} restore-keys: ${{ runner.os }}-install- - - name: Install Python - uses: actions/setup-python@v4 + - name: Enable pip cache + run: | + mkdir -p ~/.cache/pip + chown -R 1000:1000 ~/.cache/pip + + - name: Cache Python dependencies + uses: actions/cache@v3 with: - python-version: '3.9' - cache: 'pip' + path: | + ~/.cache/pip/wheels + key: ${{ runner.os }}-python-install-${{ github.sha }} + restore-keys: ${{ runner.os }}-python-install- - name: Install dependencies run: bash install.sh From d0d413ec3be5999aa0fbe33cb32d601b0c792b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 19:31:21 -0300 Subject: [PATCH 21/23] Add some comments --- .github/workflows/test_install.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index 0a84f38761..d9663f3366 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -23,7 +23,8 @@ jobs: cache-all-crates: 'true' cache-on-failure: 'true' cache-directories: ./cairo/target/ - + + # just to cache dependencies - name: Install python uses: actions/setup-python@v4 with: @@ -32,7 +33,7 @@ jobs: - name: Install dependencies run: bash install.sh - + - name: Compile project run: cargo check @@ -58,12 +59,13 @@ jobs: ./cairo/target/ key: ${{ runner.os }}-install-${{ github.sha }} restore-keys: ${{ runner.os }}-install- - + - name: Enable pip cache run: | mkdir -p ~/.cache/pip chown -R 1000:1000 ~/.cache/pip - + + # NOTE: we don't use install-python because lsb_release isn't installed - name: Cache Python dependencies uses: actions/cache@v3 with: From 8aedff4f04376229dacc079d370f4632ee127487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Fri, 30 Jun 2023 20:21:05 -0300 Subject: [PATCH 22/23] Make cache owned by current user and add logs --- .github/workflows/test_install.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index d9663f3366..07ab75c63c 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -63,7 +63,10 @@ jobs: - name: Enable pip cache run: | mkdir -p ~/.cache/pip - chown -R 1000:1000 ~/.cache/pip + chown -v -R $USER ~/.cache + chmod -v -R 770 ~/.cache + ls -al ~/ + ls -al ~/.cache # NOTE: we don't use install-python because lsb_release isn't installed - name: Cache Python dependencies From ee7ce53df020e9d794c48a7c9536afaabab9490d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1?= <47506558+MegaRedHand@users.noreply.github.com> Date: Tue, 4 Jul 2023 17:44:25 -0300 Subject: [PATCH 23/23] Remove python install from script --- Makefile | 1 - install-scripts/install-debian.sh | 18 ++++-------------- install-scripts/install-macos.sh | 15 ++------------- install-scripts/install-ubuntu.sh | 22 +++++++--------------- install.sh | 4 ---- 5 files changed, 13 insertions(+), 47 deletions(-) diff --git a/Makefile b/Makefile index 0c9d982c12..81e1020709 100644 --- a/Makefile +++ b/Makefile @@ -134,7 +134,6 @@ deps: cargo-deps build-cairo-1-compiler pip install -r requirements.txt ; \ deps-macos: cargo-deps build-cairo-1-compiler - brew install gmp arch -x86_64 pyenv install -s pypy3.9-7.3.9 PYENV_VERSION=pypy3.9-7.3.9 python -m venv cairo-vm-pypy-env . cairo-vm-pypy-env/bin/activate ; \ diff --git a/install-scripts/install-debian.sh b/install-scripts/install-debian.sh index aa2a9a97eb..fb050edf97 100755 --- a/install-scripts/install-debian.sh +++ b/install-scripts/install-debian.sh @@ -17,7 +17,9 @@ source "$HOME/.cargo/env" rustc --version # Install pyenv dependencies -apt-get install -y git make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev +apt-get install -y git make build-essential libssl-dev zlib1g-dev libbz2-dev \ + libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \ + xz-utils tk-dev libffi-dev liblzma-dev libgmp3-dev # Install pyenv curl https://pyenv.run | bash @@ -28,16 +30,4 @@ eval "$(pyenv init -)" # Make sure pyenv has been installed correctly pyenv -v -# Installing python 3.9 with pyenv -pyenv install 3.9 - -# Setting python 3.9 as the default local version -pyenv local 3.9 - -# Create and enter a virtual environment -python3.9 -m venv ~/cairo_venv -source ~/cairo_venv/bin/activate - -# Install cairo & its dependencies -apt install -y libgmp3-dev -pip3 install -r requirements.txt +make deps diff --git a/install-scripts/install-macos.sh b/install-scripts/install-macos.sh index d5cc1413fc..09da2b33a4 100755 --- a/install-scripts/install-macos.sh +++ b/install-scripts/install-macos.sh @@ -9,20 +9,9 @@ source "$HOME/.cargo/env" rustc --version # Install pyenv -brew install pyenv +brew install pyenv gmp # Make sure pyenv has been installed correctly pyenv -v -# Installing python 3.9 with pyenv -pyenv install 3.9 - -# Setting python 3.9 as the default local version -pyenv local 3 - -# Create and enter a virtual environment -python3 -m venv ~/cairo_venv -source ~/cairo_venv/bin/activate - -# Install cairo & its dependencies -pip3 install -r requirements.txt +make deps-macos diff --git a/install-scripts/install-ubuntu.sh b/install-scripts/install-ubuntu.sh index 6a923fb1e4..7141928865 100755 --- a/install-scripts/install-ubuntu.sh +++ b/install-scripts/install-ubuntu.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -ex +PYTHON_VERSION=3.9.15 +PYTHON_MINOR_VERSION=${PYTHON_VERSION%.*} + sudo apt update -y # Install Rust and Cargo @@ -11,7 +14,9 @@ source "$HOME/.cargo/env" rustc --version # Install pyenv dependencies -sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev +sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ + libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \ + xz-utils tk-dev libffi-dev liblzma-dev libgmp3-dev # Install pyenv curl https://pyenv.run | bash @@ -23,17 +28,4 @@ eval "$(pyenv init -)" # Make sure pyenv has been installed correctly pyenv -v -# Installing python 3.9 with pyenv -pyenv install 3.9.16 - -# Setting python 3.9 as the default local version -pyenv local 3.9.16 - -# Create and enter a virtual environment - -python3.9 -m venv ~/cairo_venv -source ~/cairo_venv/bin/activate - -# Install cairo & its dependencies -sudo apt install -y libgmp3-dev -pip3 install -r requirements.txt +make deps diff --git a/install.sh b/install.sh index 8351f432a4..40ebf0c06a 100755 --- a/install.sh +++ b/install.sh @@ -65,15 +65,11 @@ install_linux() { Debian*) run_script "install-scripts/install-debian.sh" ;; *) unsupported_os "linux: $OS" ;; esac - - make deps } install_macos() { print_os "MacOS" run_script install-scripts/install-macos.sh - - make deps-macos } case "$OSTYPE" in