setup.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # This file is part of Radicale Server - Calendar Server
  5. # Copyright © 2009-2010 Guillaume Ayoub
  6. #
  7. # This library is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This library is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with Radicale. If not, see <http://www.gnu.org/licenses/>.
  19. import os
  20. import shutil
  21. from distutils.core import setup, Command
  22. from distutils.command.build_scripts import build_scripts
  23. class BuildScripts(build_scripts):
  24. def run(self):
  25. self.mkpath(self.build_dir)
  26. for script in self.scripts:
  27. root, _ = os.path.splitext(script)
  28. self.copy_file(script, os.path.join(self.build_dir, root))
  29. class Clean(Command):
  30. description = "clean up package temporary files"
  31. user_options = []
  32. def initialize_options(self):
  33. pass
  34. def finalize_options(self):
  35. pass
  36. def run(self):
  37. path = os.path.abspath(os.path.dirname(__file__))
  38. for pathname, _, files in os.walk(path):
  39. for filename in filter(self._should_remove, files):
  40. os.unlink(os.path.join(pathname, filename))
  41. for folder in ("build", "dist"):
  42. if os.path.isdir(os.path.join(path, folder)):
  43. shutil.rmtree(os.path.join(path, folder))
  44. if os.path.isfile(os.path.join(path, "MANIFEST")):
  45. os.unlink(os.path.join(path, "MANIFEST"))
  46. @staticmethod
  47. def _should_remove(filename):
  48. return (os.path.splitext(filename)[1] == ".pyc" or
  49. os.path.splitext(filename)[1] == ".pyo" or
  50. filename.endswith("~") or
  51. (filename.startswith("#") and filename.endswith("#")))
  52. setup(
  53. name="Radicale",
  54. version="0.1",
  55. description="Radicale CalDAV Server",
  56. author="Guillaume Ayoub",
  57. author_email="guillaume.ayoub@kozea.fr",
  58. url="http://www.radicale.org/",
  59. license="GNU GPL v3",
  60. packages=["radicale", "radicale.acl", "radicale.support"],
  61. scripts=["radicale.py"],
  62. cmdclass={'clean': Clean,
  63. "build_scripts": BuildScripts})