# Path: FluidNexus/BuildManpage.py
# class build_manpage(Command):
#     """Class to build a manpage from our help and distutils info.
# 
#     From http://andialbrecht.wordpress.com/2009/03/17/creating-a-man-page-with-distutils-and-optparse/."""
# 
#     description = "Generate man page."
# 
#     user_options = [
#         ("output=", "o", "output file"),
#         ("parser=", None, "module path to optparse (e.g. mymod:func)"),
#     ]
# 
#     def initialize_options(self):
#         self.output = None
#         self.parser = None
# 
#     def finalize_options(self):
#         if (self.output is None):
#             raise DistutilsOptionError("'output' option is required")
#         if self.parser is None:
#             raise DistutilsOptionError("'parser' option is required")
# 
#         mod_name, func_name = self.parser.split(":")
# 
#         fromlist = mod_name.split(".")
# 
#         try:
#             mod = __import__(mod_name, fromlist = fromlist)
#             self._parser = getattr(mod, func_name)()
#         except ImportError, err:
#             raise
# 
#         self._parser.formatter = ManPageFormatter()
#         self._parser.formatter.set_parser(self._parser)
#         self.announce("Writing man page %s" % self.output)
#         self._today = datetime.date.today()
# 
#     def _markup(self, txt):
#         return txt.replace("-", "\\-")
# 
#     def _write_header(self):
#         appname = self.distribution.get_name()
# 
#         ret = []
#         ret.append(".TH %s 1 %s\n" % (self._markup(appname),
#                                       self._today.strftime("%Y\\-%m\\-%d")))
#         description = self.distribution.get_description()
#         if description:
#             name = self._markup("%s - %s" % (self._markup(appname),
#                                              description.splitlines()[0]))
#         else:
#             name = self._markup(appname)
# 
#         ret.append(".SH NAME\n%s\n" % name)
# 
#         synopsis = self._parser.get_usage()
#         if synopsis:
#             synopsis = synopsis.replace("setup.py", "")
#             ret.append(".SH SYNOPSIS\n.B %s %s\n" % (self._markup(appname),
#                                                       synopsis))
# 
#         #long_desc = self.distribution.get_long_description()
#         long_desc = self._parser.get_description()
#         if long_desc:
#             ret.append(".SH DESCRIPTION\n%s\n" % self._markup(long_desc))
# 
#         return "".join(ret)
# 
#     def _write_options(self):
#         ret = [".SH OPTIONS\n"]
#         ret.append(self._parser.format_option_help())
#         return "".join(ret)
# 
#     def _write_footer(self):
#         ret = []
#         appname = self.distribution.get_name()
#         author = "%s <%s>" % (self.distribution.get_author(),
#                               self.distribution.get_author_email())
#         ret.append((".SH AUTHORS\n.B %s was written by %s.\n" % (self._markup(appname), self._markup(author))))
#         homepage = self.distribution.get_url()
#         ret.append((".SH DISTRIBUTION\nThe latest version of %s may be downloaded from\n.UR %s\n.UE\n" % (self._markup(appname), self._markup(homepage),)))
#         return "".join(ret)
# 
#     def run(self):
#         manpage = []
#         manpage.append(self._write_header())
#         manpage.append(self._write_options())
#         manpage.append(self._write_footer())
#         stream = open(self.output, "w")
#         stream.write("".join(manpage))
#         stream.close()


import glob
import os
import subprocess
import sys
import FluidNexus
    import py2exe
from distutils.command.build_py import build_py as _build_py
from distutils.core import setup
from setuptools import find_packages
from FluidNexus.BuildManpage import build_manpage
    data_files = data_files,
    scripts=["scripts/fluid-nexus"],
    setup_requires=setup_requires,
    zipfile = "lib/library.zip",
    windows=[{
        "script": "scripts/fluid-nexus",
        "icon_resources": [(1, "FluidNexus/ui/res/icons/fluid_nexus_icon.ico")]}],
    app=["FluidNexusApp.py"],
    options = {
        "py2exe": { 
            "includes": ["sip", "simplejson", "pysqlite2", "google.protobuf", "sqlalchemy"], 
            "packages": ["sqlalchemy.dialects.sqlite", "FluidNexus.ui"]
        },
        "py2app": {
            "argv_emulation": True,
            "iconfile": "FluidNexus/ui/res/icons/fluid_nexus_icon.icns",
            "includes": ["sip", "LightAquaBlue", "lightblue", "pysqlite2", "simplejson", "sqlalchemy", "google.protobuf", "sqlalchemy.dialects.sqlite"],
            "packages": ["Foundation"],
            "plist": dict(
                CFBundleName               = "FluidNexus",
                CFBundleShortVersionString = FluidNexus.version.__version__,     # must be in X.X.X format
                CFBundleGetInfoString      = "Fluid Nexus %s" % FluidNexus.version.__version__,
                #CFBundleExecutable         = "FluidNexusApp.py",
                CFBundleIdentifier         = "net.fluidnexus.FluidNexus",
            ),
        },
    },
    include_package_data=True,
    zip_safe=False,
    install_requires = requires,

