CAT-SOOP is a tool for automatic collection and assessment of online exercises 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.

setup.py 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. # This file is part of CAT-SOOP
  2. # Copyright (c) 2011-2019 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
  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 dirty_version():
  37. """
  38. If install/sdist is run from a git directory, add a devN suffix to reported
  39. version number and write a gitignored file that holds the git hash of the
  40. current state of the repo.
  41. """
  42. global CS_VERSION, ORIGINAL_VERSION
  43. try:
  44. last_version = subprocess.check_output(
  45. ["git", "describe", "--tags", "--match", "v*"]
  46. ).decode("ascii")
  47. except Exception:
  48. print("failed to find git tags", file=sys.stderr)
  49. return
  50. try:
  51. _, N, sha = last_version.strip().split("-")
  52. N = int(N)
  53. except ValueError: # tag name may contain "-"
  54. print("failed to parse git version", file=sys.stderr)
  55. return
  56. # if we get to this point, we are not at a particular tag. we'll modify
  57. # the __version__ from catsoop/__init__.py to include a .devN suffix.
  58. sha = sha.lstrip("g")
  59. CS_VERSION = CS_VERSION + ".dev%s" % (N,)
  60. _cmd = ["git", "show", "-s", "--format=%cD", sha]
  61. try:
  62. _date = subprocess.check_output(_cmd)
  63. _date = _date.decode("ascii")
  64. # remove weekday name for a shorter string
  65. _date = "".join(_date.split(" ", 1)[1:])
  66. except:
  67. _date = ""
  68. print("failed to get commit date", file=sys.stderr)
  69. with open(
  70. os.path.join(os.path.dirname(__file__), "catsoop", "dev.githash"), "w"
  71. ) as f:
  72. f.write("{}|{}".format(sha, _date))
  73. with open(VERSION_FNAME, "r") as f:
  74. ORIGINAL_VERSION = f.read()
  75. with open(VERSION_FNAME, "w") as f:
  76. f.write('__version__ = "%s"\n' % CS_VERSION)
  77. def main():
  78. if sys.version_info[:2] < (3, 5):
  79. sys.exit("catsoop currently requires Python 3.5+")
  80. if "--name" not in sys.argv:
  81. print(logo)
  82. with open(os.path.join(os.path.dirname(__file__), "requirements.txt"), "r") as f:
  83. requirements = f.read().split("\n")
  84. with open(os.path.join(os.path.dirname(__file__), "README.md"), "r") as f:
  85. readme = f.read()
  86. dirty_version()
  87. setup(
  88. name="catsoop",
  89. version=CS_VERSION,
  90. author="CAT-SOOP Contributors",
  91. author_email="catsoop-dev@mit.edu",
  92. packages=["catsoop", "catsoop.test", "catsoop.thirdparty", "catsoop.scripts"],
  93. scripts=[],
  94. url="https://catsoop.mit.edu",
  95. license="AGPLv3+",
  96. description="CAT-SOOP is a tool for automatic collection and assessment of online exercises.",
  97. long_description=readme,
  98. long_description_content_type="text/markdown",
  99. include_package_data=True,
  100. entry_points={
  101. "console_scripts": ["catsoop = catsoop.main:command_line_interface"]
  102. },
  103. install_requires=requirements,
  104. package_dir={"catsoop": "catsoop"},
  105. package_data={"catsoop": ["scripts/*"]},
  106. test_suite="catsoop.test",
  107. classifiers=[
  108. "Development Status :: 4 - Beta",
  109. "Intended Audience :: Education",
  110. "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
  111. "Programming Language :: Python :: 3.5",
  112. "Programming Language :: Python :: 3.6",
  113. "Programming Language :: Python :: 3.7",
  114. "Topic :: Education",
  115. "Topic :: Internet :: WWW/HTTP :: WSGI",
  116. ],
  117. )
  118. if ORIGINAL_VERSION is not None:
  119. with open(VERSION_FNAME, "w") as f:
  120. f.write(ORIGINAL_VERSION)
  121. if __name__ == "__main__":
  122. main()