setup.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # $Id$
  2. #
  3. # Copyright (C) 2015--2016 Parsons Government Services ("PARSONS")
  4. # Portions copyright (C) 2014 Dragon Research Labs ("DRL")
  5. # Portions copyright (C) 2011--2013 Internet Systems Consortium ("ISC")
  6. #
  7. # Permission to use, copy, modify, and distribute this software for any
  8. # purpose with or without fee is hereby granted, provided that the above
  9. # copyright notices and this permission notice appear in all copies.
  10. #
  11. # THE SOFTWARE IS PROVIDED "AS IS" AND PARSONS, DRL, AND ISC DISCLAIM
  12. # ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  13. # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  14. # PARSONS, DRL, OR ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
  15. # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
  16. # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  17. # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  18. # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19. from distutils.core import setup, Extension
  20. from glob import glob
  21. import setup_extensions
  22. try:
  23. import setup_autoconf as autoconf
  24. except ImportError:
  25. class autoconf:
  26. "Fake autoconf object to let --help work without autoconf."
  27. sbindir = libexecdir = datarootdir = sysconfdir = ""
  28. CFLAGS = LDFLAGS = LIBS = CA_TARGET = RP_TARGET = ""
  29. try:
  30. from rpki.version import VERSION
  31. except ImportError:
  32. VERSION = "0.0"
  33. # pylint: disable=W0622
  34. scripts = []
  35. data_files = []
  36. packages = []
  37. package_data = {}
  38. ext_modules = []
  39. # I keep forgetting to update the packages list here. Could we
  40. # automate this by looking for __init__.py files in the rpki/ tree?
  41. # Might have to filter out some rpki.gui.app subdirs, or, rather,
  42. # list those as package_data instead.
  43. if autoconf.RP_TARGET == "rp":
  44. packages += ["rpki",
  45. "rpki.POW",
  46. "rpki.django_settings",
  47. "rpki.rtr",
  48. "rpki.irdb",
  49. "rpki.pubdb",
  50. "rpki.rpkidb",
  51. "rpki.rcynicdb",
  52. "rpki.gui",
  53. "rpki.gui.app",
  54. "rpki.gui.gui_rpki_cache",
  55. "rpki.gui.api",
  56. "rpki.gui.routeview"]
  57. ext_modules += [Extension("rpki.POW._POW", ["ext/POW.c"],
  58. include_dirs = [cflag[2:] for cflag in autoconf.CFLAGS.split() if cflag.startswith("-I")],
  59. extra_compile_args = [cflag for cflag in autoconf.CFLAGS.split() if not cflag.startswith("-I")],
  60. extra_link_args = autoconf.LDFLAGS.split() + autoconf.LIBS.split())]
  61. for package in ("rpki.irdb", "rpki.pubdb", "rpki.rpkidb", "rpki.rcynicdb"):
  62. package_data[package] = ["migrations/*.py"]
  63. data_files += [(autoconf.sysconfdir + "/rpki",
  64. ["rp/config/rpki-confgen.xml"])]
  65. scripts += [(autoconf.bindir,
  66. ["rp/rcynic/rcynic-cron",
  67. "rp/rcynic/rcynic-html",
  68. "rp/rcynic/rcynic-svn",
  69. "rp/rcynic/rcynic-text",
  70. "rp/rcynic/validation_status",
  71. "rp/rpki-rtr/rpki-rtr",
  72. "rp/utils/find_roa",
  73. "rp/utils/hashdir",
  74. "rp/utils/print_roa",
  75. "rp/utils/print_rpki_manifest",
  76. "rp/utils/scan_roas",
  77. "rp/utils/scan_routercerts",
  78. "rp/utils/uri"]),
  79. (autoconf.sbindir,
  80. ["rp/config/rpki-confgen",
  81. "rp/config/rpki-sql-backup",
  82. "rp/config/rpki-sql-setup",
  83. "rp/config/rpki-manage",
  84. "rp/config/rpki-generate-root-certificate"])]
  85. if autoconf.CA_TARGET == "ca":
  86. package_data["rpki.gui.app"] = ["migrations/*.py",
  87. "static/*/*",
  88. "templates/*.html",
  89. "templates/*/*.html",
  90. "templatetags/*.py"]
  91. package_data["rpki.gui.gui_rpki_cache"] = ["migrations/*.py"]
  92. package_data["rpki.gui.routeview"] = ["migrations/*.py"]
  93. data_files += [(autoconf.datarootdir + "/rpki/wsgi",
  94. ["ca/rpki.wsgi"]),
  95. (autoconf.datarootdir + "/rpki/media/css",
  96. glob("rpki/gui/app/static/css/*")),
  97. (autoconf.datarootdir + "/rpki/media/js",
  98. glob("rpki/gui/app/static/js/*")),
  99. (autoconf.datarootdir + "/rpki/media/img",
  100. glob("rpki/gui/app/static/img/*"))]
  101. scripts += [(autoconf.sbindir,
  102. ["ca/rpkic",
  103. "ca/rpkigui-query-routes",
  104. "ca/irbe_cli"]),
  105. (autoconf.libexecdir,
  106. ["ca/irdbd",
  107. "ca/pubd",
  108. "ca/rootd",
  109. "ca/rpkid",
  110. "ca/rpki-nanny",
  111. "ca/rpkigui-import-routes",
  112. "ca/rpkigui-check-expired",
  113. "ca/rpkigui-rcynic",
  114. "ca/rpkigui-apache-conf-gen"])]
  115. setup_args = dict(
  116. name = "rpki",
  117. version = VERSION,
  118. description = "RPKI Toolkit",
  119. license = "BSD",
  120. url = "http://rpki.net/",
  121. cmdclass = {"build_scripts" : setup_extensions.build_scripts,
  122. "install_scripts" : setup_extensions.install_scripts})
  123. for name in ("scripts", "data_files", "packages", "package_data", "ext_modules"):
  124. val = globals().get(name)
  125. if val:
  126. setup_args[name] = val
  127. setup(**setup_args)