diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 000000000..47ce7c6b6 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +recursive-include trustify * diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..2bc387f63 --- /dev/null +++ b/setup.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python + +from setuptools import setup +from setuptools.command.build_py import build_py +from setuptools import Command +from distutils.errors import DistutilsPlatformError +import os +import subprocess +from distutils.spawn import find_executable + +proto = [ 'trustify/protocol/chocolate.proto' ] + +class build_py_with_protobuf(build_py): + protoc = find_executable("protoc") + + def run_protoc(self, proto): + try: + proc = subprocess.Popen( + [self.protoc, '--python_out', '.', proto], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + except OSError, ex: + if ex.errno == errno.ENOENT: + print ("Could not find protoc command. Make sure protobuf is " + "installed and your PATH environment is set.") + raise DistutilsPlatformError("Failed to generate protbuf " + "files with protoc.") + else: + raise + out = proc.communicate()[0] + result = proc.wait() + if result != 0: + print "Error during protobuf files generation with protoc:" + print out + raise DistutilsPlatformError("Failed to generate protobuf " + "files with protoc.") + + def run(self): + for p in proto: + self.run_protoc(p) + + build_py.run(self) + +class clean_with_protobuf(Command): + user_options = [("all", "a", "")] + + def initialize_options(self): + self.all = True + pass + + def finalize_options(self): + pass + + def run(self): + for p in proto: + pb2 = p.replace(".proto", "_pb2.py") + if not os.path.exists(pb2): + continue + os.unlink(pb2) + +setup( + name="trustify", + version="0.1", + description="Trustify", + author="Trustify project", + license="", + url="https://trustify.net/", + packages=[ + 'trustify', + 'trustify.protocol', + 'trustify.client', + ], + install_requires=[ + #'dialog', + 'protobuf', + 'python-augeas', + 'pycrypto', + 'M2Crypto', + ], + entry_points={ + 'console_scripts': [ + 'trustify = trustify.client.client:authenticate' + ] + }, + cmdclass={ + 'build_py': build_py_with_protobuf, + 'clean': clean_with_protobuf, + }, +) diff --git a/client.py b/trustify.py similarity index 100% rename from client.py rename to trustify.py diff --git a/trustify/protocol/Makefile b/trustify/protocol/Makefile deleted file mode 100644 index 3eaaebd8e..000000000 --- a/trustify/protocol/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -proto = chocolate.proto - -$(proto:.proto=_pb2.py): $(proto) - protoc $^ --python_out=. - -clean: - rm -f *_pb2.py *_pb2.pyc