Add devel/py-protobuf-compiler

Python protobuf compiler can be used to compile collections protobuf files
and create a single package distribution suitable for installing with pip.

WWW: https://github.com/netsaj/python-protobuf-compiler
This commit is contained in:
Mateusz Piotrowski 2021-02-24 10:39:04 +00:00
parent 997bdb96cb
commit b7aef02ff7
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=566466
6 changed files with 100 additions and 0 deletions

View file

@ -4837,6 +4837,7 @@
SUBDIR += py-proselint
SUBDIR += py-proto-plus
SUBDIR += py-protobuf
SUBDIR += py-protobuf-compiler
SUBDIR += py-proxmoxer
SUBDIR += py-ptable
SUBDIR += py-ptpython

View file

@ -0,0 +1,49 @@
# $FreeBSD$
PORTNAME= protobuf-compiler
DISTVERSION= 1.0.20
CATEGORIES= devel python
MASTER_SITES= CHEESESHOP
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
DISTNAME= ${PORTNAME:S/-/_/}-${DISTVERSION}
DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
MAINTAINER= 0mp@FreeBSD.org
COMMENT= Compile all protobuf files and create package distributions
LICENSE= MIT
LICENSE_FILE= ${WRKSRC_tests}/LICENSE
BUILD_DEPENDS= ${_MY_DEPENDS}
RUN_DEPENDS= ${_MY_DEPENDS}
USES= python:3.6+ shebangfix
USE_GITHUB= nodefault
GH_TUPLE= netsaj:python-${PORTNAME}:7cb32ab8188cbfecb91034cbf7803394ed1c25b6:tests
USE_PYTHON= autoplist concurrent distutils
SHEBANG_GLOB= *.py
TEST_ENV= PYTHONPATH="${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}"
NO_ARCH= yes
TEST_WRKSRC= ${WRKSRC_tests}
_MY_DEPENDS= ${PYTHON_PKGNAMEPREFIX}bleach>=2.1.0:www/py-bleach@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}colorama>=0.3.3:devel/py-colorama@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}grpcio-tools>=1.18.0:devel/py-grpcio-tools@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}grpcio>=1.18.0:devel/py-grpcio@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}termcolor>=1.1.0:devel/py-termcolor@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}tqdm>=4.31.1:misc/py-tqdm@${PY_FLAVOR}
post-patch:
${REINPLACE_CMD} 's|%%PYTHON_CMD%%|${PYTHON_CMD}|g' \
${WRKSRC}/protobuf_compiler/main.py
do-test:
# Loosely based on the upstream test_protopy.py.
${RM} -r ${TEST_WRKSRC}/run_test
cd ${TEST_WRKSRC} && ${SETENV} ${TEST_ENV} \
${PYTHON_CMD} ${STAGEDIR}${PREFIX}/bin/protopy \
-o ./run_test -d ./test -p mytesting -v 1.0.1
${TEST} -e ${TEST_WRKSRC}/run_test/mytesting-1.0.1.tar.gz
.include <bsd.port.mk>

View file

@ -0,0 +1,5 @@
TIMESTAMP = 1614156744
SHA256 (protobuf_compiler-1.0.20.tar.gz) = ac8daa7187fb9cac7752008368b79d8d8e44dd1b154423fa7afd227a31d062f6
SIZE (protobuf_compiler-1.0.20.tar.gz) = 5296
SHA256 (netsaj-python-protobuf-compiler-7cb32ab8188cbfecb91034cbf7803394ed1c25b6_GH0.tar.gz) = 72b8f59ef6ee9999701b09b2611fc3d79d7c500821fbb2edc4e8a1d4db864771
SIZE (netsaj-python-protobuf-compiler-7cb32ab8188cbfecb91034cbf7803394ed1c25b6_GH0.tar.gz) = 7499

View file

@ -0,0 +1,20 @@
--- protobuf_compiler/main.py.orig 2021-02-24 09:06:33 UTC
+++ protobuf_compiler/main.py
@@ -100,7 +100,7 @@ def main():
for f in files:
file_name = f.split(os.path.sep)[-1]
folder = f.replace(file_name,"").replace(input_dir + os.path.sep, "")
- command = "python3 -m grpc_tools.protoc -I. \
+ command = "%%PYTHON_CMD%% -m grpc_tools.protoc -I. \
--proto_path=" + input_dir + " \
--python_out=" + os.path.join(output_dir, package_name) + " \
--grpc_python_out=" + os.path.join(output_dir, package_name) + " \
@@ -130,7 +130,7 @@ setup(
description=''
)
""")
- command = "cd " + os.path.join(output_dir, package_name) + " && python3 setup.py sdist"
+ command = "cd " + os.path.join(output_dir, package_name) + " && %%PYTHON_CMD%% setup.py sdist"
out = os.system(command)
# print(out)
if args.repository != '':

View file

@ -0,0 +1,21 @@
--- setup.py.orig 2021-02-24 08:56:12 UTC
+++ setup.py
@@ -24,12 +24,12 @@ setup(
"Programming Language :: Python :: 3.6",
],
install_requires=[
- 'grpcio==1.18.0',
- 'grpcio-tools==1.18.0',
- 'colorama==0.3.3',
- 'termcolor==1.1.0',
- 'tqdm==4.31.1',
- 'bleach==2.1.0'
+ 'grpcio>=1.18.0',
+ 'grpcio-tools>=1.18.0',
+ 'colorama>=0.3.3',
+ 'termcolor>=1.1.0',
+ 'tqdm>=4.31.1',
+ 'bleach>=2.1.0'
],
entry_points={
'console_scripts': [

View file

@ -0,0 +1,4 @@
Python protobuf compiler can be used to compile collections protobuf files and
create a single package distribution suitable for installing with pip.
WWW: https://github.com/netsaj/python-protobuf-compiler