# Path: FluidNexus/BuildManpage.py
# class build_manpage(Command):
#     """Class to build a manpage from our help and distutils info.
# 
#     From http://andialbrecht.wordpress.com/2009/03/17/creating-a-man-page-with-distutils-and-optparse/."""
# 
#     description = "Generate man page."
# 
#     user_options = [
#         ("output=", "o", "output file"),
#         ("parser=", None, "module path to optparse (e.g. mymod:func)"),
#     ]
# 
#     def initialize_options(self):
#         self.output = None
#         self.parser = None
# 
#     def finalize_options(self):
#         if (self.output is None):
#             raise DistutilsOptionError("'output' option is required")
#         if self.parser is None:
#             raise DistutilsOptionError("'parser' option is required")
# 
#         mod_name, func_name = self.parser.split(":")
# 
#         fromlist = mod_name.split(".")
# 
#         try:
#             mod = __import__(mod_name, fromlist = fromlist)
#             self._parser = getattr(mod, func_name)()
#         except ImportError, err:
#             raise
# 
#         self._parser.formatter = ManPageFormatter()
#         self._parser.formatter.set_parser(self._parser)
#         self.announce("Writing man page %s" % self.output)
#         self._today = datetime.date.today()
# 
#     def _markup(self, txt):
#         return txt.replace("-", "\\-")
# 
#     def _write_header(self):
#         appname = self.distribution.get_name()
# 
#         ret = []
#         ret.append(".TH %s 1 %s\n" % (self._markup(appname),
#                                       self._today.strftime("%Y\\-%m\\-%d")))
#         description = self.distribution.get_description()
#         if description:
#             name = self._markup("%s - %s" % (self._markup(appname),
#                                              description.splitlines()[0]))
#         else:
#             name = self._markup(appname)
# 
#         ret.append(".SH NAME\n%s\n" % name)
# 
#         synopsis = self._parser.get_usage()
#         if synopsis:
#             synopsis = synopsis.replace("setup.py", "")
#             ret.append(".SH SYNOPSIS\n.B %s %s\n" % (self._markup(appname),
#                                                       synopsis))
# 
#         #long_desc = self.distribution.get_long_description()
#         long_desc = self._parser.get_description()
#         if long_desc:
#             ret.append(".SH DESCRIPTION\n%s\n" % self._markup(long_desc))
# 
#         return "".join(ret)
# 
#     def _write_options(self):
#         ret = [".SH OPTIONS\n"]
#         ret.append(self._parser.format_option_help())
#         return "".join(ret)
# 
#     def _write_footer(self):
#         ret = []
#         appname = self.distribution.get_name()
#         author = "%s <%s>" % (self.distribution.get_author(),
#                               self.distribution.get_author_email())
#         ret.append((".SH AUTHORS\n.B %s was written by %s.\n" % (self._markup(appname), self._markup(author))))
#         homepage = self.distribution.get_url()
#         ret.append((".SH DISTRIBUTION\nThe latest version of %s may be downloaded from\n.UR %s\n.UE\n" % (self._markup(appname), self._markup(homepage),)))
#         return "".join(ret)
# 
#     def run(self):
#         manpage = []
#         manpage.append(self._write_header())
#         manpage.append(self._write_options())
#         manpage.append(self._write_footer())
#         stream = open(self.output, "w")
#         stream.write("".join(manpage))
#         stream.close()


# Path: setup.py
import glob
import os
import subprocess
import sys
import FluidNexus
    import py2exe
from distutils.command.build_py import build_py as _build_py
from distutils.core import setup
from setuptools import find_packages
from FluidNexus.BuildManpage import build_manpage

    data_files = data_files,
    scripts=["scripts/fluid-nexus"],
    setup_requires=setup_requires,
    zipfile = "lib/library.zip",
    windows=[{
        "script": "scripts/fluid-nexus",
        "icon_resources": [(1, "FluidNexus/ui/res/icons/fluid_nexus_icon.ico")]}],
    app=["FluidNexusApp.py"],
    options = {
        "py2exe": { 
            "includes": ["sip", "simplejson", "pysqlite2", "google.protobuf", "sqlalchemy"], 
            "packages": ["sqlalchemy.dialects.sqlite", "FluidNexus.ui"]
        },
        "py2app": {
            "argv_emulation": True,
            "iconfile": "FluidNexus/ui/res/icons/fluid_nexus_icon.icns",
            "includes": ["sip", "LightAquaBlue", "lightblue", "pysqlite2", "simplejson", "sqlalchemy", "google.protobuf", "sqlalchemy.dialects.sqlite"],
            "packages": ["Foundation"],
            "plist": dict(
                CFBundleName               = "FluidNexus",
                CFBundleShortVersionString = FluidNexus.version.__version__,     # must be in X.X.X format
                CFBundleGetInfoString      = "Fluid Nexus %s" % FluidNexus.version.__version__,
                #CFBundleExecutable         = "FluidNexusApp.py",
                CFBundleIdentifier         = "net.fluidnexus.FluidNexus",
            ),
        },
    },
    include_package_data=True,
    zip_safe=False,
    install_requires = requires,

    cmdclass={"build_py": build_py, "build_manpage": build_manpage}