Skip to content

Commit

Permalink
refactor: Rename requirements.in to requirements.txt. (#2619)
Browse files Browse the repository at this point in the history
Rename requirements.in to requirements.txt. It is a more standard way to manage Python dependencies, it can be recognized automatically by some IDEs.

Add environment setup section to README for running hermetic build scripts.
  • Loading branch information
blakeli0 authored Apr 5, 2024
1 parent b19fa33 commit ad55967
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/verify_library_generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
26 changes: 16 additions & 10 deletions library_generation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
```
Expand Down
File renamed without changes.

0 comments on commit ad55967

Please sign in to comment.