diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml index dec0d74e5..0b1dbe6ab 100644 --- a/.github/workflows/macos.yaml +++ b/.github/workflows/macos.yaml @@ -11,6 +11,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} cancel-in-progress: true +env: + PYTHON_VENV_ROOT: ${{ github.workspace }}/src/python-venv + jobs: build_arm64: # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-14-Readme.md @@ -23,9 +26,10 @@ jobs: with: submodules: 'recursive' - - name: Install pip dependencies - working-directory: ./src + - name: Setup Python run: | + python3 -m venv ${PYTHON_VENV_ROOT} + source ${PYTHON_VENV_ROOT}/bin/activate python3 -m pip install requests - name: Try to restore update_deps cache @@ -38,11 +42,13 @@ jobs: working-directory: ./src # This command uses src/third_party_cache as the download cache. run: | + source ${PYTHON_VENV_ROOT}/bin/activate python3 build_tools/update_deps.py - name: Build Qt working-directory: ./src run: | + source ${PYTHON_VENV_ROOT}/bin/activate python3 build_tools/build_qt.py --release --confirm_license --macos_cpus=arm64 echo "MOZC_QT_PATH=${PWD}/third_party/qt" >> $GITHUB_ENV @@ -69,9 +75,10 @@ jobs: with: submodules: 'recursive' - - name: Install pip dependencies - working-directory: ./src + - name: Setup Python run: | + python3 -m venv ${PYTHON_VENV_ROOT} + source ${PYTHON_VENV_ROOT}/bin/activate python3 -m pip install requests - name: Try to restore update_deps cache @@ -84,11 +91,13 @@ jobs: working-directory: ./src # This command uses src/third_party_cache as the download cache. run: | + source ${PYTHON_VENV_ROOT}/bin/activate python3 build_tools/update_deps.py - name: Build Qt working-directory: ./src run: | + source ${PYTHON_VENV_ROOT}/bin/activate python3 build_tools/build_qt.py --release --confirm_license --macos_cpus=x86_64 echo "MOZC_QT_PATH=${PWD}/third_party/qt" >> $GITHUB_ENV @@ -115,9 +124,10 @@ jobs: with: submodules: 'recursive' - - name: Install pip dependencies - working-directory: ./src + - name: Setup Python run: | + python3 -m venv ${PYTHON_VENV_ROOT} + source ${PYTHON_VENV_ROOT}/bin/activate python3 -m pip install requests - name: Try to restore update_deps cache @@ -130,11 +140,13 @@ jobs: working-directory: ./src # This command uses src/third_party_cache as the download cache. run: | + source ${PYTHON_VENV_ROOT}/bin/activate python3 build_tools/update_deps.py - name: Build Qt working-directory: ./src run: | + source ${PYTHON_VENV_ROOT}/bin/activate python3 build_tools/build_qt.py --release --confirm_license --macos_cpus=x86_64,arm64 echo "MOZC_QT_PATH=${PWD}/third_party/qt" >> $GITHUB_ENV @@ -161,9 +173,10 @@ jobs: with: submodules: 'recursive' - - name: Install pip dependencies - working-directory: ./src + - name: Setup Python run: | + python3 -m venv ${PYTHON_VENV_ROOT} + source ${PYTHON_VENV_ROOT}/bin/activate python3 -m pip install requests - name: Try to restore update_deps cache @@ -176,11 +189,13 @@ jobs: working-directory: ./src # This command uses src/third_party_cache as the download cache. run: | + source ${PYTHON_VENV_ROOT}/bin/activate python3 build_tools/update_deps.py - name: Build Qt working-directory: ./src run: | + source ${PYTHON_VENV_ROOT}/bin/activate python3 build_tools/build_qt.py --release --confirm_license echo "MOZC_QT_PATH=${PWD}/third_party/qt" >> $GITHUB_ENV @@ -201,9 +216,10 @@ jobs: - name: checkout uses: actions/checkout@v4 - - name: Install pip dependencies - working-directory: ./src + - name: Setup Python run: | + python3 -m venv ${PYTHON_VENV_ROOT} + source ${PYTHON_VENV_ROOT}/bin/activate python3 -m pip install requests - name: Try to restore update_deps cache @@ -216,4 +232,5 @@ jobs: working-directory: ./src # This command uses src/third_party_cache as the download cache. run: | + source ${PYTHON_VENV_ROOT}/bin/activate python3 build_tools/update_deps.py --cache_only diff --git a/.gitignore b/.gitignore index 136fd0524..f6b221137 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,10 @@ /src-* /src_* +# Python venv dir used to conform PEP 668 +# https://peps.python.org/pep-0668/ +/src/python-venv + # Mozc build artifacts by Bazel (symbolic links) /src/bazel-bin /src/bazel-out diff --git a/docs/build_mozc_in_osx.md b/docs/build_mozc_in_osx.md index 3a7c23971..8b400083e 100644 --- a/docs/build_mozc_in_osx.md +++ b/docs/build_mozc_in_osx.md @@ -9,11 +9,14 @@ If you are not sure what the following commands do, please check the description and make sure the operations before running them. ``` -python3 -m pip install requests - git clone https://github.com/google/mozc.git cd mozc/src +export PYTHON_VENV_ROOT=${PWD}/python-venv +python3 -m venv ${PYTHON_VENV_ROOT} +source ${PYTHON_VENV_ROOT}/bin/activate +python3 -m pip install requests + python3 build_tools/update_deps.py # CMake is also required to build Qt. @@ -62,6 +65,19 @@ cd mozc/src Hereafter you can do all the operations without changing directory. +### Set up and enable Python virtual environment + +The following commands set up Python virtual environment under `mozc/src/python-venv`. + +``` +export PYTHON_VENV_ROOT=${PWD}/python-venv +python3 -m venv ${PYTHON_VENV_ROOT} +source ${PYTHON_VENV_ROOT}/bin/activate +python3 -m pip install requests +``` + +Using `mozc/src/python-venv` as the virtual environment location is not mandatory. Any other location should also work. + ### Check out additional build dependencies ```