From 22ed5db6038c08c21ccebb3ebe4854a63deff15c Mon Sep 17 00:00:00 2001 From: Valerio Versace Date: Tue, 11 Jun 2019 05:01:05 +0200 Subject: [PATCH] fixed basic setup for CLI, added setup and requirements for namespace package, moved version identifier --- packages/snet_cli/.gitignore | 1 + .../snet_cli/scripts/package-namespace-pip | 3 + packages/snet_cli/setup-namespace.py | 68 +++++++++++++++++++ packages/snet_cli/setup.py | 2 +- .../snet_cli/{ => snet}/snet_cli/version.py | 0 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100755 packages/snet_cli/scripts/package-namespace-pip create mode 100644 packages/snet_cli/setup-namespace.py rename packages/snet_cli/{ => snet}/snet_cli/version.py (100%) diff --git a/packages/snet_cli/.gitignore b/packages/snet_cli/.gitignore index e86739fb..0bf999a7 100644 --- a/packages/snet_cli/.gitignore +++ b/packages/snet_cli/.gitignore @@ -1,5 +1,6 @@ venv/ snet_cli.egg-info/ +snet.snet_cli.egg-info/ snet/snet_cli/resources/contracts/abi snet/snet_cli/resources/contracts/networks snet/snet_cli/resources/node_modules diff --git a/packages/snet_cli/scripts/package-namespace-pip b/packages/snet_cli/scripts/package-namespace-pip new file mode 100755 index 00000000..086a88f2 --- /dev/null +++ b/packages/snet_cli/scripts/package-namespace-pip @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +python3.6 setup-namespace.py sdist bdist_wheel diff --git a/packages/snet_cli/setup-namespace.py b/packages/snet_cli/setup-namespace.py new file mode 100644 index 00000000..0fec53da --- /dev/null +++ b/packages/snet_cli/setup-namespace.py @@ -0,0 +1,68 @@ +from setuptools import setup, find_namespace_packages +from setuptools.command.develop import develop as _develop +from setuptools.command.install import install as _install + + +def install_and_compile_proto(): + import snet.snet_cli + from snet.snet_cli.utils import compile_proto as compile_proto + from pathlib import Path + proto_dir = Path(__file__).absolute().parent.joinpath("snet", "snet_cli", "resources", "proto") + dest_dir = Path(snet.snet_cli.__file__).absolute().parent.joinpath("resources", "proto") + print(proto_dir, "->", dest_dir) + for fn in proto_dir.glob('*.proto'): + print("Compiling protobuf", fn) + compile_proto(proto_dir, dest_dir, proto_file=fn) + + +class develop(_develop): + """Post-installation for development mode.""" + + def run(self): + _develop.run(self) + self.execute(install_and_compile_proto, (), msg="Compile protocol buffers") + + +class install(_install): + """Post-installation for installation mode.""" + + def run(self): + _install.run(self) + self.execute(install_and_compile_proto, (), msg="Compile protocol buffers") + + +version_dict = {} +with open("./snet/snet_cli/version.py") as fp: + exec(fp.read(), version_dict) +setup( + name='snet.snet-cli', + version=version_dict['__version__'], + packages=find_namespace_packages(include=['snet.*']), + namespace_packages=['snet'], + url='https://github.com/singnet/snet-cli', + license='MIT', + author='SingularityNET Foundation', + author_email='info@singularitynet.io', + description='SingularityNET CLI standalone namespace package', + python_requires='>=3.6', + install_requires=[ + 'grpcio-tools==1.19.0', + 'jsonrpcclient==2.5.2', + 'web3==4.8.3', + 'mnemonic==0.18', + 'pycoin>=0.80', + 'rlp==1.0.1', + 'pyyaml>=4.2b1', + 'ipfsapi==0.4.2.post1', + 'rfc3986==1.1.0', + 'pymultihash==0.8.2', + 'base58==1.0.2', + 'argcomplete>=1.9.4', + 'grpcio-health-checking==1.19.0' + ], + cmdclass={ + 'develop': develop, + 'install': install + }, + include_package_data=True +) diff --git a/packages/snet_cli/setup.py b/packages/snet_cli/setup.py index fd0fa2d4..faca0963 100644 --- a/packages/snet_cli/setup.py +++ b/packages/snet_cli/setup.py @@ -32,7 +32,7 @@ def run(self): version_dict = {} -with open("./snet_cli/version.py") as fp: +with open("./snet/snet_cli/version.py") as fp: exec(fp.read(), version_dict) setup( name='snet-cli', diff --git a/packages/snet_cli/snet_cli/version.py b/packages/snet_cli/snet/snet_cli/version.py similarity index 100% rename from packages/snet_cli/snet_cli/version.py rename to packages/snet_cli/snet/snet_cli/version.py