Commits

yedpodtrzitko committed af7007b

bump

Comments (0)

Files changed (5)

bin/getpythondev.py

 URL = 'http://python.org/ftp/python/3.2.2/Python-3.2.2.tgz'
 HASH = '3c63a6d97333f4da35976b6a0755eb67'
 
+
 def main():
     filename = os.path.basename(URL)
 

bin/make-tart-distro.py

 #!/usr/bin/env python
 '''Package up files for a Tart binary distribution.'''
-
 import sys
 import os
 import argparse
 import errno
-import hashlib
 import subprocess
 import tempfile
 import zipfile
 
+from os.path import join, normpath, isdir, relpath, isfile
 
 PYDIR = 'Python-3.2.2'
 PYINC = 'Include'
-PYCONFIG = os.path.join(PYINC, 'pyconfig.h')
+PYCONFIG = join(PYINC, 'pyconfig.h')
 LIBDIR = 'libs'
 EXCLUDE = ['tart/tart-libs', 'bin/make-tart-distro.py', 'bin/getpythondev.py']
 PKGPREFIX = 'tart-'
 class Packager:
     def __init__(self, args):
         self.args = args
-        self.exclude = [os.path.normpath(x) for x in EXCLUDE]
-
+        self.exclude = [normpath(x) for x in EXCLUDE]
 
     def warning(self, msg):
         '''Print a warning to stderr and fail unless --force was used.'''
         if not self.args.force:
             sys.exit(1)
 
-
     def error(self, msg):
         '''Print an error message to stderr and fail.'''
         print('Error: ' + msg, file=sys.stderr)
         sys.exit(2)
 
-
     def chdir(self, folder):
         if self.args.verbose:
             print('chdir:', folder)
         os.chdir(folder)
 
-
     def do_cmd(self, cmd):
         if self.args.verbose:
             print('do_cmd:', cmd)
         # print(repr(output))
         return output
 
-
     def check_env(self):
         '''Check the build environment for required pieces.'''
         try:
                 sys.exit('Mercurial (hg) not found')
             raise
 
-        self.pydir = self.args.python or os.path.join(self.hgroot, PYDIR)
-        if not os.path.isdir(self.pydir):
+        self.pydir = self.args.python or join(self.hgroot, PYDIR)
+        if not isdir(self.pydir):
             self.error('Python source folder not found: ' + self.pydir)
 
-        pyconfig = os.path.join(self.pydir, PYCONFIG)
-        if not os.path.isfile(pyconfig):
+        pyconfig = join(self.pydir, PYCONFIG)
+        if not isfile(pyconfig):
             self.error('pyconfig.h not found: ' + pyconfig)
 
-        self.libdir = self.args.libs or os.path.join(self.hgroot, LIBDIR)
-        if not os.path.isdir(self.libdir):
+        self.libdir = self.args.libs or join(self.hgroot, LIBDIR)
+        if not isdir(self.libdir):
             self.error('libs folder not found: ' + self.libdir)
 
-
     def make_archive(self, rootpath):
         '''Create archive folder from specified repo root.'''
         if ' ' in rootpath:
             self.args.rev)
         self.do_cmd(cmd)
 
-
     def create_links(self, source, dest):
         '''Make hard links to build dependencies to resolve Makefile paths.'''
         # print('make base dir', dest)
 
         for base, dirs, files in os.walk(source):
             # print('base', base, 'dirs', dirs)
-            relbase = os.path.relpath(base, source)
+            relbase = relpath(base, source)
             # print('relbase', relbase)
             for d in dirs:
-                path = os.path.join(dest, relbase, d)
+                path = join(dest, relbase, d)
                 # print('makedir', path)
                 os.makedirs(path)
 
             for f in files:
                 # print(dest, base, f)
-                path = os.path.join(dest, relbase, f)
+                path = join(dest, relbase, f)
                 # print('make link', path)
-                os.link(os.path.join(base, f), path)
-
+                os.link(join(base, f), path)
 
     def build_from_archive(self):
         '''Extract specified rev/tag into archive folder and build.'''
             self.chdir(tempdir)
             try:
                 self.make_archive(self.hgroot)
-                self.create_links(os.path.join(self.pydir, PYINC), os.path.join(PYDIR, PYINC))
+                self.create_links(join(self.pydir, PYINC), join(PYDIR, PYINC))
                 self.create_links(self.libdir, LIBDIR)
                 self.build()
 
             finally:
                 self.chdir(self.origdir)
 
-
     def build(self):
         if '+' in self.revid:
             self.warning('working copy has uncommitted changes!')
             print('building package', name)
         self.package(name)
 
-
     def is_excluded(self, path):
-        path = os.path.normpath(path)
+        path = normpath(path)
         for test in self.exclude:
             if path.startswith(test):
                 if self.args.verbose:
                 return True
         return False
 
-
     def package(self, name):
-        pkgpath = os.path.join(self.origdir, name + '.zip')
+        pkgpath = join(self.origdir, name + '.zip')
 
         with zipfile.ZipFile(pkgpath, 'w') as pkg:
             pkg.writestr('tart/tart.hgid', name)
                     continue
 
                 for f in files:
-                    path = os.path.join(base, f)
-                    exclude = False
+                    path = join(base, f)
                     if self.is_excluded(path):
                         continue
 
                     continue
 
                 for f in files:
