CAT-SOOP is a flexible, programmable learning management system based on the Python programming language. https://catsoop.mit.edu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

154 lines
5.1 KiB

  1. # This file is part of CAT-SOOP
  2. # Copyright (c) 2011-2020 by The CAT-SOOP Developers <catsoop-dev@mit.edu>
  3. #
  4. # This program is free software: you can redistribute it and/or modify it under
  5. # the terms of the GNU Affero General Public License as published by the Free
  6. # Software Foundation, either version 3 of the License, or (at your option) any
  7. # later version.
  8. #
  9. # This program is distributed in the hope that it will be useful, but WITHOUT
  10. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  12. # details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #
  17. #
  18. # Portions of this file were forked from the setup.py file for xonsh
  19. # (https://xon.sh/), which is available under the MIT/Expat license.
  20. import os
  21. import sys
  22. import subprocess
  23. from setuptools import setup
  24. from catsoop import __version__ as CS_VERSION, __codename__ as CODENAME
  25. logo = (
  26. "\\ "
  27. "\n/ /\\__/\\ "
  28. "\n\\__=( o_O )="
  29. "\n(__________) "
  30. "\n |_ |_ |_ |_ "
  31. "\n "
  32. "\n CAT-SOOP "
  33. )
  34. VERSION_FNAME = os.path.join(os.path.dirname(__file__), "catsoop", "__init__.py")
  35. ORIGINAL_VERSION = None
  36. def dev_number():
  37. try:
  38. last_version = subprocess.check_output(
  39. ["git", "describe", "--tags", "--match", "v*"]
  40. ).decode("ascii")
  41. except Exception:
  42. print("failed to find git tags", file=sys.stderr)
  43. return
  44. try:
  45. _, N, sha = last_version.strip().split("-")
  46. N = int(N)
  47. except ValueError: # tag name may contain "-"
  48. print("failed to parse git version", file=sys.stderr)
  49. return
  50. sha = sha.lstrip("g")
  51. try:
  52. _cmd = ["git", "show", "-s", "--format=%cD", sha]
  53. _date = subprocess.check_output(_cmd)
  54. _date = _date.decode("ascii")
  55. _date = "".join(_date.split(" ", 1)[1:])
  56. except:
  57. _date = ""
  58. print("failed to get git commit date", file=sys.stderr)
  59. return ("Git", sha, N, _date)
  60. def dirty_version():
  61. """
  62. If install/sdist is run from a git directory, add a devN suffix to reported
  63. version number and write an ignored file that holds info about the current
  64. state of the repo.
  65. """
  66. global CS_VERSION, ORIGINAL_VERSION
  67. dev_num = dev_number()
  68. if not dev_num:
  69. return
  70. vcs, sha, N, _date = dev_num
  71. # if we get to this point, we are not at a particular tag. we'll modify
  72. # the __version__ from catsoop/__init__.py to include a .devN suffix.
  73. CS_VERSION = CS_VERSION + ".dev%s" % (N,)
  74. with open(os.path.join(os.path.dirname(__file__), "catsoop", "dev.hash"), "w") as f:
  75. f.write("{}|{}|{}".format(vcs, sha, _date))
  76. with open(VERSION_FNAME, "r") as f:
  77. ORIGINAL_VERSION = f.read()
  78. with open(VERSION_FNAME, "w") as f:
  79. f.write("__version__ = %r\n" % CS_VERSION)
  80. f.write("__codename__= %r\n" % CODENAME)
  81. def main():
  82. if sys.version_info[:2] < (3, 5):
  83. sys.exit("catsoop currently requires Python 3.5+")
  84. if "--name" not in sys.argv:
  85. print(logo)
  86. with open(os.path.join(os.path.dirname(__file__), "requirements.txt"), "r") as f:
  87. requirements = f.read().split("\n")
  88. with open(os.path.join(os.path.dirname(__file__), "README.md"), "r") as f:
  89. readme = f.read()
  90. try:
  91. dirty_version()
  92. setup(
  93. name="catsoop",
  94. version=CS_VERSION,
  95. author="CAT-SOOP Contributors",
  96. author_email="catsoop-dev@mit.edu",
  97. packages=[
  98. "catsoop",
  99. "catsoop.test",
  100. "catsoop.thirdparty",
  101. "catsoop.scripts",
  102. ],
  103. scripts=[],
  104. url="https://catsoop.mit.edu",
  105. license="AGPLv3+",
  106. description="CAT-SOOP is a tool for automatic collection and assessment of online exercises.",
  107. long_description=readme,
  108. long_description_content_type="text/markdown",
  109. include_package_data=True,
  110. entry_points={
  111. "console_scripts": ["catsoop = catsoop.main:command_line_interface"]
  112. },
  113. install_requires=requirements,
  114. package_dir={"catsoop": "catsoop"},
  115. package_data={"catsoop": ["scripts/*"]},
  116. test_suite="catsoop.test",
  117. classifiers=[
  118. "Development Status :: 4 - Beta",
  119. "Intended Audience :: Education",
  120. "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
  121. "Programming Language :: Python :: 3.5",
  122. "Programming Language :: Python :: 3.6",
  123. "Programming Language :: Python :: 3.7",
  124. "Topic :: Education",
  125. "Topic :: Internet :: WWW/HTTP :: WSGI",
  126. ],
  127. )
  128. finally:
  129. if ORIGINAL_VERSION is not None:
  130. with open(VERSION_FNAME, "w") as f:
  131. f.write(ORIGINAL_VERSION)
  132. if __name__ == "__main__":
  133. main()