parent
3bac8780cb
commit
9880136636
7 changed files with 258 additions and 6 deletions
@ -0,0 +1,100 @@ |
||||
name: Python Tests |
||||
|
||||
on: |
||||
push: |
||||
branches: |
||||
- main |
||||
- '[0-9]+.x' |
||||
pull_request: |
||||
branches: |
||||
- main |
||||
- '[0-9]+.x' |
||||
workflow_dispatch: |
||||
|
||||
jobs: |
||||
build_wheels: |
||||
name: Build Wheels |
||||
runs-on: ubuntu-latest |
||||
if: ${{ github.event.pull_request.head.repo.full_name == 'protocolbuffers/upb' }} |
||||
env: |
||||
DOCKER_IMAGE: gcr.io/protobuf-build/bazel/linux@sha256:9dba7773926bb6dce839de098948055c9e80260d7470a7fefb94b6a4fed363ba |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v2 |
||||
- name: Set up Cloud SDK |
||||
uses: google-github-actions/auth@v0 |
||||
with: |
||||
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }} |
||||
export_environment_variables: true |
||||
- name: Use gcloud CLI |
||||
run: gcloud info |
||||
- name: Configure Docker |
||||
run: gcloud auth configure-docker |
||||
- name: Pull Docker Image |
||||
run: docker pull $DOCKER_IMAGE |
||||
- name: Build Wheels |
||||
run: cd ${{ github.workspace }} && docker run -e GOOGLE_APPLICATION_CREDENTIALS=/workspace/$(basename $GOOGLE_APPLICATION_CREDENTIALS) -v$PWD:/workspace $DOCKER_IMAGE build $BAZEL_CACHE --crosstool_top=@com_google_protobuf//toolchain:clang_suite --symlink_prefix=/ -c dbg python/dist:source_wheel python/dist:test_wheel |
||||
- name: Move Wheels |
||||
run: mkdir wheels && find _build/out -name 'protobuf*.whl' -o -name 'protobuf*.tar.gz' -exec mv '{}' wheels ';' |
||||
- uses: actions/upload-artifact@v3 |
||||
with: |
||||
name: python-wheels |
||||
path: wheels/ |
||||
|
||||
test_wheels: |
||||
name: Test Wheels |
||||
needs: build_wheels |
||||
strategy: |
||||
fail-fast: false # Don't cancel all jobs if one fails. |
||||
matrix: |
||||
include: |
||||
# Test on all supported operating systems and using the oldest and |
||||
# newest versions of python we support |
||||
- { os: ubuntu-18.04, python-version: "3.7", architecture: x64 } |
||||
- { os: ubuntu-20.04, python-version: "3.10", architecture: x64 } |
||||
- { os: macos-11, python-version: "3.7", architecture: x64 } |
||||
- { os: macos-12, python-version: "3.10", architecture: x64 } |
||||
- { os: windows-2019, python-version: "3.7", architecture: x86 } |
||||
- { os: windows-2019, python-version: "3.10", architecture: x86 } |
||||
- { os: windows-2019, python-version: "3.7", architecture: x64 } |
||||
- { os: windows-2019, python-version: "3.10", architecture: x64 } |
||||
runs-on: ${{ matrix.os }} |
||||
defaults: |
||||
run: |
||||
shell: bash |
||||
steps: |
||||
- name: Download Wheels |
||||
uses: actions/download-artifact@v3 |
||||
with: |
||||
name: python-wheels |
||||
path: wheels |
||||
- name: Extract tar |
||||
run: tar -xzvf *.tar.gz |
||||
- uses: actions/setup-python@v2 |
||||
with: |
||||
python-version: ${{ matrix.python-version }} |
||||
architecture: ${{ matrix.architecture }} |
||||
- name: Setup Python venv |
||||
run: | |
||||
python -m pip install --upgrade pip |
||||
python -m venv env |
||||
# Windows uses 'Scripts' instead of 'bin' |
||||
source env/bin/activate || source env/Scripts/activate |
||||
echo "VIRTUAL ENV:" $VIRTUAL_ENV |
||||
- name: Install tzdata |
||||
run: pip install tzdata |
||||
# Only needed on Windows, Linux ships with tzdata. |
||||
if: ${{ contains(matrix.os, 'windows') }} |
||||
- name: Install numpy |
||||
run: pip install numpy |
||||
- name: Install Protobuf Wheels |
||||
run: pip install -vvv --no-index --find-links wheels protobuf protobuftests |
||||
- name: Test that module is importable |
||||
run: python -v -c 'from google._upb import _message; assert "google._upb._message.MessageMeta" in str(_message.MessageMeta)' |
||||
if: ${{ !matrix.pure_python }} |
||||
- name: Run the unit tests |
||||
run: | |
||||
TESTS=$(pip show -f protobuftests | grep pb_unit_tests.*py$ | sed 's,/,.,g' | sed 's,\\,.,g' | sed -E 's,.py$,,g') |
||||
for test in $TESTS; do |
||||
python -m unittest -v $test |
||||
done |
@ -0,0 +1,84 @@ |
||||
#! /usr/bin/env python |
||||
# Protocol Buffers - Google's data interchange format |
||||
# Copyright 2008 Google Inc. All rights reserved. |
||||
# https://developers.google.com/protocol-buffers/ |
||||
# |
||||
# Redistribution and use in source and binary forms, with or without |
||||
# modification, are permitted provided that the following conditions are |
||||
# met: |
||||
# |
||||
# * Redistributions of source code must retain the above copyright |
||||
# notice, this list of conditions and the following disclaimer. |
||||
# * Redistributions in binary form must reproduce the above |
||||
# copyright notice, this list of conditions and the following disclaimer |
||||
# in the documentation and/or other materials provided with the |
||||
# distribution. |
||||
# * Neither the name of Google Inc. nor the names of its |
||||
# contributors may be used to endorse or promote products derived from |
||||
# this software without specific prior written permission. |
||||
# |
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
# |
||||
# See README for usage instructions. |
||||
|
||||
import glob |
||||
import os |
||||
|
||||
# We must use setuptools, not distutils, because we need to use the |
||||
# namespace_packages option for the "google" package. |
||||
from setuptools import setup, Extension, find_packages |
||||
|
||||
def GetVersion(): |
||||
"""Reads and returns the version from google/protobuf/__init__.py. |
||||
|
||||
Do not import google.protobuf.__init__ directly, because an installed |
||||
protobuf library may be loaded instead. |
||||
|
||||
Returns: |
||||
The version. |
||||
""" |
||||
|
||||
with open(os.path.join('google', 'protobuf', '__init__.py')) as version_file: |
||||
exec(version_file.read(), globals()) # pylint:disable=exec-used |
||||
return __version__ # pylint:disable=undefined-variable |
||||
|
||||
# Keep this list of dependencies in sync with tox.ini. |
||||
install_requires = [] |
||||
|
||||
setup( |
||||
name='protobuf', |
||||
version=GetVersion(), |
||||
description='Protocol Buffers', |
||||
download_url='https://github.com/protocolbuffers/protobuf/releases', |
||||
long_description="Protocol Buffers are Google's data interchange format", |
||||
url='https://developers.google.com/protocol-buffers/', |
||||
project_urls={ |
||||
'Source': 'https://github.com/protocolbuffers/protobuf', |
||||
}, |
||||
maintainer='protobuf@googlegroups.com', |
||||
maintainer_email='protobuf@googlegroups.com', |
||||
license='BSD-3-Clause', |
||||
classifiers=[ |
||||
'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', |
||||
], |
||||
namespace_packages=['google'], |
||||
packages=find_packages(), |
||||
install_requires=install_requires, |
||||
ext_modules= [Extension('google.protobuf.pyext._message', glob.glob('google/protobuf/pyext/*.c'))], |
||||
python_requires='>=3.7', |
||||
) |
Loading…
Reference in new issue