setup.py 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. #!/usr/bin/env python3
  2. # Contest Management System - http://cms-dev.github.io/
  3. # Copyright © 2010-2013 Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
  4. # Copyright © 2010-2018 Stefano Maggiolo <s.maggiolo@gmail.com>
  5. # Copyright © 2010-2012 Matteo Boscariol <boscarim@hotmail.com>
  6. # Copyright © 2013 Luca Wehrstedt <luca.wehrstedt@gmail.com>
  7. # Copyright © 2014 Artem Iglikov <artem.iglikov@gmail.com>
  8. # Copyright © 2015 William Di Luigi <williamdiluigi@gmail.com>
  9. # Copyright © 2016 Myungwoo Chun <mc.tamaki@gmail.com>
  10. # Copyright © 2016 Masaki Hara <ackie.h.gmai@gmail.com>
  11. # Copyright © 2016 Peyman Jabbarzade Ganje <peyman.jabarzade@gmail.com>
  12. #
  13. # This program is free software: you can redistribute it and/or modify
  14. # it under the terms of the GNU Affero General Public License as
  15. # published by the Free Software Foundation, either version 3 of the
  16. # License, or (at your option) any later version.
  17. #
  18. # This program is distributed in the hope that it will be useful,
  19. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. # GNU Affero General Public License for more details.
  22. #
  23. # You should have received a copy of the GNU Affero General Public License
  24. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. """Build and installation routines for CMS.
  26. """
  27. import os
  28. import re
  29. from setuptools import setup, find_packages
  30. from setuptools.command.build_py import build_py
  31. PACKAGE_DATA = {
  32. "cms.server": [
  33. "static/*.*",
  34. "static/jq/*.*",
  35. "admin/static/*.*",
  36. "admin/static/jq/*.*",
  37. "admin/static/sh/*.*",
  38. "admin/templates/*.*",
  39. "admin/templates/fragments/*.*",
  40. "admin/templates/macro/*.*",
  41. "contest/static/*.*",
  42. "contest/static/css/*.*",
  43. "contest/static/img/*.*",
  44. "contest/static/img/mimetypes/*.*",
  45. "contest/static/js/*.*",
  46. "contest/templates/*.*",
  47. "contest/templates/macro/*.*",
  48. ],
  49. "cms.service": [
  50. "templates/printing/*.*",
  51. ],
  52. "cms.locale": [
  53. "*/LC_MESSAGES/*.*",
  54. ],
  55. "cmsranking": [
  56. "static/img/*.*",
  57. "static/lib/*.*",
  58. "static/*.*",
  59. ],
  60. "cmstestsuite": [
  61. "code/*.*",
  62. "tasks/batch_stdio/data/*.*",
  63. "tasks/batch_fileio/data/*.*",
  64. "tasks/batch_fileio_managed/code/*",
  65. "tasks/batch_fileio_managed/data/*.*",
  66. "tasks/communication_fifoio_stubbed/code/*",
  67. "tasks/communication_fifoio_stubbed/data/*.*",
  68. "tasks/communication_many_fifoio_stubbed/code/*",
  69. "tasks/communication_many_fifoio_stubbed/data/*.*",
  70. "tasks/communication_many_stdio_stubbed/code/*",
  71. "tasks/communication_many_stdio_stubbed/data/*.*",
  72. "tasks/communication_stdio/code/*",
  73. "tasks/communication_stdio/data/*.*",
  74. "tasks/communication_stdio_stubbed/code/*",
  75. "tasks/communication_stdio_stubbed/data/*.*",
  76. "tasks/outputonly/data/*.*",
  77. "tasks/outputonly_comparator/code/*",
  78. "tasks/outputonly_comparator/data/*.*",
  79. "tasks/twosteps/code/*.*",
  80. "tasks/twosteps/data/*.*",
  81. "tasks/twosteps_comparator/code/*",
  82. "tasks/twosteps_comparator/data/*.*",
  83. ],
  84. }
  85. def find_version():
  86. """Return the version string obtained from cms/__init__.py"""
  87. path = os.path.join("cms", "__init__.py")
  88. with open(path, "rt", encoding="utf-8") as f:
  89. version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
  90. f.read(), re.M)
  91. if version_match is not None:
  92. return version_match.group(1)
  93. raise RuntimeError("Unable to find version string.")
  94. # We piggyback the translation catalogs compilation onto build_py since
  95. # the po and mofiles will be part of the package data for cms.locale,
  96. # which is collected at this stage.
  97. class build_py_and_l10n(build_py):
  98. def run(self):
  99. self.run_command("compile_catalog")
  100. # The build command of distutils/setuptools searches the tree
  101. # and compiles a list of data files before run() is called and
  102. # then stores that value. Hence we need to refresh it.
  103. self.data_files = self._get_data_files()
  104. super().run()
  105. setup(
  106. name="cms",
  107. version=find_version(),
  108. author="The CMS development team",
  109. author_email="contestms@googlegroups.com",
  110. url="https://github.com/cms-dev/cms",
  111. download_url="https://github.com/cms-dev/cms/archive/master.tar.gz",
  112. description="A contest management system and grader "
  113. "for IOI-like programming competitions",
  114. packages=find_packages(),
  115. package_data=PACKAGE_DATA,
  116. cmdclass={"build_py": build_py_and_l10n},
  117. scripts=["scripts/cmsLogService",
  118. "scripts/cmsScoringService",
  119. "scripts/cmsEvaluationService",
  120. "scripts/cmsWorker",
  121. "scripts/cmsResourceService",
  122. "scripts/cmsChecker",
  123. "scripts/cmsContestWebServer",
  124. "scripts/cmsAdminWebServer",
  125. "scripts/cmsProxyService",
  126. "scripts/cmsPrintingService",
  127. "scripts/cmsRankingWebServer",
  128. "scripts/cmsInitDB",
  129. "scripts/cmsDropDB"],
  130. entry_points={
  131. "console_scripts": [
  132. "cmsRunTests=cmstestsuite.RunTests:main",
  133. "cmsAddAdmin=cmscontrib.AddAdmin:main",
  134. "cmsAddParticipation=cmscontrib.AddParticipation:main",
  135. "cmsAddStatement=cmscontrib.AddStatement:main",
  136. "cmsAddSubmission=cmscontrib.AddSubmission:main",
  137. "cmsAddTeam=cmscontrib.AddTeam:main",
  138. "cmsAddTestcases=cmscontrib.AddTestcases:main",
  139. "cmsAddUser=cmscontrib.AddUser:main",
  140. "cmsCleanFiles=cmscontrib.CleanFiles:main",
  141. "cmsDumpExporter=cmscontrib.DumpExporter:main",
  142. "cmsDumpImporter=cmscontrib.DumpImporter:main",
  143. "cmsDumpUpdater=cmscontrib.DumpUpdater:main",
  144. "cmsExportSubmissions=cmscontrib.ExportSubmissions:main",
  145. "cmsImportContest=cmscontrib.ImportContest:main",
  146. "cmsImportDataset=cmscontrib.ImportDataset:main",
  147. "cmsImportTask=cmscontrib.ImportTask:main",
  148. "cmsImportTeam=cmscontrib.ImportTeam:main",
  149. "cmsImportUser=cmscontrib.ImportUser:main",
  150. "cmsRWSHelper=cmscontrib.RWSHelper:main",
  151. "cmsRemoveContest=cmscontrib.RemoveContest:main",
  152. "cmsRemoveParticipation=cmscontrib.RemoveParticipation:main",
  153. "cmsRemoveSubmissions=cmscontrib.RemoveSubmissions:main",
  154. "cmsRemoveTask=cmscontrib.RemoveTask:main",
  155. "cmsRemoveUser=cmscontrib.RemoveUser:main",
  156. "cmsSpoolExporter=cmscontrib.SpoolExporter:main",
  157. "cmsMake=cmstaskenv.cmsMake:main",
  158. ],
  159. "cms.grading.tasktypes": [
  160. "Batch=cms.grading.tasktypes.Batch:Batch",
  161. "Communication=cms.grading.tasktypes.Communication:Communication",
  162. "OutputOnly=cms.grading.tasktypes.OutputOnly:OutputOnly",
  163. "TwoSteps=cms.grading.tasktypes.TwoSteps:TwoSteps",
  164. ],
  165. "cms.grading.scoretypes": [
  166. "Sum=cms.grading.scoretypes.Sum:Sum",
  167. "GroupMin=cms.grading.scoretypes.GroupMin:GroupMin",
  168. "GroupMul=cms.grading.scoretypes.GroupMul:GroupMul",
  169. "GroupThreshold=cms.grading.scoretypes.GroupThreshold:GroupThreshold",
  170. ],
  171. "cms.grading.languages": [
  172. "C++11 / g++=cms.grading.languages.cpp11_gpp:Cpp11Gpp",
  173. "C++14 / g++=cms.grading.languages.cpp14_gpp:Cpp14Gpp",
  174. "C++17 / g++=cms.grading.languages.cpp17_gpp:Cpp17Gpp",
  175. "C11 / gcc=cms.grading.languages.c11_gcc:C11Gcc",
  176. "C# / Mono=cms.grading.languages.csharp_mono:CSharpMono",
  177. "Haskell / ghc=cms.grading.languages.haskell_ghc:HaskellGhc",
  178. "Java / JDK=cms.grading.languages.java_jdk:JavaJDK",
  179. "Pascal / fpc=cms.grading.languages.pascal_fpc:PascalFpc",
  180. "PHP=cms.grading.languages.php:Php",
  181. "Python 2 / CPython=cms.grading.languages.python2_cpython:Python2CPython",
  182. "Python 3 / CPython=cms.grading.languages.python3_cpython:Python3CPython",
  183. "Rust=cms.grading.languages.rust:Rust",
  184. ],
  185. },
  186. keywords="ioi programming contest grader management system",
  187. license="Affero General Public License v3",
  188. classifiers=[
  189. "Development Status :: 5 - Production/Stable",
  190. "Natural Language :: English",
  191. "Operating System :: POSIX :: Linux",
  192. "Programming Language :: Python :: 3.8",
  193. "License :: OSI Approved :: "
  194. "GNU Affero General Public License v3",
  195. ]
  196. )