setup.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #!/usr/bin/env python
  2. #
  3. # Copyright (c) 2015, Nordic Semiconductor
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions are met:
  8. #
  9. # * Redistributions of source code must retain the above copyright notice, this
  10. # list of conditions and the following disclaimer.
  11. #
  12. # * Redistributions in binary form must reproduce the above copyright notice,
  13. # this list of conditions and the following disclaimer in the documentation
  14. # and/or other materials provided with the distribution.
  15. #
  16. # * Neither the name of Nordic Semiconductor ASA nor the names of its
  17. # contributors may be used to endorse or promote products derived from
  18. # this software without specific prior written permission.
  19. #
  20. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  23. # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  24. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  25. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26. # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  27. # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. """
  31. Setup script for nrfutil.
  32. USAGE:
  33. python setup.py install
  34. python setup.py py2exe
  35. """
  36. import os
  37. import platform
  38. from setuptools import setup, find_packages
  39. from setuptools.command.test import test as TestCommand
  40. from setuptools_behave import behave_test
  41. from nordicsemi import version
  42. if platform.system() == 'Windows':
  43. import py2exe # Required even if it is not used in this file. This import adds py2exe to distutils.
  44. excludes = ["Tkconstants",
  45. "Tkinter",
  46. "tcl",
  47. "pickle",
  48. "unittest",
  49. "pyreadline"]
  50. # DFU component cli interface
  51. includes = ["nordicsemi.dfu.dfu"]
  52. packages = []
  53. dll_excludes = [
  54. "w9xpopen.exe",
  55. "OLEAUT32.DLL",
  56. "OLE32.DLL",
  57. "USER32.DLL",
  58. "SHELL32.DLL",
  59. "ADVAPI32.DLL",
  60. "KERNEL32.DLL",
  61. "WS2_32.DLL",
  62. "GDI32.DLL"]
  63. build_dir = os.environ.get("NRFUTIL_BUILD_DIR", "./{}".format(version.NRFUTIL_VERSION))
  64. description = """A Python package that includes the nrfutil utility and the nordicsemi library"""
  65. class NoseTestCommand(TestCommand):
  66. def finalize_options(self):
  67. TestCommand.finalize_options(self)
  68. self.test_args = []
  69. self.test_suite = True
  70. def run_tests(self):
  71. import nose
  72. nose.run_exit(argv=['nosetests', '--with-xunit', '--xunit-file=test-reports/unittests.xml'])
  73. common_requirements=[]
  74. setup(
  75. name="nrfutil",
  76. version=version.NRFUTIL_VERSION,
  77. license="Nordic Semicondictor proprietary license",
  78. url="https://github.com/NordicSemiconductor/pc-nrfutil",
  79. description="Nordic Semiconductor nrfutil utility and Python library",
  80. long_description=description,
  81. packages=find_packages(exclude=["tests.*", "tests"]),
  82. include_package_data=False,
  83. install_requires=common_requirements,
  84. setup_requires=common_requirements,
  85. zipfile=None,
  86. tests_require=[
  87. "nose >= 1.3.4",
  88. "behave"
  89. ],
  90. zip_safe=False,
  91. classifiers=[
  92. "Programming Language :: Python :: 2.7",
  93. ],
  94. cmdclass={
  95. 'test': NoseTestCommand
  96. # 'bdd_test': behave_test
  97. },
  98. entry_points='''
  99. [console_scripts]
  100. nrfutil = nordicsemi.__main__:cli
  101. ''',
  102. console=[{
  103. "script": "./nordicsemi/__main__.py",
  104. "dest_base": "nrfutil"
  105. }],
  106. options={
  107. "py2exe": {
  108. "includes": includes,
  109. "excludes": excludes,
  110. "ascii": False,
  111. "bundle_files": 1, # 1 for bunding into exe, 3 for to distdir
  112. "dist_dir": build_dir,
  113. "verbose": True,
  114. "dll_excludes": dll_excludes
  115. }
  116. }
  117. )