setup-vc.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #
  2. # pjsua Setup script for Visual Studio
  3. #
  4. # Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. #
  20. from distutils.core import setup, Extension
  21. import os
  22. import sys
  23. # Find version
  24. pj_version=""
  25. pj_version_major=""
  26. pj_version_minor=""
  27. pj_version_rev=""
  28. pj_version_suffix=""
  29. f = open('../../../version.mak', 'r')
  30. for line in f:
  31. if line.find("export PJ_VERSION_MAJOR") != -1:
  32. tokens=line.split("=")
  33. if len(tokens)>1:
  34. pj_version_major= tokens[1].strip()
  35. elif line.find("export PJ_VERSION_MINOR") != -1:
  36. tokens=line.split("=")
  37. if len(tokens)>1:
  38. pj_version_minor= line.split("=")[1].strip()
  39. elif line.find("export PJ_VERSION_REV") != -1:
  40. tokens=line.split("=")
  41. if len(tokens)>1:
  42. pj_version_rev= line.split("=")[1].strip()
  43. elif line.find("export PJ_VERSION_SUFFIX") != -1:
  44. tokens=line.split("=")
  45. if len(tokens)>1:
  46. pj_version_suffix= line.split("=")[1].strip()
  47. f.close()
  48. if not pj_version_major:
  49. print 'Unable to get PJ_VERSION_MAJOR'
  50. sys.exit(1)
  51. pj_version = pj_version_major + "." + pj_version_minor
  52. if pj_version_rev:
  53. pj_version += "." + pj_version_rev
  54. if pj_version_suffix:
  55. pj_version += "-" + pj_version_suffix
  56. #print 'PJ_VERSION = "'+ pj_version + '"'
  57. # Check that extension has been built
  58. if not os.access('../../lib/_pjsua.pyd', os.R_OK):
  59. print 'Error: file "../../lib/_pjsua.pyd" does not exist!'
  60. print ''
  61. print 'Please build the extension with Visual Studio first'
  62. print 'For more info, see http://trac.pjsip.org/repos/wiki/Python_SIP_Tutorial'
  63. sys.exit(1)
  64. setup(name="pjsua",
  65. version=pj_version,
  66. description='SIP User Agent Library based on PJSIP',
  67. url='http://trac.pjsip.org/repos/wiki/Python_SIP_Tutorial',
  68. data_files=[('lib/site-packages', ['../../lib/_pjsua.pyd'])],
  69. py_modules=["pjsua"]
  70. )