1#! /usr/bin/env python 2# Protocol Buffers - Google's data interchange format 3# Copyright 2008 Google Inc. All rights reserved. 4# 5# Use of this source code is governed by a BSD-style 6# license that can be found in the LICENSE file or at 7# https://developers.google.com/open-source/licenses/bsd 8# 9# See README for usage instructions. 10 11import glob 12import os 13import sys 14 15from setuptools import setup, Extension, find_packages 16 17 18def GetVersion(): 19 """Reads and returns the version from google/protobuf/__init__.py. 20 21 Do not import google.protobuf.__init__ directly, because an installed 22 protobuf library may be loaded instead. 23 24 Returns: 25 The version. 26 """ 27 28 with open(os.path.join('google', 'protobuf', '__init__.py')) as version_file: 29 file_globals = {} 30 exec(version_file.read(), file_globals) # pylint:disable=exec-used 31 return file_globals["__version__"] 32 33 34current_dir = os.path.dirname(os.path.abspath(__file__)) 35extra_link_args = [] 36 37if sys.platform.startswith('win'): 38 extra_link_args = ['-static'] 39 40setup( 41 name='protobuf', 42 version=GetVersion(), 43 description='Protocol Buffers', 44 download_url='https://github.com/protocolbuffers/protobuf/releases', 45 long_description="Protocol Buffers are Google's data interchange format", 46 url='https://developers.google.com/protocol-buffers/', 47 project_urls={ 48 'Source': 'https://github.com/protocolbuffers/protobuf', 49 }, 50 maintainer='protobuf@googlegroups.com', 51 maintainer_email='protobuf@googlegroups.com', 52 license='BSD-3-Clause', 53 classifiers=[ 54 'Programming Language :: Python', 55 'Programming Language :: Python :: 3', 56 'Programming Language :: Python :: 3.8', 57 'Programming Language :: Python :: 3.9', 58 'Programming Language :: Python :: 3.10', 59 'Programming Language :: Python :: 3.11', 60 'Programming Language :: Python :: 3.12', 61 ], 62 namespace_packages=['google'], 63 packages=find_packages(), 64 install_requires=[], 65 ext_modules=[ 66 Extension( 67 'google._upb._message', 68 glob.glob('google/protobuf/*.c') 69 + glob.glob('python/*.c') 70 + glob.glob('upb/**/*.c', recursive=True) 71 + glob.glob('utf8_range/*.c'), 72 include_dirs=[current_dir, os.path.join(current_dir, 'utf8_range')], 73 language='c', 74 extra_link_args=extra_link_args, 75 ) 76 ], 77 python_requires='>=3.8', 78) 79