setup.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. """
  20. Radicale setup file.
  21. To install, type ``python setup.py install`` as superuser.
  22. """
  23. import os
  24. import shutil
  25. from distutils.core import setup, Command
  26. from distutils.command.build_scripts import build_scripts
  27. class BuildScripts(build_scripts):
  28. """Build the package."""
  29. def run(self):
  30. """Run building."""
  31. self.mkpath(self.build_dir)
  32. for script in self.scripts:
  33. root, _ = os.path.splitext(script)
  34. self.copy_file(script, os.path.join(self.build_dir, root))
  35. class Clean(Command):
  36. """Clean up package temporary files."""
  37. description = "clean up package temporary files"
  38. user_options = []
  39. def initialize_options(self):
  40. """Pre-processing."""
  41. pass
  42. def finalize_options(self):
  43. """Post-processing."""
  44. pass
  45. def run(self):
  46. """Run clean up."""
  47. path = os.path.abspath(os.path.dirname(__file__))
  48. for pathname, _, files in os.walk(path):
  49. for filename in filter(self._should_remove, files):
  50. os.unlink(os.path.join(pathname, filename))
  51. for folder in ("build", "dist"):
  52. if os.path.isdir(os.path.join(path, folder)):
  53. shutil.rmtree(os.path.join(path, folder))
  54. if os.path.isfile(os.path.join(path, "MANIFEST")):
  55. os.unlink(os.path.join(path, "MANIFEST"))
  56. @staticmethod
  57. def _should_remove(filename):
  58. """Return if ``filename`` should be considered as temporary."""
  59. return (os.path.splitext(filename)[1] == ".pyc" or
  60. os.path.splitext(filename)[1] == ".pyo" or
  61. filename.endswith("~") or
  62. (filename.startswith("#") and filename.endswith("#")))
  63. setup(
  64. name="Radicale",
  65. version="0.2",
  66. description="Radicale CalDAV Server",
  67. author="Guillaume Ayoub",
  68. author_email="guillaume.ayoub@kozea.fr",
  69. url="http://www.radicale.org/",
  70. license="GNU GPL v3",
  71. packages=["radicale", "radicale.acl"],
  72. scripts=["radicale.py"],
  73. cmdclass={'clean': Clean,
  74. "build_scripts": BuildScripts})