setup.py 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. '''
  4. The setup script for salt
  5. '''
  6. # pylint: disable=file-perms,ungrouped-imports,wrong-import-order,wrong-import-position,repr-flag-used-in-string
  7. # pylint: disable=3rd-party-local-module-not-gated,resource-leakage
  8. # pylint: disable=C0111,E1101,E1103,F0401,W0611,W0201,W0232,R0201,R0902,R0903
  9. # For Python 2.5. A no-op on 2.6 and above.
  10. from __future__ import absolute_import, print_function, with_statement
  11. import os
  12. import sys
  13. import glob
  14. import time
  15. import operator
  16. import platform
  17. try:
  18. from urllib2 import urlopen
  19. except ImportError:
  20. from urllib.request import urlopen # pylint: disable=no-name-in-module
  21. from datetime import datetime
  22. # pylint: disable=E0611
  23. import distutils.dist
  24. from distutils import log
  25. from distutils.cmd import Command
  26. from distutils.errors import DistutilsArgError
  27. from distutils.command.build import build
  28. from distutils.command.clean import clean
  29. from distutils.command.sdist import sdist
  30. from distutils.command.install_lib import install_lib
  31. from distutils.version import LooseVersion # pylint: disable=blacklisted-module
  32. from ctypes.util import find_library
  33. # pylint: enable=E0611
  34. try:
  35. import zmq
  36. HAS_ZMQ = True
  37. except ImportError:
  38. HAS_ZMQ = False
  39. try:
  40. DATE = datetime.utcfromtimestamp(int(os.environ['SOURCE_DATE_EPOCH']))
  41. except (KeyError, ValueError):
  42. DATE = datetime.utcnow()
  43. # Change to salt source's directory prior to running any command
  44. try:
  45. SETUP_DIRNAME = os.path.dirname(__file__)
  46. except NameError:
  47. # We're most likely being frozen and __file__ triggered this NameError
  48. # Let's work around that
  49. SETUP_DIRNAME = os.path.dirname(sys.argv[0])
  50. if SETUP_DIRNAME != '':
  51. os.chdir(SETUP_DIRNAME)
  52. SETUP_DIRNAME = os.path.abspath(SETUP_DIRNAME)
  53. BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION = os.environ.get(
  54. # The user can provide a different bootstrap-script version.
  55. # ATTENTION: A tag for that version MUST exist
  56. 'BOOTSTRAP_SCRIPT_VERSION',
  57. # If no bootstrap-script version was provided from the environment, let's
  58. # provide the one we define.
  59. 'v2014.06.21'
  60. )
  61. # Store a reference to the executing platform
  62. IS_WINDOWS_PLATFORM = sys.platform.startswith('win')
  63. if IS_WINDOWS_PLATFORM:
  64. IS_SMARTOS_PLATFORM = False
  65. else:
  66. # os.uname() not available on Windows.
  67. IS_SMARTOS_PLATFORM = os.uname()[0] == 'SunOS' and os.uname()[3].startswith('joyent_')
  68. # Store a reference whether if we're running under Python 3 and above
  69. IS_PY3 = sys.version_info > (3,)
  70. # Use setuptools only if the user opts-in by setting the USE_SETUPTOOLS env var
  71. # Or if setuptools was previously imported (which is the case when using
  72. # 'distribute')
  73. # This ensures consistent behavior but allows for advanced usage with
  74. # virtualenv, buildout, and others.
  75. WITH_SETUPTOOLS = False
  76. if 'USE_SETUPTOOLS' in os.environ or 'setuptools' in sys.modules:
  77. try:
  78. from setuptools import setup
  79. from setuptools.command.develop import develop
  80. from setuptools.command.install import install
  81. from setuptools.command.sdist import sdist
  82. from setuptools.command.egg_info import egg_info
  83. WITH_SETUPTOOLS = True
  84. except ImportError:
  85. WITH_SETUPTOOLS = False
  86. if WITH_SETUPTOOLS is False:
  87. import warnings
  88. # pylint: disable=E0611
  89. from distutils.command.install import install
  90. from distutils.core import setup
  91. # pylint: enable=E0611
  92. warnings.filterwarnings(
  93. 'ignore',
  94. 'Unknown distribution option: \'(extras_require|tests_require|install_requires|zip_safe)\'',
  95. UserWarning,
  96. 'distutils.dist'
  97. )
  98. try:
  99. # Add the esky bdist target if the module is available
  100. # may require additional modules depending on platform
  101. from esky import bdist_esky
  102. # bbfreeze chosen for its tight integration with distutils
  103. import bbfreeze
  104. HAS_ESKY = True
  105. except ImportError:
  106. HAS_ESKY = False
  107. SALT_VERSION = os.path.join(os.path.abspath(SETUP_DIRNAME), 'salt', 'version.py')
  108. SALT_VERSION_HARDCODED = os.path.join(os.path.abspath(SETUP_DIRNAME), 'salt', '_version.py')
  109. SALT_SYSPATHS_HARDCODED = os.path.join(os.path.abspath(SETUP_DIRNAME), 'salt', '_syspaths.py')
  110. SALT_REQS = os.path.join(os.path.abspath(SETUP_DIRNAME), 'requirements', 'base.txt')
  111. SALT_ZEROMQ_REQS = os.path.join(os.path.abspath(SETUP_DIRNAME), 'requirements', 'zeromq.txt')
  112. SALT_RAET_REQS = os.path.join(os.path.abspath(SETUP_DIRNAME), 'requirements', 'raet.txt')
  113. SALT_WINDOWS_REQS = os.path.join(os.path.abspath(SETUP_DIRNAME), 'pkg', 'windows', 'req.txt')
  114. SALT_LONG_DESCRIPTION_FILE = os.path.join(os.path.abspath(SETUP_DIRNAME), 'README.rst')
  115. # Salt SSH Packaging Detection
  116. PACKAGED_FOR_SALT_SSH_FILE = os.path.join(os.path.abspath(SETUP_DIRNAME), '.salt-ssh-package')
  117. PACKAGED_FOR_SALT_SSH = os.path.isfile(PACKAGED_FOR_SALT_SSH_FILE)
  118. # pylint: disable=W0122
  119. exec(compile(open(SALT_VERSION).read(), SALT_VERSION, 'exec'))
  120. # pylint: enable=W0122
  121. # ----- Helper Functions -------------------------------------------------------------------------------------------->
  122. def _parse_op(op):
  123. '''
  124. >>> _parse_op('>')
  125. 'gt'
  126. >>> _parse_op('>=')
  127. 'ge'
  128. >>> _parse_op('=>')
  129. 'ge'
  130. >>> _parse_op('=> ')
  131. 'ge'
  132. >>> _parse_op('<')
  133. 'lt'
  134. >>> _parse_op('<=')
  135. 'le'
  136. >>> _parse_op('==')
  137. 'eq'
  138. >>> _parse_op(' <= ')
  139. 'le'
  140. '''
  141. op = op.strip()
  142. if '>' in op:
  143. if '=' in op:
  144. return 'ge'
  145. else:
  146. return 'gt'
  147. elif '<' in op:
  148. if '=' in op:
  149. return 'le'
  150. else:
  151. return 'lt'
  152. elif '!' in op:
  153. return 'ne'
  154. else:
  155. return 'eq'
  156. def _parse_ver(ver):
  157. '''
  158. >>> _parse_ver("'3.4' # pyzmq 17.1.0 stopped building wheels for python3.4")
  159. '3.4'
  160. >>> _parse_ver('"3.4"')
  161. '3.4'
  162. >>> _parse_ver('"2.6.17"')
  163. '2.6.17'
  164. '''
  165. if '#' in ver:
  166. ver, _ = ver.split('#', 1)
  167. ver = ver.strip()
  168. return ver.strip('\'').strip('"')
  169. def _check_ver(pyver, op, wanted):
  170. '''
  171. >>> _check_ver('2.7.15', 'gt', '2.7')
  172. True
  173. >>> _check_ver('2.7.15', 'gt', '2.7.15')
  174. False
  175. >>> _check_ver('2.7.15', 'ge', '2.7.15')
  176. True
  177. >>> _check_ver('2.7.15', 'eq', '2.7.15')
  178. True
  179. '''
  180. pyver = distutils.version.LooseVersion(pyver)
  181. wanted = distutils.version.LooseVersion(wanted)
  182. return getattr(operator, '__{}__'.format(op))(pyver, wanted)
  183. def _parse_requirements_file(requirements_file):
  184. parsed_requirements = []
  185. with open(requirements_file) as rfh:
  186. for line in rfh.readlines():
  187. line = line.strip()
  188. if not line or line.startswith(('#', '-r')):
  189. continue
  190. if IS_WINDOWS_PLATFORM:
  191. if 'libcloud' in line:
  192. continue
  193. if IS_PY3 and 'futures' in line.lower():
  194. # Python 3 already has futures, installing it will only break
  195. # the current python installation whenever futures is imported
  196. continue
  197. try:
  198. pkg, pyverspec = line.rsplit(';', 1)
  199. except ValueError:
  200. pkg, pyverspec = line, ''
  201. pyverspec = pyverspec.strip()
  202. if pyverspec:
  203. _, op, ver = pyverspec.split(' ', 2)
  204. if not _check_ver(platform.python_version(), _parse_op(op), _parse_ver(ver)):
  205. continue
  206. parsed_requirements.append(pkg)
  207. return parsed_requirements
  208. # <---- Helper Functions ---------------------------------------------------------------------------------------------
  209. # ----- Custom Distutils/Setuptools Commands ------------------------------------------------------------------------>
  210. class WriteSaltVersion(Command):
  211. description = 'Write salt\'s hardcoded version file'
  212. user_options = []
  213. def initialize_options(self):
  214. '''
  215. Abstract method that is required to be overwritten
  216. '''
  217. def finalize_options(self):
  218. '''
  219. Abstract method that is required to be overwritten
  220. '''
  221. def run(self):
  222. if not os.path.exists(SALT_VERSION_HARDCODED) or self.distribution.with_salt_version:
  223. # Write the version file
  224. if getattr(self.distribution, 'salt_version_hardcoded_path', None) is None:
  225. print('This command is not meant to be called on it\'s own')
  226. exit(1)
  227. if not self.distribution.with_salt_version:
  228. salt_version = __saltstack_version__ # pylint: disable=undefined-variable
  229. else:
  230. from salt.version import SaltStackVersion
  231. salt_version = SaltStackVersion.parse(self.distribution.with_salt_version)
  232. # pylint: disable=E0602
  233. open(self.distribution.salt_version_hardcoded_path, 'w').write(
  234. INSTALL_VERSION_TEMPLATE.format(
  235. date=DATE,
  236. full_version_info=salt_version.full_info
  237. )
  238. )
  239. # pylint: enable=E0602
  240. class GenerateSaltSyspaths(Command):
  241. description = 'Generate salt\'s hardcoded syspaths file'
  242. def initialize_options(self):
  243. pass
  244. def finalize_options(self):
  245. pass
  246. def run(self):
  247. # Write the syspaths file
  248. if getattr(self.distribution, 'salt_syspaths_hardcoded_path', None) is None:
  249. print('This command is not meant to be called on it\'s own')
  250. exit(1)
  251. # Write the system paths file
  252. open(self.distribution.salt_syspaths_hardcoded_path, 'w').write(
  253. INSTALL_SYSPATHS_TEMPLATE.format(
  254. date=DATE,
  255. root_dir=self.distribution.salt_root_dir,
  256. share_dir=self.distribution.salt_share_dir,
  257. config_dir=self.distribution.salt_config_dir,
  258. cache_dir=self.distribution.salt_cache_dir,
  259. sock_dir=self.distribution.salt_sock_dir,
  260. srv_root_dir=self.distribution.salt_srv_root_dir,
  261. base_file_roots_dir=self.distribution.salt_base_file_roots_dir,
  262. base_pillar_roots_dir=self.distribution.salt_base_pillar_roots_dir,
  263. base_master_roots_dir=self.distribution.salt_base_master_roots_dir,
  264. base_thorium_roots_dir=self.distribution.salt_base_thorium_roots_dir,
  265. logs_dir=self.distribution.salt_logs_dir,
  266. pidfile_dir=self.distribution.salt_pidfile_dir,
  267. spm_parent_path=self.distribution.salt_spm_parent_dir,
  268. spm_formula_path=self.distribution.salt_spm_formula_dir,
  269. spm_pillar_path=self.distribution.salt_spm_pillar_dir,
  270. spm_reactor_path=self.distribution.salt_spm_reactor_dir,
  271. home_dir=self.distribution.salt_home_dir,
  272. )
  273. )
  274. class WriteSaltSshPackagingFile(Command):
  275. description = 'Write salt\'s ssh packaging file'
  276. user_options = []
  277. def initialize_options(self):
  278. '''
  279. Abstract method that is required to be overwritten
  280. '''
  281. def finalize_options(self):
  282. '''
  283. Abstract method that is required to be overwritten
  284. '''
  285. def run(self):
  286. if not os.path.exists(PACKAGED_FOR_SALT_SSH_FILE):
  287. # Write the salt-ssh packaging file
  288. if getattr(self.distribution, 'salt_ssh_packaging_file', None) is None:
  289. print('This command is not meant to be called on it\'s own')
  290. exit(1)
  291. # pylint: disable=E0602
  292. open(self.distribution.salt_ssh_packaging_file, 'w').write('Packaged for Salt-SSH\n')
  293. # pylint: enable=E0602
  294. if WITH_SETUPTOOLS:
  295. class Develop(develop):
  296. user_options = develop.user_options + [
  297. ('write-salt-version', None,
  298. 'Generate Salt\'s _version.py file which allows proper version '
  299. 'reporting. This defaults to False on develop/editable setups. '
  300. 'If WRITE_SALT_VERSION is found in the environment this flag is '
  301. 'switched to True.'),
  302. ('generate-salt-syspaths', None,
  303. 'Generate Salt\'s _syspaths.py file which allows tweaking some '
  304. 'common paths that salt uses. This defaults to False on '
  305. 'develop/editable setups. If GENERATE_SALT_SYSPATHS is found in '
  306. 'the environment this flag is switched to True.'),
  307. ('mimic-salt-install', None,
  308. 'Mimmic the install command when running the develop command. '
  309. 'This will generate salt\'s _version.py and _syspaths.py files. '
  310. 'Generate Salt\'s _syspaths.py file which allows tweaking some '
  311. 'This defaults to False on develop/editable setups. '
  312. 'If MIMIC_INSTALL is found in the environment this flag is '
  313. 'switched to True.')
  314. ]
  315. boolean_options = develop.boolean_options + [
  316. 'write-salt-version',
  317. 'generate-salt-syspaths',
  318. 'mimic-salt-install'
  319. ]
  320. def initialize_options(self):
  321. develop.initialize_options(self)
  322. self.write_salt_version = False
  323. self.generate_salt_syspaths = False
  324. self.mimic_salt_install = False
  325. def finalize_options(self):
  326. develop.finalize_options(self)
  327. if 'WRITE_SALT_VERSION' in os.environ:
  328. self.write_salt_version = True
  329. if 'GENERATE_SALT_SYSPATHS' in os.environ:
  330. self.generate_salt_syspaths = True
  331. if 'MIMIC_SALT_INSTALL' in os.environ:
  332. self.mimic_salt_install = True
  333. if self.mimic_salt_install:
  334. self.write_salt_version = True
  335. self.generate_salt_syspaths = True
  336. def run(self):
  337. if IS_WINDOWS_PLATFORM:
  338. # Download the required DLLs
  339. self.distribution.salt_download_windows_dlls = True
  340. self.run_command('download-windows-dlls')
  341. self.distribution.salt_download_windows_dlls = None
  342. if self.write_salt_version is True:
  343. self.distribution.running_salt_install = True
  344. self.distribution.salt_version_hardcoded_path = SALT_VERSION_HARDCODED
  345. self.run_command('write_salt_version')
  346. if self.generate_salt_syspaths:
  347. self.distribution.salt_syspaths_hardcoded_path = SALT_SYSPATHS_HARDCODED
  348. self.run_command('generate_salt_syspaths')
  349. # Resume normal execution
  350. develop.run(self)
  351. class DownloadWindowsDlls(Command):
  352. description = 'Download required DLL\'s for windows'
  353. def initialize_options(self):
  354. pass
  355. def finalize_options(self):
  356. pass
  357. def run(self):
  358. if getattr(self.distribution, 'salt_download_windows_dlls', None) is None:
  359. print('This command is not meant to be called on it\'s own')
  360. exit(1)
  361. import pip
  362. # pip has moved many things to `_internal` starting with pip 10
  363. if LooseVersion(pip.__version__) < LooseVersion('10.0'):
  364. from pip.utils.logging import indent_log # pylint: disable=no-name-in-module
  365. else:
  366. from pip._internal.utils.logging import indent_log # pylint: disable=no-name-in-module
  367. platform_bits, _ = platform.architecture()
  368. url = 'https://repo.saltstack.com/windows/dependencies/{bits}/{fname}.dll'
  369. dest = os.path.join(os.path.dirname(sys.executable), '{fname}.dll')
  370. with indent_log():
  371. for fname in ('libeay32', 'libsodium', 'ssleay32', 'msvcr120'):
  372. # See if the library is already on the system
  373. if find_library(fname):
  374. continue
  375. furl = url.format(bits=platform_bits[:2], fname=fname)
  376. fdest = dest.format(fname=fname)
  377. if not os.path.exists(fdest):
  378. log.info('Downloading {0}.dll to {1} from {2}'.format(fname, fdest, furl))
  379. try:
  380. import requests
  381. from contextlib import closing
  382. with closing(requests.get(furl, stream=True)) as req:
  383. if req.status_code == 200:
  384. with open(fdest, 'wb') as wfh:
  385. for chunk in req.iter_content(chunk_size=4096):
  386. if chunk: # filter out keep-alive new chunks
  387. wfh.write(chunk)
  388. wfh.flush()
  389. else:
  390. log.error(
  391. 'Failed to download {0}.dll to {1} from {2}'.format(
  392. fname, fdest, furl
  393. )
  394. )
  395. except ImportError:
  396. req = urlopen(furl)
  397. if req.getcode() == 200:
  398. with open(fdest, 'wb') as wfh:
  399. if IS_PY3:
  400. while True:
  401. chunk = req.read(4096)
  402. if len(chunk) == 0:
  403. break
  404. wfh.write(chunk)
  405. wfh.flush()
  406. else:
  407. while True:
  408. for chunk in req.read(4096):
  409. if not chunk:
  410. break
  411. wfh.write(chunk)
  412. wfh.flush()
  413. else:
  414. log.error(
  415. 'Failed to download {0}.dll to {1} from {2}'.format(
  416. fname, fdest, furl
  417. )
  418. )
  419. class Sdist(sdist):
  420. def make_release_tree(self, base_dir, files):
  421. if self.distribution.ssh_packaging:
  422. self.distribution.salt_ssh_packaging_file = PACKAGED_FOR_SALT_SSH_FILE
  423. self.run_command('write_salt_ssh_packaging_file')
  424. self.filelist.files.append(os.path.basename(PACKAGED_FOR_SALT_SSH_FILE))
  425. if not IS_PY3 and not isinstance(base_dir, str):
  426. # Work around some bad code in distutils which logs unicode paths
  427. # against a str format string.
  428. base_dir = base_dir.encode('utf-8')
  429. sdist.make_release_tree(self, base_dir, files)
  430. # Let's generate salt/_version.py to include in the sdist tarball
  431. self.distribution.running_salt_sdist = True
  432. self.distribution.salt_version_hardcoded_path = os.path.join(
  433. base_dir, 'salt', '_version.py'
  434. )
  435. self.run_command('write_salt_version')
  436. def make_distribution(self):
  437. sdist.make_distribution(self)
  438. if self.distribution.ssh_packaging:
  439. os.unlink(PACKAGED_FOR_SALT_SSH_FILE)
  440. class CloudSdist(Sdist): # pylint: disable=too-many-ancestors
  441. user_options = Sdist.user_options + [
  442. ('download-bootstrap-script', None,
  443. 'Download the latest stable bootstrap-salt.sh script. This '
  444. 'can also be triggered by having `DOWNLOAD_BOOTSTRAP_SCRIPT=1` as an '
  445. 'environment variable.')
  446. ]
  447. boolean_options = Sdist.boolean_options + [
  448. 'download-bootstrap-script'
  449. ]
  450. def initialize_options(self):
  451. Sdist.initialize_options(self)
  452. self.skip_bootstrap_download = True
  453. self.download_bootstrap_script = False
  454. def finalize_options(self):
  455. Sdist.finalize_options(self)
  456. if 'SKIP_BOOTSTRAP_DOWNLOAD' in os.environ:
  457. log('Please stop using \'SKIP_BOOTSTRAP_DOWNLOAD\' and use ' # pylint: disable=not-callable
  458. '\'DOWNLOAD_BOOTSTRAP_SCRIPT\' instead')
  459. if 'DOWNLOAD_BOOTSTRAP_SCRIPT' in os.environ:
  460. download_bootstrap_script = os.environ.get(
  461. 'DOWNLOAD_BOOTSTRAP_SCRIPT', '0'
  462. )
  463. self.download_bootstrap_script = download_bootstrap_script == '1'
  464. def run(self):
  465. if self.download_bootstrap_script is True:
  466. # Let's update the bootstrap-script to the version defined to be
  467. # distributed. See BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION above.
  468. url = (
  469. 'https://github.com/saltstack/salt-bootstrap/raw/{0}'
  470. '/bootstrap-salt.sh'.format(
  471. BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION
  472. )
  473. )
  474. deploy_path = os.path.join(
  475. SETUP_DIRNAME,
  476. 'salt',
  477. 'cloud',
  478. 'deploy',
  479. 'bootstrap-salt.sh'
  480. )
  481. log.info(
  482. 'Updating bootstrap-salt.sh.'
  483. '\n\tSource: {0}'
  484. '\n\tDestination: {1}'.format(
  485. url,
  486. deploy_path
  487. )
  488. )
  489. try:
  490. import requests
  491. req = requests.get(url)
  492. if req.status_code == 200:
  493. script_contents = req.text.encode(req.encoding)
  494. else:
  495. log.error(
  496. 'Failed to update the bootstrap-salt.sh script. HTTP '
  497. 'Error code: {0}'.format(
  498. req.status_code
  499. )
  500. )
  501. except ImportError:
  502. req = urlopen(url)
  503. if req.getcode() == 200:
  504. script_contents = req.read()
  505. else:
  506. log.error(
  507. 'Failed to update the bootstrap-salt.sh script. HTTP '
  508. 'Error code: {0}'.format(
  509. req.getcode()
  510. )
  511. )
  512. try:
  513. with open(deploy_path, 'w') as fp_:
  514. fp_.write(script_contents)
  515. except (OSError, IOError) as err:
  516. log.error(
  517. 'Failed to write the updated script: {0}'.format(err)
  518. )
  519. # Let's the rest of the build command
  520. Sdist.run(self)
  521. def write_manifest(self):
  522. # We only need to ship the scripts which are supposed to be installed
  523. dist_scripts = self.distribution.scripts
  524. for script in self.filelist.files[:]:
  525. if not script.startswith('scripts/'):
  526. continue
  527. if script not in dist_scripts:
  528. self.filelist.files.remove(script)
  529. return Sdist.write_manifest(self)
  530. class TestCommand(Command):
  531. description = 'Run tests'
  532. user_options = [
  533. ('runtests-opts=', 'R', 'Command line options to pass to runtests.py')
  534. ]
  535. def initialize_options(self):
  536. self.runtests_opts = None
  537. def finalize_options(self):
  538. '''
  539. Abstract method that is required to be overwritten
  540. '''
  541. def run(self):
  542. from subprocess import Popen
  543. self.run_command('build')
  544. build_cmd = self.get_finalized_command('build_ext')
  545. runner = os.path.abspath('tests/runtests.py')
  546. test_cmd = sys.executable + ' {0}'.format(runner)
  547. if self.runtests_opts:
  548. test_cmd += ' {0}'.format(self.runtests_opts)
  549. print('running test')
  550. test_process = Popen(
  551. test_cmd, shell=True,
  552. stdout=sys.stdout, stderr=sys.stderr,
  553. cwd=build_cmd.build_lib
  554. )
  555. test_process.communicate()
  556. sys.exit(test_process.returncode)
  557. class Clean(clean):
  558. def run(self):
  559. clean.run(self)
  560. # Let's clean compiled *.py[c,o]
  561. for subdir in ('salt', 'tests', 'doc'):
  562. root = os.path.join(os.path.dirname(__file__), subdir)
  563. for dirname, _, _ in os.walk(root):
  564. for to_remove_filename in glob.glob('{0}/*.py[oc]'.format(dirname)):
  565. os.remove(to_remove_filename)
  566. INSTALL_VERSION_TEMPLATE = '''\
  567. # This file was auto-generated by salt's setup
  568. from salt.version import SaltStackVersion
  569. __saltstack_version__ = SaltStackVersion{full_version_info!r}
  570. '''
  571. INSTALL_SYSPATHS_TEMPLATE = '''\
  572. # This file was auto-generated by salt's setup on \
  573. {date:%A, %d %B %Y @ %H:%m:%S UTC}.
  574. ROOT_DIR = {root_dir!r}
  575. SHARE_DIR = {share_dir!r}
  576. CONFIG_DIR = {config_dir!r}
  577. CACHE_DIR = {cache_dir!r}
  578. SOCK_DIR = {sock_dir!r}
  579. SRV_ROOT_DIR= {srv_root_dir!r}
  580. BASE_FILE_ROOTS_DIR = {base_file_roots_dir!r}
  581. BASE_PILLAR_ROOTS_DIR = {base_pillar_roots_dir!r}
  582. BASE_MASTER_ROOTS_DIR = {base_master_roots_dir!r}
  583. BASE_THORIUM_ROOTS_DIR = {base_thorium_roots_dir!r}
  584. LOGS_DIR = {logs_dir!r}
  585. PIDFILE_DIR = {pidfile_dir!r}
  586. SPM_PARENT_PATH = {spm_parent_path!r}
  587. SPM_FORMULA_PATH = {spm_formula_path!r}
  588. SPM_PILLAR_PATH = {spm_pillar_path!r}
  589. SPM_REACTOR_PATH = {spm_reactor_path!r}
  590. HOME_DIR = {home_dir!r}
  591. '''
  592. class Build(build):
  593. def run(self):
  594. # Run build.run function
  595. build.run(self)
  596. if getattr(self.distribution, 'with_salt_version', False):
  597. # Write the hardcoded salt version module salt/_version.py
  598. self.distribution.salt_version_hardcoded_path = os.path.join(
  599. self.build_lib, 'salt', '_version.py'
  600. )
  601. self.run_command('write_salt_version')
  602. if getattr(self.distribution, 'running_salt_install', False):
  603. # If our install attribute is present and set to True, we'll go
  604. # ahead and write our install time python modules.
  605. # Write the hardcoded salt version module salt/_version.py
  606. self.run_command('write_salt_version')
  607. # Write the system paths file
  608. self.distribution.salt_syspaths_hardcoded_path = os.path.join(
  609. self.build_lib, 'salt', '_syspaths.py'
  610. )
  611. self.run_command('generate_salt_syspaths')
  612. class Install(install):
  613. def initialize_options(self):
  614. install.initialize_options(self)
  615. def finalize_options(self):
  616. install.finalize_options(self)
  617. def run(self):
  618. # Let's set the running_salt_install attribute so we can add
  619. # _version.py in the build command
  620. self.distribution.running_salt_install = True
  621. self.distribution.salt_version_hardcoded_path = os.path.join(
  622. self.build_lib, 'salt', '_version.py'
  623. )
  624. if IS_WINDOWS_PLATFORM:
  625. # Download the required DLLs
  626. self.distribution.salt_download_windows_dlls = True
  627. self.run_command('download-windows-dlls')
  628. self.distribution.salt_download_windows_dlls = None
  629. # Run install.run
  630. install.run(self)
  631. class InstallLib(install_lib):
  632. def run(self):
  633. executables = [
  634. 'salt/templates/git/ssh-id-wrapper',
  635. 'salt/templates/lxc/salt_tarball',
  636. ]
  637. install_lib.run(self)
  638. # input and outputs match 1-1
  639. inp = self.get_inputs()
  640. out = self.get_outputs()
  641. chmod = []
  642. for idx, inputfile in enumerate(inp):
  643. for executable in executables:
  644. if inputfile.endswith(executable):
  645. chmod.append(idx)
  646. for idx in chmod:
  647. filename = out[idx]
  648. os.chmod(filename, 0o755)
  649. # <---- Custom Distutils/Setuptools Commands -------------------------------------------------------------------------
  650. # ----- Custom Distribution Class ----------------------------------------------------------------------------------->
  651. # We use this to override the package name in case --ssh-packaging is passed to
  652. # setup.py or the special .salt-ssh-package is found
  653. class SaltDistribution(distutils.dist.Distribution):
  654. '''
  655. Just so it's completely clear
  656. Under windows, the following scripts should be installed:
  657. * salt-call
  658. * salt-cp
  659. * salt-minion
  660. * salt-unity
  661. * salt-proxy
  662. When packaged for salt-ssh, the following scripts should be installed:
  663. * salt-call
  664. * salt-run
  665. * salt-ssh
  666. * salt-cloud
  667. Under windows, the following scripts should be omitted from the salt-ssh package:
  668. * salt-cloud
  669. * salt-run
  670. Under *nix, all scripts should be installed
  671. '''
  672. global_options = distutils.dist.Distribution.global_options + [
  673. ('ssh-packaging', None, 'Run in SSH packaging mode'),
  674. ('salt-transport=', None, 'The transport to prepare salt for. Choices are \'zeromq\' '
  675. '\'raet\' or \'both\'. Defaults to \'zeromq\'', 'zeromq')] + [
  676. ('with-salt-version=', None, 'Set a fixed version for Salt instead calculating it'),
  677. # Salt's Paths Configuration Settings
  678. ('salt-root-dir=', None,
  679. 'Salt\'s pre-configured root directory'),
  680. ('salt-share-dir=', None,
  681. 'Salt\'s pre-configured share directory'),
  682. ('salt-config-dir=', None,
  683. 'Salt\'s pre-configured configuration directory'),
  684. ('salt-cache-dir=', None,
  685. 'Salt\'s pre-configured cache directory'),
  686. ('salt-sock-dir=', None,
  687. 'Salt\'s pre-configured socket directory'),
  688. ('salt-srv-root-dir=', None,
  689. 'Salt\'s pre-configured service directory'),
  690. ('salt-base-file-roots-dir=', None,
  691. 'Salt\'s pre-configured file roots directory'),
  692. ('salt-base-pillar-roots-dir=', None,
  693. 'Salt\'s pre-configured pillar roots directory'),
  694. ('salt-base-master-roots-dir=', None,
  695. 'Salt\'s pre-configured master roots directory'),
  696. ('salt-logs-dir=', None,
  697. 'Salt\'s pre-configured logs directory'),
  698. ('salt-pidfile-dir=', None,
  699. 'Salt\'s pre-configured pidfiles directory'),
  700. ('salt-spm-formula-dir=', None,
  701. 'Salt\'s pre-configured SPM formulas directory'),
  702. ('salt-spm-pillar-dir=', None,
  703. 'Salt\'s pre-configured SPM pillar directory'),
  704. ('salt-spm-reactor-dir=', None,
  705. 'Salt\'s pre-configured SPM reactor directory'),
  706. ('salt-home-dir=', None,
  707. 'Salt\'s pre-configured user home directory'),
  708. ]
  709. def __init__(self, attrs=None):
  710. distutils.dist.Distribution.__init__(self, attrs)
  711. self.ssh_packaging = PACKAGED_FOR_SALT_SSH
  712. self.salt_transport = None
  713. # Salt Paths Configuration Settings
  714. self.salt_root_dir = None
  715. self.salt_share_dir = None
  716. self.salt_config_dir = None
  717. self.salt_cache_dir = None
  718. self.salt_sock_dir = None
  719. self.salt_srv_root_dir = None
  720. self.salt_base_file_roots_dir = None
  721. self.salt_base_thorium_roots_dir = None
  722. self.salt_base_pillar_roots_dir = None
  723. self.salt_base_master_roots_dir = None
  724. self.salt_logs_dir = None
  725. self.salt_pidfile_dir = None
  726. self.salt_spm_parent_dir = None
  727. self.salt_spm_formula_dir = None
  728. self.salt_spm_pillar_dir = None
  729. self.salt_spm_reactor_dir = None
  730. self.salt_home_dir = None
  731. # Salt version
  732. self.with_salt_version = None
  733. self.name = 'salt-ssh' if PACKAGED_FOR_SALT_SSH else 'salt'
  734. self.salt_version = __version__ # pylint: disable=undefined-variable
  735. self.description = 'Portable, distributed, remote execution and configuration management system'
  736. kwargs = {}
  737. if IS_PY3:
  738. kwargs['encoding'] = 'utf-8'
  739. with open(SALT_LONG_DESCRIPTION_FILE, **kwargs) as f:
  740. self.long_description = f.read()
  741. self.long_description_content_type = 'text/x-rst'
  742. self.author = 'Thomas S Hatch'
  743. self.author_email = 'thatch45@gmail.com'
  744. self.url = 'http://saltstack.org'
  745. self.cmdclass.update({'test': TestCommand,
  746. 'clean': Clean,
  747. 'build': Build,
  748. 'sdist': Sdist,
  749. 'install': Install,
  750. 'write_salt_version': WriteSaltVersion,
  751. 'generate_salt_syspaths': GenerateSaltSyspaths,
  752. 'write_salt_ssh_packaging_file': WriteSaltSshPackagingFile})
  753. if not IS_WINDOWS_PLATFORM:
  754. self.cmdclass.update({'sdist': CloudSdist,
  755. 'install_lib': InstallLib})
  756. if IS_WINDOWS_PLATFORM:
  757. self.cmdclass.update({'download-windows-dlls': DownloadWindowsDlls})
  758. if WITH_SETUPTOOLS:
  759. self.cmdclass.update({'develop': Develop})
  760. self.license = 'Apache Software License 2.0'
  761. self.packages = self.discover_packages()
  762. self.zip_safe = False
  763. if HAS_ESKY:
  764. self.setup_esky()
  765. self.update_metadata()
  766. def update_metadata(self):
  767. for attrname in dir(self):
  768. if attrname.startswith('__'):
  769. continue
  770. attrvalue = getattr(self, attrname, None)
  771. if attrvalue == 0:
  772. continue
  773. if attrname == 'salt_version':
  774. attrname = 'version'
  775. if hasattr(self.metadata, 'set_{0}'.format(attrname)):
  776. getattr(self.metadata, 'set_{0}'.format(attrname))(attrvalue)
  777. elif hasattr(self.metadata, attrname):
  778. try:
  779. setattr(self.metadata, attrname, attrvalue)
  780. except AttributeError:
  781. pass
  782. def discover_packages(self):
  783. modules = []
  784. for root, _, files in os.walk(os.path.join(SETUP_DIRNAME, 'salt')):
  785. if '__init__.py' not in files:
  786. continue
  787. modules.append(os.path.relpath(root, SETUP_DIRNAME).replace(os.sep, '.'))
  788. return modules
  789. # ----- Static Data -------------------------------------------------------------------------------------------->
  790. @property
  791. def _property_classifiers(self):
  792. return ['Programming Language :: Python',
  793. 'Programming Language :: Cython',
  794. 'Programming Language :: Python :: 2.6',
  795. 'Programming Language :: Python :: 2.7',
  796. 'Development Status :: 5 - Production/Stable',
  797. 'Environment :: Console',
  798. 'Intended Audience :: Developers',
  799. 'Intended Audience :: Information Technology',
  800. 'Intended Audience :: System Administrators',
  801. 'License :: OSI Approved :: Apache Software License',
  802. 'Operating System :: POSIX :: Linux',
  803. 'Topic :: System :: Clustering',
  804. 'Topic :: System :: Distributed Computing']
  805. @property
  806. def _property_dependency_links(self):
  807. return ['https://github.com/saltstack/salt-testing/tarball/develop#egg=SaltTesting']
  808. @property
  809. def _property_tests_require(self):
  810. return ['SaltTesting']
  811. # <---- Static Data ----------------------------------------------------------------------------------------------
  812. # ----- Dynamic Data -------------------------------------------------------------------------------------------->
  813. @property
  814. def _property_package_data(self):
  815. package_data = {'salt.templates': ['rh_ip/*.jinja',
  816. 'debian_ip/*.jinja',
  817. 'virt/*.jinja',
  818. 'git/*',
  819. 'lxc/*',
  820. ]}
  821. if not IS_WINDOWS_PLATFORM:
  822. package_data['salt.cloud'] = ['deploy/*.sh']
  823. if not self.ssh_packaging and not PACKAGED_FOR_SALT_SSH:
  824. package_data['salt.daemons.flo'] = ['*.flo']
  825. return package_data
  826. @property
  827. def _property_data_files(self):
  828. # Data files common to all scenarios
  829. data_files = [
  830. ('share/man/man1', ['doc/man/salt-call.1', 'doc/man/salt-run.1']),
  831. ('share/man/man7', ['doc/man/salt.7'])
  832. ]
  833. if self.ssh_packaging or PACKAGED_FOR_SALT_SSH:
  834. data_files[0][1].append('doc/man/salt-ssh.1')
  835. if IS_WINDOWS_PLATFORM:
  836. return data_files
  837. data_files[0][1].append('doc/man/salt-cloud.1')
  838. return data_files
  839. if IS_WINDOWS_PLATFORM:
  840. data_files[0][1].extend(['doc/man/salt-cp.1',
  841. 'doc/man/salt-key.1',
  842. 'doc/man/salt-master.1',
  843. 'doc/man/salt-minion.1',
  844. 'doc/man/salt-proxy.1',
  845. 'doc/man/salt-unity.1'])
  846. return data_files
  847. # *nix, so, we need all man pages
  848. data_files[0][1].extend(['doc/man/salt-api.1',
  849. 'doc/man/salt-cloud.1',
  850. 'doc/man/salt-cp.1',
  851. 'doc/man/salt-key.1',
  852. 'doc/man/salt-master.1',
  853. 'doc/man/salt-minion.1',
  854. 'doc/man/salt-proxy.1',
  855. 'doc/man/spm.1',
  856. 'doc/man/salt.1',
  857. 'doc/man/salt-ssh.1',
  858. 'doc/man/salt-syndic.1',
  859. 'doc/man/salt-unity.1'])
  860. return data_files
  861. @property
  862. def _property_install_requires(self):
  863. install_requires = _parse_requirements_file(SALT_REQS)
  864. if self.salt_transport == 'zeromq':
  865. install_requires += _parse_requirements_file(SALT_ZEROMQ_REQS)
  866. elif self.salt_transport == 'raet':
  867. install_requires += _parse_requirements_file(SALT_RAET_REQS)
  868. if IS_WINDOWS_PLATFORM:
  869. install_requires = _parse_requirements_file(SALT_WINDOWS_REQS)
  870. return install_requires
  871. @property
  872. def _property_extras_require(self):
  873. if self.ssh_packaging:
  874. return {}
  875. return {'RAET': _parse_requirements_file(SALT_RAET_REQS)}
  876. @property
  877. def _property_scripts(self):
  878. # Scripts common to all scenarios
  879. scripts = ['scripts/salt-call', 'scripts/salt-run']
  880. if self.ssh_packaging or PACKAGED_FOR_SALT_SSH:
  881. scripts.append('scripts/salt-ssh')
  882. if IS_WINDOWS_PLATFORM:
  883. return scripts
  884. scripts.extend(['scripts/salt-cloud', 'scripts/spm'])
  885. return scripts
  886. if IS_WINDOWS_PLATFORM:
  887. scripts.extend(['scripts/salt',
  888. 'scripts/salt-cp',
  889. 'scripts/salt-key',
  890. 'scripts/salt-master',
  891. 'scripts/salt-minion',
  892. 'scripts/salt-proxy',
  893. 'scripts/salt-unity'])
  894. return scripts
  895. # *nix, so, we need all scripts
  896. scripts.extend(['scripts/salt',
  897. 'scripts/salt-api',
  898. 'scripts/salt-cloud',
  899. 'scripts/salt-cp',
  900. 'scripts/salt-key',
  901. 'scripts/salt-master',
  902. 'scripts/salt-minion',
  903. 'scripts/salt-ssh',
  904. 'scripts/salt-syndic',
  905. 'scripts/salt-unity',
  906. 'scripts/salt-proxy',
  907. 'scripts/spm'])
  908. return scripts
  909. @property
  910. def _property_entry_points(self):
  911. # console scripts common to all scenarios
  912. scripts = ['salt-call = salt.scripts:salt_call',
  913. 'salt-run = salt.scripts:salt_run']
  914. if self.ssh_packaging or PACKAGED_FOR_SALT_SSH:
  915. scripts.append('salt-ssh = salt.scripts:salt_ssh')
  916. if IS_WINDOWS_PLATFORM:
  917. return {'console_scripts': scripts}
  918. scripts.append('salt-cloud = salt.scripts:salt_cloud')
  919. return {'console_scripts': scripts}
  920. if IS_WINDOWS_PLATFORM:
  921. scripts.extend(['salt = salt.scripts:salt_main',
  922. 'salt-cp = salt.scripts:salt_cp',
  923. 'salt-key = salt.scripts:salt_key',
  924. 'salt-master = salt.scripts:salt_master',
  925. 'salt-minion = salt.scripts:salt_minion',
  926. 'salt-unity = salt.scripts:salt_unity',
  927. 'spm = salt.scripts:salt_spm'])
  928. return {'console_scripts': scripts}
  929. # *nix, so, we need all scripts
  930. scripts.extend(['salt = salt.scripts:salt_main',
  931. 'salt-api = salt.scripts:salt_api',
  932. 'salt-cloud = salt.scripts:salt_cloud',
  933. 'salt-cp = salt.scripts:salt_cp',
  934. 'salt-key = salt.scripts:salt_key',
  935. 'salt-master = salt.scripts:salt_master',
  936. 'salt-minion = salt.scripts:salt_minion',
  937. 'salt-ssh = salt.scripts:salt_ssh',
  938. 'salt-syndic = salt.scripts:salt_syndic',
  939. 'salt-unity = salt.scripts:salt_unity',
  940. 'spm = salt.scripts:salt_spm'])
  941. return {'console_scripts': scripts}
  942. # <---- Dynamic Data ---------------------------------------------------------------------------------------------
  943. # ----- Esky Setup ---------------------------------------------------------------------------------------------->
  944. def setup_esky(self):
  945. opt_dict = self.get_option_dict('bdist_esky')
  946. opt_dict['freezer_module'] = ('setup script', 'bbfreeze')
  947. opt_dict['freezer_options'] = ('setup script', {'includes': self.get_esky_freezer_includes()})
  948. @property
  949. def _property_freezer_options(self):
  950. return {'includes': self.get_esky_freezer_includes()}
  951. def get_esky_freezer_includes(self):
  952. # Sometimes the auto module traversal doesn't find everything, so we
  953. # explicitly add it. The auto dependency tracking especially does not work for
  954. # imports occurring in salt.modules, as they are loaded at salt runtime.
  955. # Specifying includes that don't exist doesn't appear to cause a freezing
  956. # error.
  957. freezer_includes = [
  958. 'zmq.core.*',
  959. 'zmq.utils.*',
  960. 'ast',
  961. 'csv',
  962. 'difflib',
  963. 'distutils',
  964. 'distutils.version',
  965. 'numbers',
  966. 'json',
  967. 'M2Crypto',
  968. 'Cookie',
  969. 'asyncore',
  970. 'fileinput',
  971. 'sqlite3',
  972. 'email',
  973. 'email.mime.*',
  974. 'requests',
  975. 'sqlite3',
  976. ]
  977. if HAS_ZMQ and hasattr(zmq, 'pyzmq_version_info'):
  978. if HAS_ZMQ and zmq.pyzmq_version_info() >= (0, 14):
  979. # We're freezing, and when freezing ZMQ needs to be installed, so this
  980. # works fine
  981. if 'zmq.core.*' in freezer_includes:
  982. # For PyZMQ >= 0.14, freezing does not need 'zmq.core.*'
  983. freezer_includes.remove('zmq.core.*')
  984. if IS_WINDOWS_PLATFORM:
  985. freezer_includes.extend([
  986. 'imp',
  987. 'win32api',
  988. 'win32file',
  989. 'win32con',
  990. 'win32com',
  991. 'win32net',
  992. 'win32netcon',
  993. 'win32gui',
  994. 'win32security',
  995. 'ntsecuritycon',
  996. 'pywintypes',
  997. 'pythoncom',
  998. '_winreg',
  999. 'wmi',
  1000. 'site',
  1001. 'psutil',
  1002. 'pytz',
  1003. ])
  1004. elif IS_SMARTOS_PLATFORM:
  1005. # we have them as requirements in pkg/smartos/esky/requirements.txt
  1006. # all these should be safe to force include
  1007. freezer_includes.extend([
  1008. 'cherrypy',
  1009. 'python-dateutil',
  1010. 'pyghmi',
  1011. 'croniter',
  1012. 'mako',
  1013. 'gnupg',
  1014. ])
  1015. elif sys.platform.startswith('linux'):
  1016. freezer_includes.append('spwd')
  1017. try:
  1018. import yum # pylint: disable=unused-variable
  1019. freezer_includes.append('yum')
  1020. except ImportError:
  1021. pass
  1022. elif sys.platform.startswith('sunos'):
  1023. # (The sledgehammer approach)
  1024. # Just try to include everything
  1025. # (This may be a better way to generate freezer_includes generally)
  1026. try:
  1027. from bbfreeze.modulegraph.modulegraph import ModuleGraph
  1028. mgraph = ModuleGraph(sys.path[:])
  1029. for arg in glob.glob('salt/modules/*.py'):
  1030. mgraph.run_script(arg)
  1031. for mod in mgraph.flatten():
  1032. if type(mod).__name__ != 'Script' and mod.filename:
  1033. freezer_includes.append(str(os.path.basename(mod.identifier)))
  1034. except ImportError:
  1035. pass
  1036. # Include C extension that convinces esky to package up the libsodium C library
  1037. # This is needed for ctypes to find it in libnacl which is in turn needed for raet
  1038. # see pkg/smartos/esky/sodium_grabber{.c,_installer.py}
  1039. freezer_includes.extend([
  1040. 'sodium_grabber',
  1041. 'ioflo',
  1042. 'raet',
  1043. 'libnacl',
  1044. ])
  1045. return freezer_includes
  1046. # <---- Esky Setup -----------------------------------------------------------------------------------------------
  1047. # ----- Overridden Methods -------------------------------------------------------------------------------------->
  1048. def parse_command_line(self):
  1049. args = distutils.dist.Distribution.parse_command_line(self)
  1050. if not self.ssh_packaging and PACKAGED_FOR_SALT_SSH:
  1051. self.ssh_packaging = 1
  1052. if self.ssh_packaging:
  1053. self.metadata.name = 'salt-ssh'
  1054. self.salt_transport = 'ssh'
  1055. elif self.salt_transport is None:
  1056. self.salt_transport = 'zeromq'
  1057. if self.salt_transport not in ('zeromq', 'raet', 'both', 'ssh', 'none'):
  1058. raise DistutilsArgError(
  1059. 'The value of --salt-transport needs be \'zeromq\', '
  1060. '\'raet\', \'both\', \'ssh\' or \'none\' not \'{0}\''.format(
  1061. self.salt_transport
  1062. )
  1063. )
  1064. # Setup our property functions after class initialization and
  1065. # after parsing the command line since most are set to None
  1066. # ATTENTION: This should be the last step before returning the args or
  1067. # some of the requirements won't be correctly set
  1068. for funcname in dir(self):
  1069. if not funcname.startswith('_property_'):
  1070. continue
  1071. property_name = funcname.split('_property_', 1)[-1]
  1072. setattr(self, property_name, getattr(self, funcname))
  1073. return args
  1074. # <---- Overridden Methods ---------------------------------------------------------------------------------------
  1075. # <---- Custom Distribution Class ------------------------------------------------------------------------------------
  1076. if __name__ == '__main__':
  1077. setup(distclass=SaltDistribution)