setup.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Copyright (C) 2016-2017, AquilaNipalensis
  5. #
  6. # This program is free software; you can redistribute it and/or modify it
  7. # under the terms of the GNU General Public License as published by the
  8. # Free Software Foundation; either version 2 of the License, or (at your
  9. # option) any later version. Please read the COPYING file.
  10. #
  11. import os
  12. import sys
  13. import glob
  14. import shutil
  15. from distutils.core import setup
  16. from distutils.command.install import install
  17. from scom import __version__ as version
  18. distfiles = """
  19. setup.py
  20. scom/*.py
  21. """
  22. def make_dist():
  23. distdir = "scom-api-%s" % version
  24. list = []
  25. for t in distfiles.split():
  26. list.extend(glob.glob(t))
  27. if os.path.exists(distdir):
  28. shutil.rmtree(distdir)
  29. os.mkdir(distdir)
  30. for file_ in list:
  31. cum = distdir[:]
  32. for d in os.path.dirname(file_).split('/'):
  33. dn = os.path.join(cum, d)
  34. cum = dn[:]
  35. if not os.path.exists(dn):
  36. os.mkdir(dn)
  37. shutil.copy(file_, os.path.join(distdir, file_))
  38. os.popen("tar -czf %s %s" % ("scom-api-" + version + ".tar.gz", distdir))
  39. shutil.rmtree(distdir)
  40. if "dist" in sys.argv:
  41. make_dist()
  42. sys.exit(0)
  43. class Install(install):
  44. def finalize_options(self):
  45. # NOTE: for Pardus distribution
  46. if os.path.exists("/etc/sulin-release"):
  47. self.install_platlib = '$base/lib/sulin'
  48. self.install_purelib = '$base/lib/sulin'
  49. install.finalize_options(self)
  50. def run(self):
  51. install.run(self)
  52. setup(
  53. name = 'scom',
  54. version = version,
  55. description = 'COMAR API Functions',
  56. url = 'http://www.sulin.org.tr/projeler/scom',
  57. license = 'GNU GPL2',
  58. package_dir = { '': '' },
  59. packages = [ 'scom' ],
  60. cmdclass = {
  61. 'install' : Install
  62. }
  63. )