diff --git a/.cloudbuild/library_generation/library_generation.Dockerfile b/.cloudbuild/library_generation/library_generation.Dockerfile index 4b3b1f4b1c..09d23a106b 100644 --- a/.cloudbuild/library_generation/library_generation.Dockerfile +++ b/.cloudbuild/library_generation/library_generation.Dockerfile @@ -26,7 +26,7 @@ RUN rm $(which python3) RUN ln -s $(which python3.11) /usr/local/bin/python RUN ln -s $(which python3.11) /usr/local/bin/python3 RUN python -m pip install --upgrade pip -RUN cd /src && python -m pip install -r requirements.in +RUN cd /src && python -m pip install -r requirements.txt RUN cd /src && python -m pip install . # set dummy git credentials for empty commit used in postprocessing diff --git a/.github/workflows/verify_library_generation.yaml b/.github/workflows/verify_library_generation.yaml index ca308461c0..c51f8ed7b0 100644 --- a/.github/workflows/verify_library_generation.yaml +++ b/.github/workflows/verify_library_generation.yaml @@ -10,17 +10,9 @@ on: name: verify_library_generation jobs: integration_tests: - strategy: - matrix: - java: [ 11 ] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - uses: actions/setup-java@v4 - with: - java-version: ${{ matrix.java }} - distribution: temurin - cache: maven - uses: actions/setup-python@v5 with: python-version: 3.11 @@ -41,7 +33,7 @@ jobs: run: | set -ex pushd library_generation - pip install -r requirements.in + pip install -r requirements.txt pip install . popd - name: Run integration tests @@ -71,7 +63,7 @@ jobs: run: | set -ex pushd library_generation - pip install -r requirements.in + pip install -r requirements.txt popd - name: install synthtool shell: bash @@ -115,7 +107,7 @@ jobs: run: | set -ex pushd library_generation - pip install -r requirements.in + pip install -r requirements.txt popd - name: Lint shell: bash diff --git a/library_generation/README.md b/library_generation/README.md index 364ec6b511..04da9fda03 100644 --- a/library_generation/README.md +++ b/library_generation/README.md @@ -10,6 +10,8 @@ google-cloud-java) from a configuration file. - Java runtime environment (8 or above) - Apache Maven (used in formatting source code) - Python (3.11.6 or above) +- Docker +- Git ## Prerequisite @@ -188,22 +190,26 @@ libraries: - proto_path: google/cloud/asset/v1p7beta1 ``` +# Local Environment Setup before running `entry_point.py` + +1. Assuming Python 3 is installed, follow official guide from [Python.org](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments) to create a virtual environment. The virtual environment can be installed to any folder, usually it is recommended to be installed under the root folder of the project(`sdk-platform-java` in this case). +2. Assuming the virtual environment is installed under `sdk-platform-java`. Run the following command under the root folder of `sdk-platform-java` to install the dependencies of `library_generation` +```bash +python -m pip install -r library_generation/requirements.txt +``` +3. Run the following command to install `library_generation` as a module, which allows the `library_generation` module to be imported from anywhere +```bash +python -m pip install library_generation/ +``` + ## An example to generate a repository using `entry_point.py` ```bash -# install python module (allows the `library_generation` module to be imported from anywhere) -python -m pip install -r library_generation/requirements.in -# install library_generation module -python -m pip install library_generation -# generate the repository -python -m library_generation/entry_point.py generate \ +python library_generation/entry_point.py generate \ --baseline-generation-config=/path/to/baseline_config_file \ --current-generation-config=/path/to/current_config_file \ ---repository-path=/path/to/repository +--repository-path=path/to/repository ``` - -## An example of generated repository using `entry_point.py` - If you run `entry_point.py` with the example [configuration](#an-example-of-generation-configuration) shown above, the repository structure is: ``` diff --git a/library_generation/requirements.in b/library_generation/requirements.txt similarity index 100% rename from library_generation/requirements.in rename to library_generation/requirements.txt