-                    path = os.path.join(base, f)
-                    exclude = False
+                    path = join(base, f)
                     if self.is_excluded(path):
                         continue
 
 
         print('created package', pkgpath)
 
-
     def run(self):
         self.origdir = os.getcwd()
         self.check_env()
         self.build_from_archive()
 
 
-
 if __name__ == '__main__':
     parser = argparse.ArgumentParser()
     parser.add_argument('--python', metavar='PATH',
 
     packager = Packager(args)
     packager.run()
-

bin/tartutil/commands/package.py

 '''Package an app for release or debug.'''
-from genericpath import isfile
 import sys
 import os
 import datetime as dt
 import struct
 import tempfile
 
-from os.path import dirname, join, basename, normpath, exists, relpath
+from os.path import dirname, join, basename, normpath, exists, relpath, isfile
 
 from py_compile import MAGIC, PyCompileError
 
 from .. import command, project
 from ..core import tart
-
+from ..tart_conf import BUILD_ID
 
 BAR_TEMPLATE = join(dirname(__file__), 'bar-descriptor-template.xml')
 
             help='path to project (default: current directory)')
 
     def run(self, args):
+        include = set()
+        config = Bag()
+
+        def opt(*args):
+            command.extend(args)
+
         self.args = args
         if args.verbose:
             print('package args', args)
         if self.args.verbose:
             print('project', self.project)
 
-        config = Bag()
         config.id = self.project.config('id')
         if not config.id:
             idbase = tart.config('idbase')
 
         # create a _buildId file if it doesn't already exist
         # TODO: make this configurable too: some devs won't want auto-increment
-        buildIdFile = self.project.relpath('_buildId')
-        if not exists(buildIdFile):
-            with open(buildIdFile, 'w') as f:
-                f.write('0')
+        if BUILD_ID:
+            buildIdFile = self.project.relpath('_buildId')
+            if not exists(buildIdFile):
+                with open(buildIdFile, 'w') as f:
+                    f.write('0')
+            opt('-buildIdFile', buildIdFile)
 
         config.desc = self.project.config('description', 'The {} app'.format(appname))
         config.theme = self.project.config('theme', 'dark')
         with open(BAR_TEMPLATE) as ftemplate:
             bardesc = ftemplate.read().format(cfg=config)
 
-        include = set()
-
         if args.mode != 'quick':
             # these are always included
             # include.add((join(tartdistro, 'js'), 'tart.js'))
 
             include.update(self.find_modules(tartdistro))
 
-        # print('include')
-        # print('\n'.join('%s  %s' % x for x in sorted(include)))
         with tempfile.TemporaryDirectory(prefix='tart-', dir='.') as tdir:
             os.chdir(tdir)
             try:
 
                 command = ['blackberry-nativepackager']
 
-                def opt(*args):
-                    command.extend(args)
-
                 opt('-package', pkgname)
 
                 if devMode:
                     opt('-devMode')
 
-                opt('-buildIdFile', buildIdFile)
-
                 opt('-configuration', config.configuration)
 
                 opt('-env', 'PYTHONDONTWRITEBYTECODE=1')
                 opt('@' + optfile)
 
                 res = self.do_cmd(command)
-                print(res)
 
                 # probably too messy... find better way? (ask user?)
+                input('foo')
                 if exists(pkgname):
                     dest = join('..', pkgname)
                     if exists(dest):
 
     def do_cmd(self, cmd):
         if self.args.verbose:
-            print('do_cmd:', cmd)
+            print('\ndo_cmd:', cmd, '\n')
         p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
         output = p.stdout.read().decode('ascii').strip()
         stderr = p.stderr.read().decode('ascii').strip()

bin/tartutil/commands/quickdeploy.py

 # see also http://msdn.microsoft.com/en-us/library/windows/desktop/aa364391%28v=vs.85%29.aspx
 
 from __future__ import print_function
-from genericpath import exists
 
 import os
 import sys
 
 from collections import OrderedDict, defaultdict, namedtuple
 
-from os.path import basename, join, relpath, normpath, sep
+from os.path import basename, join, relpath, normpath, sep, exists, dirname, isdir
 
 try:
     import win32file
     return time.time() - basetime
 
 
-
 #------------------------------------------------
 #
 class Filter:
     CMD_INCLUDE = 'include'
     CMD_EXCLUDE = 'exclude'
 
-    def __init__(self, base, rules=[]):
+    def __init__(self, base, rules=None):
         self.base = base
         self.reset()
-        self.add_rules(rules)
-        # print('base', self.base)
+        self.add_rules(rules or [])
 
     def reset(self):
         self.default_outcome = Filter.DEFAULT_OUTCOME
     def populate(self):
         for base, dirs, files in os.walk(self.path):
             for name in files:
-                path = join(base, name)
-                path = self.filter(path)
+                path = self.filter(join(base, name))
                 if not path:
                     continue
 
             print(self.files[path])
 
 
-
 #------------------------------------------------
 #
 class SourceMonitor_win32:
     def run(self, args):
         app = QuickDeploy(args)
         app.main()
-
-
-# EOF

bin/tartutil/tart_conf.py

 
 ININAME = 'tart-project.ini'       # found in current or ancestor folder
 DEFSECTION = 'project'
+
+BUILD_ID = False