scanpypi 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. #!/usr/bin/env python2
  2. """
  3. Utility for building Buildroot packages for existing PyPI packages
  4. Any package built by scanpypi should be manually checked for
  5. errors.
  6. """
  7. from __future__ import print_function
  8. import argparse
  9. import json
  10. import urllib2
  11. import sys
  12. import os
  13. import shutil
  14. import StringIO
  15. import tarfile
  16. import zipfile
  17. import errno
  18. import hashlib
  19. import re
  20. import textwrap
  21. import tempfile
  22. import imp
  23. from functools import wraps
  24. def setup_decorator(func, method):
  25. """
  26. Decorator for distutils.core.setup and setuptools.setup.
  27. Puts the arguments with which setup is called as a dict
  28. Add key 'method' which should be either 'setuptools' or 'distutils'.
  29. Keyword arguments:
  30. func -- either setuptools.setup or distutils.core.setup
  31. method -- either 'setuptools' or 'distutils'
  32. """
  33. @wraps(func)
  34. def closure(*args, **kwargs):
  35. # Any python packages calls its setup function to be installed.
  36. # Argument 'name' of this setup function is the package's name
  37. BuildrootPackage.setup_args[kwargs['name']] = kwargs
  38. BuildrootPackage.setup_args[kwargs['name']]['method'] = method
  39. return closure
  40. # monkey patch
  41. import setuptools
  42. setuptools.setup = setup_decorator(setuptools.setup, 'setuptools')
  43. import distutils
  44. distutils.core.setup = setup_decorator(setuptools.setup, 'distutils')
  45. def find_file_upper_case(filenames, path='./'):
  46. """
  47. List generator:
  48. Recursively find files that matches one of the specified filenames.
  49. Returns a relative path starting with path argument.
  50. Keyword arguments:
  51. filenames -- List of filenames to be found
  52. path -- Path to the directory to search
  53. """
  54. for root, dirs, files in os.walk(path):
  55. for file in files:
  56. if file.upper() in filenames:
  57. yield (os.path.join(root, file))
  58. def pkg_buildroot_name(pkg_name):
  59. """
  60. Returns the Buildroot package name for the PyPI package pkg_name.
  61. Remove all non alphanumeric characters except -
  62. Also lowers the name and adds 'python-' suffix
  63. Keyword arguments:
  64. pkg_name -- String to rename
  65. """
  66. name = re.sub('[^\w-]', '', pkg_name.lower())
  67. prefix = 'python-'
  68. pattern = re.compile('^(?!' + prefix + ')(.+?)$')
  69. name = pattern.sub(r'python-\1', name)
  70. return name
  71. class DownloadFailed(Exception):
  72. pass
  73. class BuildrootPackage():
  74. """This class's methods are not meant to be used individually please
  75. use them in the correct order:
  76. __init__
  77. download_package
  78. extract_package
  79. load_module
  80. get_requirements
  81. create_package_mk
  82. create_hash_file
  83. create_config_in
  84. """
  85. setup_args = {}
  86. def __init__(self, real_name, pkg_folder):
  87. self.real_name = real_name
  88. self.buildroot_name = pkg_buildroot_name(self.real_name)
  89. self.pkg_dir = os.path.join(pkg_folder, self.buildroot_name)
  90. self.mk_name = self.buildroot_name.upper().replace('-', '_')
  91. self.as_string = None
  92. self.md5_sum = None
  93. self.metadata = None
  94. self.metadata_name = None
  95. self.metadata_url = None
  96. self.pkg_req = None
  97. self.setup_metadata = None
  98. self.tmp_extract = None
  99. self.used_url = None
  100. self.filename = None
  101. self.url = None
  102. self.version = None
  103. def fetch_package_info(self):
  104. """
  105. Fetch a package's metadata from the python package index
  106. """
  107. self.metadata_url = 'https://pypi.python.org/pypi/{pkg}/json'.format(
  108. pkg=self.real_name)
  109. try:
  110. pkg_json = urllib2.urlopen(self.metadata_url).read().decode()
  111. except urllib2.HTTPError as error:
  112. print('ERROR:', error.getcode(), error.msg, file=sys.stderr)
  113. print('ERROR: Could not find package {pkg}.\n'
  114. 'Check syntax inside the python package index:\n'
  115. 'https://pypi.python.org/pypi/ '
  116. .format(pkg=self.real_name))
  117. raise
  118. except urllib2.URLError:
  119. print('ERROR: Could not find package {pkg}.\n'
  120. 'Check syntax inside the python package index:\n'
  121. 'https://pypi.python.org/pypi/ '
  122. .format(pkg=self.real_name))
  123. raise
  124. self.metadata = json.loads(pkg_json)
  125. self.version = self.metadata['info']['version']
  126. self.metadata_name = self.metadata['info']['name']
  127. def download_package(self):
  128. """
  129. Download a package using metadata from pypi
  130. """
  131. try:
  132. self.metadata['urls'][0]['filename']
  133. except IndexError:
  134. print(
  135. 'Non-conventional package, ',
  136. 'please check carefully after creation')
  137. self.metadata['urls'] = [{
  138. 'packagetype': 'sdist',
  139. 'url': self.metadata['info']['download_url'],
  140. 'md5_digest': None}]
  141. # In this case, we can't get the name of the downloaded file
  142. # from the pypi api, so we need to find it, this should work
  143. urlpath = urllib2.urlparse.urlparse(
  144. self.metadata['info']['download_url']).path
  145. # urlparse().path give something like
  146. # /path/to/file-version.tar.gz
  147. # We use basename to remove /path/to
  148. self.metadata['urls'][0]['filename'] = os.path.basename(urlpath)
  149. for download_url in self.metadata['urls']:
  150. if 'bdist' in download_url['packagetype']:
  151. continue
  152. try:
  153. print('Downloading package {pkg} from {url}...'.format(
  154. pkg=self.real_name, url=download_url['url']))
  155. download = urllib2.urlopen(download_url['url'])
  156. except urllib2.HTTPError as http_error:
  157. download = http_error
  158. else:
  159. self.used_url = download_url
  160. self.as_string = download.read()
  161. if not download_url['md5_digest']:
  162. break
  163. self.md5_sum = hashlib.md5(self.as_string).hexdigest()
  164. if self.md5_sum == download_url['md5_digest']:
  165. break
  166. else:
  167. if download.__class__ == urllib2.HTTPError:
  168. raise download
  169. raise DownloadFailed('Failed to downloas package {pkg}'
  170. .format(pkg=self.real_name))
  171. self.filename = self.used_url['filename']
  172. self.url = self.used_url['url']
  173. def extract_package(self, tmp_path):
  174. """
  175. Extract the package contents into a directrory
  176. Keyword arguments:
  177. tmp_path -- directory where you want the package to be extracted
  178. """
  179. as_file = StringIO.StringIO(self.as_string)
  180. if self.filename[-3:] == 'zip':
  181. with zipfile.ZipFile(as_file) as as_zipfile:
  182. tmp_pkg = os.path.join(tmp_path, self.buildroot_name)
  183. try:
  184. os.makedirs(tmp_pkg)
  185. except OSError as exception:
  186. if exception.errno != errno.EEXIST:
  187. print("ERROR: ", exception.message, file=sys.stderr)
  188. return None, None
  189. print('WARNING:', exception.message, file=sys.stderr)
  190. print('Removing {pkg}...'.format(pkg=tmp_pkg))
  191. shutil.rmtree(tmp_pkg)
  192. os.makedirs(tmp_pkg)
  193. as_zipfile.extractall(tmp_pkg)
  194. else:
  195. with tarfile.open(fileobj=as_file) as as_tarfile:
  196. tmp_pkg = os.path.join(tmp_path, self.buildroot_name)
  197. try:
  198. os.makedirs(tmp_pkg)
  199. except OSError as exception:
  200. if exception.errno != errno.EEXIST:
  201. print("ERROR: ", exception.message, file=sys.stderr)
  202. return None, None
  203. print('WARNING:', exception.message, file=sys.stderr)
  204. print('Removing {pkg}...'.format(pkg=tmp_pkg))
  205. shutil.rmtree(tmp_pkg)
  206. os.makedirs(tmp_pkg)
  207. as_tarfile.extractall(tmp_pkg)
  208. tmp_extract = '{folder}/{name}-{version}'
  209. self.tmp_extract = tmp_extract.format(
  210. folder=tmp_pkg,
  211. name=self.metadata_name,
  212. version=self.version)
  213. def load_setup(self):
  214. """
  215. Loads the corresponding setup and store its metadata
  216. """
  217. current_dir = os.getcwd()
  218. os.chdir(self.tmp_extract)
  219. sys.path.append(self.tmp_extract)
  220. s_file, s_path, s_desc = imp.find_module('setup', [self.tmp_extract])
  221. setup = imp.load_module('setup', s_file, s_path, s_desc)
  222. try:
  223. self.setup_metadata = self.setup_args[self.metadata_name]
  224. except KeyError:
  225. # This means setup was not called which most likely mean that it is
  226. # called through the if __name__ == '__main__' directive.
  227. # In this case, we can only pray that it is called through a
  228. # function called main() in setup.py.
  229. setup.main([]) # Will raise AttributeError if not found
  230. self.setup_metadata = self.setup_args[self.metadata_name]
  231. # Here we must remove the module the hard way.
  232. # We must do this because of a very specific case: if a package calls
  233. # setup from the __main__ but does not come with a 'main()' function,
  234. # for some reason setup.main([]) will successfully call the main
  235. # function of a previous package...
  236. sys.modules.pop('setup',None)
  237. del setup
  238. os.chdir(current_dir)
  239. sys.path.remove(self.tmp_extract)
  240. def get_requirements(self, pkg_folder):
  241. """
  242. Retrieve dependencies from the metadata found in the setup.py script of
  243. a pypi package.
  244. Keyword Arguments:
  245. pkg_folder -- location of the already created packages
  246. """
  247. if 'install_requires' not in self.setup_metadata:
  248. self.pkg_req = None
  249. return set()
  250. self.pkg_req = self.setup_metadata['install_requires']
  251. self.pkg_req = [re.sub('([-.\w]+).*', r'\1', req)
  252. for req in self.pkg_req]
  253. req_not_found = self.pkg_req
  254. self.pkg_req = map(pkg_buildroot_name, self.pkg_req)
  255. pkg_tuples = zip(req_not_found, self.pkg_req)
  256. # pkg_tuples is a list of tuples that looks like
  257. # ('werkzeug','python-werkzeug') because I need both when checking if
  258. # dependencies already exist or are already in the download list
  259. req_not_found = set(
  260. pkg[0] for pkg in pkg_tuples
  261. if not os.path.isdir(pkg[1])
  262. )
  263. return req_not_found
  264. def __create_mk_header(self):
  265. """
  266. Create the header of the <package_name>.mk file
  267. """
  268. header = ['#' * 80 + '\n']
  269. header.append('#\n')
  270. header.append('# {name}\n'.format(name=self.buildroot_name))
  271. header.append('#\n')
  272. header.append('#' * 80 + '\n')
  273. header.append('\n')
  274. return header
  275. def __create_mk_download_info(self):
  276. """
  277. Create the lines refering to the download information of the
  278. <package_name>.mk file
  279. """
  280. lines = []
  281. version_line = '{name}_VERSION = {version}\n'.format(
  282. name=self.mk_name,
  283. version=self.version)
  284. lines.append(version_line)
  285. targz = self.filename.replace(
  286. self.version,
  287. '$({name}_VERSION)'.format(name=self.mk_name))
  288. targz_line = '{name}_SOURCE = {filename}\n'.format(
  289. name=self.mk_name,
  290. filename=targz)
  291. lines.append(targz_line)
  292. if self.filename not in self.url:
  293. # Sometimes the filename is in the url, sometimes it's not
  294. site_url = self.url
  295. else:
  296. site_url = self.url[:self.url.find(self.filename)]
  297. site_line = '{name}_SITE = {url}'.format(name=self.mk_name,
  298. url=site_url)
  299. site_line = site_line.rstrip('/') + '\n'
  300. lines.append(site_line)
  301. return lines
  302. def __create_mk_setup(self):
  303. """
  304. Create the line refering to the setup method of the package of the
  305. <package_name>.mk file
  306. There are two things you can use to make an installer
  307. for a python package: distutils or setuptools
  308. distutils comes with python but does not support dependencies.
  309. distutils is mostly still there for backward support.
  310. setuptools is what smart people use,
  311. but it is not shipped with python :(
  312. """
  313. lines = []
  314. setup_type_line = '{name}_SETUP_TYPE = {method}\n'.format(
  315. name=self.mk_name,
  316. method=self.setup_metadata['method'])
  317. lines.append(setup_type_line)
  318. return lines
  319. def __create_mk_license(self):
  320. """
  321. Create the lines referring to the package's license informations of the
  322. <package_name>.mk file
  323. The license is found using the metadata from pypi.
  324. In the metadata, the license can be found either with standard names in
  325. the classifiers part or with naming from the packager in the "License"
  326. part.
  327. From the classifiers, the license is "translated" according to
  328. buildroot standards if need be (i.e. from Apache Software License to
  329. Apache-2.0).
  330. From the License part, we cannot guess what formatting the packager
  331. used. Hence, it is likely to be incorrect. (i.e. Apache License 2.0
  332. instead of Apache-2.0).
  333. The license's files are found by searching the package for files named
  334. license or license.txt (case insensitive).
  335. If more than one license file is found, the user is asked to select
  336. which ones he wants to use.
  337. """
  338. license_dict = {
  339. 'Apache Software License': 'Apache-2.0',
  340. 'BSD License': 'BSD',
  341. 'European Union Public Licence 1.0': 'EUPL-1.0',
  342. 'European Union Public Licence 1.1': 'EUPL-1.1',
  343. "GNU General Public License": "GPL",
  344. "GNU General Public License v2": "GPL-2.0",
  345. "GNU General Public License v2 or later": "GPL-2.0+",
  346. "GNU General Public License v3": "GPL-3.0",
  347. "GNU General Public License v3 or later": "GPL-3.0+",
  348. "GNU Lesser General Public License v2": "LGPL-2.1",
  349. "GNU Lesser General Public License v2 or later": "LGPL-2.1+",
  350. "GNU Lesser General Public License v3": "LGPL-3.0",
  351. "GNU Lesser General Public License v3 or later": "LGPL-3.0+",
  352. "GNU Library or Lesser General Public License": "LGPL-2.0",
  353. "ISC License": "ISC",
  354. "MIT License": "MIT",
  355. "Mozilla Public License 1.0": "MPL-1.0",
  356. "Mozilla Public License 1.1": "MPL-1.1",
  357. "Mozilla Public License 2.0": "MPL-2.0",
  358. "Zope Public License": "ZPL"
  359. }
  360. regexp = re.compile('^License :* *.* *:+ (.*)( \(.*\))?$')
  361. classifiers_licenses = [regexp.sub(r"\1", lic)
  362. for lic in self.metadata['info']['classifiers']
  363. if regexp.match(lic)]
  364. licenses = map(lambda x: license_dict[x] if x in license_dict else x,
  365. classifiers_licenses)
  366. lines = []
  367. if not len(licenses):
  368. print('WARNING: License has been set to "{license}". It is most'
  369. ' likely wrong, please change it if need be'.format(
  370. license=', '.join(licenses)))
  371. licenses = [self.metadata['info']['license']]
  372. license_line = '{name}_LICENSE = {license}\n'.format(
  373. name=self.mk_name,
  374. license=', '.join(licenses))
  375. lines.append(license_line)
  376. filenames = ['LICENCE', 'LICENSE', 'LICENSE.TXT', 'COPYING',
  377. 'COPYING.TXT']
  378. license_files = list(find_file_upper_case(filenames, self.tmp_extract))
  379. license_files = [license.replace(self.tmp_extract, '')[1:]
  380. for license in license_files]
  381. if len(license_files) > 0:
  382. if len(license_files) > 1:
  383. print('More than one file found for license:',
  384. ', '.join(license_files))
  385. license_files = [filename
  386. for index, filename in enumerate(license_files)]
  387. license_file_line = ('{name}_LICENSE_FILES ='
  388. ' {files}\n'.format(
  389. name=self.mk_name,
  390. files=' '.join(license_files)))
  391. lines.append(license_file_line)
  392. else:
  393. print('WARNING: No license file found,'
  394. ' please specify it manually afterwards')
  395. license_file_line = '# No license file found\n'
  396. return lines
  397. def __create_mk_requirements(self):
  398. """
  399. Create the lines referring to the dependencies of the of the
  400. <package_name>.mk file
  401. Keyword Arguments:
  402. pkg_name -- name of the package
  403. pkg_req -- dependencies of the package
  404. """
  405. lines = []
  406. dependencies_line = ('{name}_DEPENDENCIES ='
  407. ' {reqs}\n'.format(
  408. name=self.mk_name,
  409. reqs=' '.join(self.pkg_req)))
  410. lines.append(dependencies_line)
  411. return lines
  412. def create_package_mk(self):
  413. """
  414. Create the lines corresponding to the <package_name>.mk file
  415. """
  416. pkg_mk = '{name}.mk'.format(name=self.buildroot_name)
  417. path_to_mk = os.path.join(self.pkg_dir, pkg_mk)
  418. print('Creating {file}...'.format(file=path_to_mk))
  419. lines = self.__create_mk_header()
  420. lines += self.__create_mk_download_info()
  421. lines += self.__create_mk_setup()
  422. lines += self.__create_mk_license()
  423. lines.append('\n')
  424. lines.append('$(eval $(python-package))')
  425. lines.append('\n')
  426. with open(path_to_mk, 'w') as mk_file:
  427. mk_file.writelines(lines)
  428. def create_hash_file(self):
  429. """
  430. Create the lines corresponding to the <package_name>.hash files
  431. """
  432. pkg_hash = '{name}.hash'.format(name=self.buildroot_name)
  433. path_to_hash = os.path.join(self.pkg_dir, pkg_hash)
  434. print('Creating {filename}...'.format(filename=path_to_hash))
  435. lines = []
  436. if self.used_url['md5_digest']:
  437. md5_comment = '# md5 from {url}, sha256 locally computed\n'.format(
  438. url=self.metadata_url)
  439. lines.append(md5_comment)
  440. hash_line = '{method}\t{digest} {filename}\n'.format(
  441. method='md5',
  442. digest=self.used_url['md5_digest'],
  443. filename=self.filename)
  444. lines.append(hash_line)
  445. digest = hashlib.sha256(self.as_string).hexdigest()
  446. hash_line = '{method}\t{digest} {filename}\n'.format(
  447. method='sha256',
  448. digest=digest,
  449. filename=self.filename)
  450. lines.append(hash_line)
  451. with open(path_to_hash, 'w') as hash_file:
  452. hash_file.writelines(lines)
  453. def create_config_in(self):
  454. """
  455. Creates the Config.in file of a package
  456. """
  457. path_to_config = os.path.join(self.pkg_dir, 'Config.in')
  458. print('Creating {file}...'.format(file=path_to_config))
  459. lines = []
  460. config_line = 'config BR2_PACKAGE_{name}\n'.format(
  461. name=self.mk_name)
  462. lines.append(config_line)
  463. bool_line = '\tbool "{name}"\n'.format(name=self.buildroot_name)
  464. lines.append(bool_line)
  465. if self.pkg_req:
  466. for dep in self.pkg_req:
  467. dep_line = '\tselect BR2_PACKAGE_{req} # runtime\n'.format(
  468. req=dep.upper().replace('-', '_'))
  469. lines.append(dep_line)
  470. lines.append('\thelp\n')
  471. help_lines = textwrap.wrap(self.metadata['info']['summary'],
  472. initial_indent='\t ',
  473. subsequent_indent='\t ')
  474. # make sure a help text is terminated with a full stop
  475. if help_lines[-1][-1] != '.':
  476. help_lines[-1] += '.'
  477. # \t + two spaces is 3 char long
  478. help_lines.append('')
  479. help_lines.append('\t ' + self.metadata['info']['home_page'])
  480. help_lines = map(lambda x: x + '\n', help_lines)
  481. lines += help_lines
  482. with open(path_to_config, 'w') as config_file:
  483. config_file.writelines(lines)
  484. def main():
  485. # Building the parser
  486. parser = argparse.ArgumentParser(
  487. description="Creates buildroot packages from the metadata of "
  488. "an existing PyPI packages and include it "
  489. "in menuconfig")
  490. parser.add_argument("packages",
  491. help="list of packages to be created",
  492. nargs='+')
  493. parser.add_argument("-o", "--output",
  494. help="""
  495. Output directory for packages.
  496. Default is ./package
  497. """,
  498. default='./package')
  499. args = parser.parse_args()
  500. packages = list(set(args.packages))
  501. # tmp_path is where we'll extract the files later
  502. tmp_prefix = 'scanpypi-'
  503. pkg_folder = args.output
  504. tmp_path = tempfile.mkdtemp(prefix=tmp_prefix)
  505. try:
  506. for real_pkg_name in packages:
  507. package = BuildrootPackage(real_pkg_name, pkg_folder)
  508. print('buildroot package name for {}:'.format(package.real_name),
  509. package.buildroot_name)
  510. # First we download the package
  511. # Most of the info we need can only be found inside the package
  512. print('Package:', package.buildroot_name)
  513. print('Fetching package', package.real_name)
  514. try:
  515. package.fetch_package_info()
  516. except (urllib2.URLError, urllib2.HTTPError):
  517. continue
  518. if package.metadata_name.lower() == 'setuptools':
  519. # setuptools imports itself, that does not work very well
  520. # with the monkey path at the begining
  521. print('Error: setuptools cannot be built using scanPyPI')
  522. continue
  523. try:
  524. package.download_package()
  525. except urllib2.HTTPError as error:
  526. print('Error: {code} {reason}'.format(code=error.code,
  527. reason=error.reason))
  528. print('Error downloading package :', package.buildroot_name)
  529. print()
  530. continue
  531. # extract the tarball
  532. try:
  533. package.extract_package(tmp_path)
  534. except (tarfile.ReadError, zipfile.BadZipfile):
  535. print('Error extracting package {}'.format(package.real_name))
  536. print()
  537. continue
  538. # Loading the package install info from the package
  539. try:
  540. package.load_setup()
  541. except ImportError as err:
  542. if 'buildutils' in err.message:
  543. print('This package needs buildutils')
  544. else:
  545. raise
  546. continue
  547. except AttributeError:
  548. print('Error: Could not install package {pkg}'.format(
  549. pkg=package.real_name))
  550. continue
  551. # Package requirement are an argument of the setup function
  552. req_not_found = package.get_requirements(pkg_folder)
  553. req_not_found = req_not_found.difference(packages)
  554. packages += req_not_found
  555. if req_not_found:
  556. print('Added packages \'{pkgs}\' as dependencies of {pkg}'
  557. .format(pkgs=", ".join(req_not_found),
  558. pkg=package.buildroot_name))
  559. print('Checking if package {name} already exists...'.format(
  560. name=package.pkg_dir))
  561. try:
  562. os.makedirs(package.pkg_dir)
  563. except OSError as exception:
  564. if exception.errno != errno.EEXIST:
  565. print("ERROR: ", exception.message, file=sys.stderr)
  566. continue
  567. print('Error: Package {name} already exists'
  568. .format(name=package.pkg_dir))
  569. del_pkg = raw_input(
  570. 'Do you want to delete existing package ? [y/N]')
  571. if del_pkg.lower() == 'y':
  572. shutil.rmtree(package.pkg_dir)
  573. os.makedirs(package.pkg_dir)
  574. else:
  575. continue
  576. package.create_package_mk()
  577. package.create_hash_file()
  578. package.create_config_in()
  579. print()
  580. # printing an empty line for visual confort
  581. finally:
  582. shutil.rmtree(tmp_path)
  583. if __name__ == "__main__":
  584. main()