From 16d8413619289e178b9350e8296f2842a4322809 Mon Sep 17 00:00:00 2001 From: Charles Engelke Date: Tue, 7 Feb 2023 16:10:27 -0800 Subject: [PATCH] fix: Final touches (#151) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: build and doc fixes * fix: merging dev versions * fix: typos * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix: restore overwritten setup.cfg * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix: remove unneded steps * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix: setup is at root now * fix: restore deleted content * fix: restore deleted content --------- Co-authored-by: Owl Bot --- .github/workflows/generate.yaml | 4 +- .github/workflows/test_generation.yaml | 4 +- BUILDING.md | 44 +++++++++++++++++++++ pyproject.toml | 2 +- scripts/generate-from-proto.py | 15 +++++++- setup.cfg | 53 +++++++++++++++++--------- tests/requirements.txt | 1 + 7 files changed, 98 insertions(+), 25 deletions(-) create mode 100644 BUILDING.md create mode 100644 tests/requirements.txt diff --git a/.github/workflows/generate.yaml b/.github/workflows/generate.yaml index 830c11f..6e73cf1 100644 --- a/.github/workflows/generate.yaml +++ b/.github/workflows/generate.yaml @@ -58,8 +58,8 @@ jobs: env: GOOGLE_EVENTS_TESTDATA: ../${{env.DATA_SOURCE_CHECKOUT_PATH}}/testdata run: | - pip install -r requirements-dev.txt - pip install ./src + pip install . + pip install -r ./tests/requirements.txt pytest -v . - name: View generator output diff --git a/.github/workflows/test_generation.yaml b/.github/workflows/test_generation.yaml index 5455c4c..de613da 100644 --- a/.github/workflows/test_generation.yaml +++ b/.github/workflows/test_generation.yaml @@ -65,8 +65,8 @@ jobs: env: GOOGLE_EVENTS_TESTDATA: ../${{env.DATA_SOURCE_CHECKOUT_PATH}}/testdata run: | - pip install -r requirements-dev.txt - pip install ./src + pip install . + pip install -r ./tests/requirements.txt pytest -v . - name: View generator output diff --git a/BUILDING.md b/BUILDING.md new file mode 100644 index 0000000..df7a3ab --- /dev/null +++ b/BUILDING.md @@ -0,0 +1,44 @@ +# Building the google-events Python library + +## Installing the current version + +The library source in this repository can be installed and used as is: + +1. Clone or download the repository contents +1. Instantiate a virtual Python environment if desired. +1. In a shell, change to the repository root. +1. Install with `pip install -e .` + +## Building a distribution + +A Python wheel can be created for the current contents of this repository as +follows: + +1. Clone or download the repository contents +1. Instantiate a virtual Python environment if desired. +1. In a shell, change to the repository root. +1. Install the standard *build* library: + `pip install --upgrade build` +1. Build the distributions(s): + `python -m build .` +1. The *dist* folder will contain distributable packages in those formats +available to your installation. + +## Updating the library + +Whenever the *googleapis/cloudevents* proto definitions change, the matching +Python *google-events* library can be updated to match, as follows: + +1. Clone or download the repository contents +1. Instantiate a virtual Python environment if desired. +1. In a shell, change to the repository root, then the *scripts* folder: + `cd scripts` +1. Install the required libraries to run the generator script: + `pip install -r requirements.txt` +1. For a test run, run the script, specifying a folder of your choice for the output: + `python generate-from-proto.py -o [OUTPUT_DIR]` + and examine the contents of *[OUTPUT_DIR]*. +1. Update the library by having the generator script replace the repository src folder: + `python generate-from-proto.py -o ../src` + +You can install or distribute the updated library with the previous instructions. diff --git a/pyproject.toml b/pyproject.toml index 2c0e412..6ee1c92 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] requires = [ - "setuptools >= 40.9.0", + "setuptools >= 61.0", ] build-backend = "setuptools.build_meta" diff --git a/scripts/generate-from-proto.py b/scripts/generate-from-proto.py index b3c3178..b3b84ed 100644 --- a/scripts/generate-from-proto.py +++ b/scripts/generate-from-proto.py @@ -130,8 +130,19 @@ def generate_module(module_dir, proto_repo, branch, do_not_confirm_actions): print(f"Fetching protobuf repo from {proto_repo}") std_proto_path = fetch_repo("protocolbuffers/protobuf", "main", tempdir) - generate_code_for_protos(proto_path, std_proto_path, module_path) - generate_code_for_dependencies(proto_path, std_proto_path, module_path) + output_path = os.path.join(tempdir, "output_path") + os.mkdir(output_path) + + generate_code_for_protos(proto_path, std_proto_path, output_path) + generate_code_for_dependencies(proto_path, std_proto_path, output_path) + + os.mkdir(os.path.join(module_path, "google")) + + shutil.move( + os.path.join(output_path, "google", "events"), + os.path.join(module_path, "google"), + ) + return True diff --git a/setup.cfg b/setup.cfg index c3a2b39..ca5d969 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,19 +1,36 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +[metadata] +name = google.events +version = 0.3.0 +author = Google LLC +author_email = googleapis-packages@google.com +description = Google Cloudevents library +long_description = file: README.md +url = url +license = Apache 2.0 +platforms = Posix, MacOS X, Windows +classifiers = + Intended Audience :: Developers + License :: OSI Approved :: Apache Software License + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Operating System :: OS Independent + Topic :: Internet -# Generated by synthtool. DO NOT EDIT! -[bdist_wheel] -universal = 1 + +[options] +include_package_data = True +package_dir = + =src +packages = find_namespace: +python_requires = >=3.7 +install_requires = + proto-plus >= 1.22.0 + protobuf >= 4.21.5 + +[options.packages.find] +where=src diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000..805eb2a --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1 @@ +pytest==7.2.1