PROJECT_MOVED -> https://lab.nexedi.com/nexedi/re6stnet
[re6stnet.git] / setup.py
1 """Resilient, Scalable, IPv6 Network
2 """
3 import os, stat
4 from distutils.command.build_scripts import first_line_re
5 from setuptools import setup, find_packages
6 from setuptools.command import sdist as _sdist, build_py as _build_py
7 from distutils import log
8
9 version = {"__file__": "re6st/version.py"}
10 execfile(version["__file__"], version)
11
12 def copy_file(self, infile, outfile, *args, **kw):
13 if infile == version["__file__"]:
14 if not self.dry_run:
15 log.info("generating %s -> %s", infile, outfile)
16 with open(outfile, "wb") as f:
17 for x in sorted(version.iteritems()):
18 if not x[0].startswith("_"):
19 f.write("%s = %r\n" % x)
20 return outfile, 1
21 elif isinstance(self, build_py) and \
22 os.stat(infile).st_mode & stat.S_IEXEC:
23 # Adjust interpreter of OpenVPN hooks.
24 with open(infile) as src:
25 first_line = src.readline()
26 m = first_line_re.match(first_line)
27 if m and not self.dry_run:
28 log.info("copying and adjusting %s -> %s", infile, outfile)
29 executable = self.distribution.command_obj['build'].executable
30 patched = "#!%s%s\n" % (executable, m.group(1) or '')
31 patched += src.read()
32 dst = os.open(outfile, os.O_CREAT | os.O_WRONLY | os.O_TRUNC)
33 try:
34 os.write(dst, patched)
35 finally:
36 os.close(dst)
37 return outfile, 1
38 cls, = self.__class__.__bases__
39 return cls.copy_file(self, infile, outfile, *args, **kw)
40
41 class build_py(_build_py.build_py):
42 copy_file = copy_file
43
44 class sdist(_sdist.sdist):
45 copy_file = copy_file
46
47 classifiers = """\
48 Environment :: Console
49 License :: OSI Approved :: GNU General Public License (GPL)
50 Natural Language :: English
51 Operating System :: POSIX :: Linux
52 Programming Language :: Python :: 2.6
53 Programming Language :: Python :: 2.7
54 Topic :: Internet
55 Topic :: System :: Networking
56 """
57
58 egg_version = "0.%(revision)s" % version
59
60 git_rev = """
61
62 Git Revision: %s == %s
63 """ % (egg_version, version["short"])
64
65 setup(
66 name = 're6stnet',
67 version = egg_version,
68 description = __doc__.strip(),
69 author = 'Nexedi',
70 author_email = 're6stnet@erp5.org',
71 url = 'http://re6st.net',
72 license = 'GPL 2+',
73 platforms = ["any"],
74 classifiers=classifiers.splitlines(),
75 long_description = ".. contents::\n\n" + open('README').read()
76 + "\n" + open('CHANGES').read() + git_rev,
77 packages = find_packages(),
78 entry_points = {
79 'console_scripts': [
80 're6st-conf=re6st.cli.conf:main',
81 're6stnet=re6st.cli.node:main',
82 're6st-registry=re6st.cli.registry:main',
83 ],
84 },
85 package_data = {
86 're6st': [
87 'ovpn-server',
88 'ovpn-client',
89 ],
90 },
91 # BBB: use MANIFEST.in only so that egg_info works with very old setuptools
92 include_package_data = True,
93 install_requires = ['pyOpenSSL >= 0.13', 'miniupnpc'],
94 #dependency_links = [
95 # "http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.7.20120714.tar.gz#egg=miniupnpc-1.7",
96 # ],
97 zip_safe = False,
98 cmdclass=dict(build_py=build_py, sdist=sdist),
99 )