mirror of
https://github.com/certbot/certbot.git
synced 2026-06-08 16:22:18 -04:00
Add setuptools-based setup.py & MANIFEST.in
Also move the protoc functionality to setup.py, making it a bit more complicated than usual :)
This commit is contained in:
parent
8db9b8bd1d
commit
7e960672b3
4 changed files with 89 additions and 7 deletions
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
|
|
@ -0,0 +1 @@
|
|||
recursive-include trustify *
|
||||
88
setup.py
Normal file
88
setup.py
Normal file
|
|
@ -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,
|
||||
},
|
||||
)
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
proto = chocolate.proto
|
||||
|
||||
$(proto:.proto=_pb2.py): $(proto)
|
||||
protoc $^ --python_out=.
|
||||
|
||||
clean:
|
||||
rm -f *_pb2.py *_pb2.pyc
|
||||
Loading…
Reference in a new issue