Example #1
0
def compile_idl(idl_compiler, include_dirs, current_dir, files):
  """
  compile_idl
    - idl_compiler: [string] path to omniidl executable
    - include_dirs: [list] path list for include directories
    - current_dir : [string] directory where stubs are generated
    - files       : [list] IDL file list
  """
  # create command and option list
  cmd = [idl_compiler, "-bpython"]
  if include_dirs: cmd += ["-I" + inc for inc in include_dirs]
  if current_dir : cmd += ["-C" + current_dir]
  cmd += files
  # function to be given dist.util.execute
  def exec_idl_compile(cmd_str):
    cmdline = string.join(cmd_str)
    if os_is() == "win32":
      os.system(cmdline)
      return
    log.info(cmdline)
    status, output = commands.getstatusoutput(cmdline)
    log.info(output)
    if status != 0:
      raise errors.DistutilsExecError("Return status of %s is %d" %
                                      (cmd, status))
    return
  # compile IDL by using dist.util.execute
  util.execute(exec_idl_compile, [cmd],
               "Generating python stubs from IDL files")
Example #2
0
def create_doc(doxygen_conf, target_dir):
  """
  create_doc
    - doxygen_conf: [string] path to Doxygen's conf file
    - target_dir  : [string] directory to where doxygen generates documentation
  """
  def exec_doxygen(cmd):
    # remove target dir
    if os.path.exists(target_dir + "/html/index.html"):
      return
    if os.path.exists(target_dir):
      shutil.rmtree(target_dir)

    cmdline = string.join(cmd)
    if os_is() == "win32":
      os.system(cmdline)
      return
    log.info(cmdline)
    status, output = commands.getstatusoutput(cmdline)
    log.info(output)
    if status != 0:
      raise errors.DistutilsExecError("Return status of %s is %d" %
                                      (cmd, status))
    return
  # compile IDL by using dist.util.execute
  docdir = os.path.dirname(doxygen_conf)
  tmp = os.getcwd()
  os.chdir(docdir)
  cmd = ["doxygen", doxygen_conf]
  util.execute(exec_doxygen, [cmd],
               "Generating documentation")
  os.chdir(tmp)
Example #3
0
def make_rules():
    if 'sdist' in sys.argv: return
    description = "install udev or devd rules (pip must be run as root)"

    udev_reload = ['udevadm', 'control', '--reload-rules']
    udev_trigger = [
        'udevadm', 'trigger', '--subsystem-match=usb',
        '--attr-match=idVendor=1A86', '--action=add'
    ]
    devd_restart = ['service', 'devd', 'restart']
    linux_create_group = ['groupadd', 'dialout']
    fbsd_create_group = ['pw', 'groupadd', 'sispmctl']

    print('installing rules for accessing KuttyPy hardware...', sys.argv)
    system = platform.system()
    if os.getuid() != 0 and system in ['Linux', 'FreeBSD']:
        raise OSError(
            'You must have root privileges to install udev/devd rules! sudo pip3 install kuttyPy'
        )
    if system == 'Linux':
        shutil.copy('resources/99-kuttypy-pip.rules', '/etc/udev/rules.d/')
        execute(lambda: call(linux_create_group), [], "Creating dialout group")
        execute(lambda: call(udev_reload), [], "Reloading udev rules")
        execute(lambda: call(udev_trigger), [], "Triggering udev rules")
    elif system == 'FreeBSD':
        shutil.copy('resources/sispmctl.conf', '/usr/local/etc/devd/')
        execute(lambda: call(fbsd_create_group), [], "Creating sispmctl group")
        execute(lambda: call(devd_restart), [], "Restarting devd")
    else:
        print("Not Linux, nothing to do.")
Example #4
0
 def create_conf_file (self, data, directory=None):
     """Create local config file from given data (list of lines) in
     the directory (or current directory if not given)."""
     data.insert(0, "# this file is automatically created by setup.py")
     data.insert(0, "# -*- coding: iso-8859-1 -*-")
     if directory is None:
         directory = os.getcwd()
     filename = self.get_conf_filename(directory)
     # add metadata
     metanames = ("name", "version", "author", "author_email",
                  "maintainer", "maintainer_email", "url",
                  "license", "description", "long_description",
                  "keywords", "platforms", "fullname", "contact",
                  "contact_email")
     for name in metanames:
         method = "get_" + name
         val = getattr(self.metadata, method)()
         if isinstance(val, str):
             val = unicode(val)
         cmd = "%s = %r" % (name, val)
         data.append(cmd)
     data.append('release_date = "%s"' % get_release_date())
     data.append('portable = %s' % get_portable())
     # write the config file
     util.execute(write_file, (filename, data),
                  "creating %s" % filename, self.verbose >= 1, self.dry_run)
Example #5
0
File: setup.py Project: saimir/FRED
    def run(self):
        self.omniidl_params = g_omniidl_params
        self.modules = g_modules
        if not os.path.isdir(
                os.path.join(self.rundir, 'build', 'stubs', 'pyfred',
                             'idlstubs')):
            os.makedirs(
                os.path.join(self.rundir, 'build', 'stubs', 'pyfred',
                             'idlstubs'))
        #create (if need) idl files
        self.omniidl_params.append("-Wbpackage=pyfred.idlstubs")
        if not self.idlforce and os.access(
                os.path.join(self.rundir, "build/stubs/pyfred/idlstubs/ccReg"),
                os.F_OK):
            log.info(
                "IDL stubs found, skipping building IDL stubs. Use idlforce "
                "option to compile idl stubs anyway or run clean target.")
        else:
            util.execute(compile_idl, (self.omniidl, self.omniidl_params, [
                gen_idl_name(self.idldir, module) for module in self.modules
            ]), "Generating python stubs from IDL files")

        self.data_files = self.data_files +\
                file_util.all_files_in('PURELIBDIR',
                        os.path.join('build', 'stubs', 'pyfred', 'idlstubs'),
                        recursive=True, cutSlashes_dst=1)
        install_data.run(self)

        # TODO so far is impossible to create rpm package with unittests \
        # scripts in it, because of update_* methods have wrong paths \
        # to files which should be changed.
        if self.install_unittests or self.is_bdist_mode:
            self.update_test_filemanager()
            self.update_test_genzone()
Example #6
0
 def create_conf_file(self, data, directory=None):
     """Create local config file from given data (list of lines) in
     the directory (or current directory if not given)."""
     data.insert(0, "# this file is automatically created by setup.py")
     data.insert(0, "# -*- coding: iso-8859-1 -*-")
     if directory is None:
         directory = os.getcwd()
     filename = self.get_conf_filename(directory)
     # add metadata
     metanames = ("name", "version", "author", "author_email", "maintainer",
                  "maintainer_email", "url", "license", "description",
                  "long_description", "keywords", "platforms", "fullname",
                  "contact", "contact_email")
     for name in metanames:
         method = "get_" + name
         val = getattr(self.metadata, method)()
         if isinstance(val, str):
             val = unicode(val)
         cmd = "%s = %r" % (name, val)
         data.append(cmd)
     data.append('release_date = "%s"' % get_release_date())
     data.append('portable = %s' % get_portable())
     # write the config file
     util.execute(write_file, (filename, data), "creating %s" % filename,
                  self.verbose >= 1, self.dry_run)
Example #7
0
    def run(self):
        self.omniidl_params = g_omniidl_params
        self.modules = g_modules
        if not os.path.isdir(os.path.join(self.rundir, 'build', 'stubs', 'pyfred', 'idlstubs')):
            os.makedirs(os.path.join(self.rundir, 'build', 'stubs', 'pyfred', 'idlstubs'))
        #create (if need) idl files
        self.omniidl_params.append("-Wbpackage=pyfred.idlstubs")
        if not self.idlforce and os.access(
                os.path.join(self.rundir, "build/stubs/pyfred/idlstubs/ccReg"),
                    os.F_OK):
            log.info("IDL stubs found, skipping building IDL stubs. Use idlforce "
                    "option to compile idl stubs anyway or run clean target.")
        else:
            util.execute(compile_idl,
                (self.omniidl, self.omniidl_params,
                    [ gen_idl_name(self.idldir, module) for module in self.modules ]),
                    "Generating python stubs from IDL files")

        self.data_files = self.data_files +\
                file_util.all_files_in('PURELIBDIR',
                        os.path.join('build', 'stubs', 'pyfred', 'idlstubs'),
                        recursive=True, cutSlashes_dst=1)
        install_data.run(self)

        # TODO so far is impossible to create rpm package with unittests \ 
        # scripts in it, because of update_* methods have wrong paths \
        # to files which should be changed.
        if self.install_unittests or self.is_bdist_mode:
            self.update_test_filemanager()
            self.update_test_genzone()
Example #8
0
def install_udev_rules(raise_exception):
    if check_root():
        shutil.copy('resources/ant-usb-sticks.rules', '/etc/udev/rules.d')
        execute(udev_reload_rules, [], "Reloading udev rules")
        execute(udev_trigger, [], "Triggering udev rules")
    else:
        msg = "copy resources/ant-usb-sticks.rules to /etc/udev/rules.d"
        print(msg)
Example #9
0
  def run(self):
    #self.omniidl_params.append("-Wbpackage=OpenRTM_aist.RTM_IDL")
    self.omniidl_params.append("-COpenRTM_aist/examples/SimpleService")
    self.omniidl_params.append("-IOpenRTM_aist/examples/SimpleService")
    modules = ["MyService"]

    util.execute(compile_idl,
                 (self.omniidl, self.omniidl_params,
                  [ gen_idl_name(self.idldir, module) for module in modules ]),
                 "Generating python sample stubs from IDL files")
Example #10
0
def install_udev_rules(raise_exception):
	if check_root():
		shutil.copy('vLabtool/calib_data/proto.rules', '/etc/udev/rules.d')
		execute(udev_reload_rules, [], "Reloading udev rules")
		execute(udev_trigger, [], "Triggering udev rules")
	else:
		msg = "You must have root privileges to install udev rules. Run 'sudo python setup.py install'"
		if raise_exception:
			raise OSError(msg)
		else:
			print(msg)
Example #11
0
def install_udev_rules(raise_exception):
    if check_root():
        shutil.copy('resources/ant-usb-sticks.rules', '/etc/udev/rules.d')
        execute(udev_reload_rules, [], "Reloading udev rules")
        execute(udev_trigger, [], "Triggering udev rules")
    else:
        msg = "You must have root privileges to install udev rules. Run \"sudo python setup.py udev_rules\""
        if raise_exception:
            raise OSError(msg)
        else:
            print(msg)
Example #12
0
def install_udev_rules(raise_exception):
    if check_root():
        shutil.copy('resources/ant-usb-sticks.rules', '/etc/udev/rules.d')
        execute(udev_reload_rules, [], "Reloading udev rules")
        execute(udev_trigger, [], "Triggering udev rules")
    else:
        msg = "You must have root privileges to install udev rules. Run \"sudo python setup.py udev_rules\""
        if raise_exception:
            raise OSError(msg)
        else:
            print(msg)
Example #13
0
 def run(self):
     """Prepare and create tarball"""
     snapshot_name = "%s-%s" % (__pkg_data__.MODULE.__name__,
                                time.strftime("%Y-%m-%d"))
     snapshot_location = "dist/%s" % snapshot_name
     if os.path.isdir(snapshot_location):
         execute(shutil.rmtree, (snapshot_location, ))
     execute(self.generate_tree, (snapshot_location, ))
     execute(write_changelog, ("%s/ChangeLog" % snapshot_location, ))
     execute(make_archive, (snapshot_location, "bztar", "dist",
                            snapshot_name))
     execute(shutil.rmtree, (snapshot_location, ))
Example #14
0
def install_udev_rules(raise_exception):
    if check_root():
        if platform.system() != 'Linux':
            return
        shutil.copy("resources/42-ant-usb-sticks.rules", "/etc/udev/rules.d")
        execute(udev_reload_rules, [], "Reloading udev rules")
        execute(udev_trigger, [], "Triggering udev rules")
    else:
        msg = 'You must have root privileges to install udev rules. Run "sudo python setup.py udev_rules"'
        if raise_exception:
            raise OSError(msg)
        else:
            print(msg)
Example #15
0
 def build_configuration(self, arch_list):
     #
     template, variables = self.get_config_data(arch_list)
     config_data = template % variables
     #
     build_lib   = self.build_lib
     dist_name   = self.distribution.get_name()
     config_file = os.path.join(build_lib, dist_name, 'lib',
                                dist_name.replace('4py', '') + '.cfg')
     #
     def write_file(filename, data):
         with open(filename, 'w') as fh:
             fh.write(config_data)
     execute(write_file, (config_file, config_data),
             msg='writing %s' % config_file,
             verbose=self.verbose, dry_run=self.dry_run)
Example #16
0
 def build_configuration(self, arch_list):
     #
     template, variables = self.get_config_data(arch_list)
     config_data = template % variables
     #
     build_lib   = self.build_lib
     dist_name   = self.distribution.get_name()
     config_file = os.path.join(build_lib, dist_name, 'lib',
                                dist_name.replace('4py', '') + '.cfg')
     #
     def write_file(filename, data):
         with open(filename, 'w') as fh:
             fh.write(config_data)
     execute(write_file, (config_file, config_data),
             msg='writing %s' % config_file,
             verbose=self.verbose, dry_run=self.dry_run)
Example #17
0
def create_doc(doxygen_conf, target_dir):
    """
    create_doc
      - doxygen_conf: [string] path to Doxygen's conf file
      - target_dir  : [string] directory to where doxygen generates documentation
    """
    def exec_doxygen(cmd):
        # remove target dir
        if os.path.exists(target_dir + "/html/index.html"):
            return
        if os.path.exists(target_dir):
            shutil.rmtree(target_dir)

        #cmdline = string.join(cmd)
        cmdline = " ".join(cmd)
        if os_is() == "win32":
            os.system(cmdline)
            return
        log.info(cmdline)
        if sys.version_info[0] == 2:
            status, output = commands.getstatusoutput(cmdline)
            log.info(output)
        else:
            try:
                proc = subprocess.run(
                    cmdline,
                    shell=True,
                    check=True,
                    stdout=subprocess.PIPE,
                    stderr=subprocess.PIPE)
                status = 0
                log.info(proc.stdout.decode("UTF-8"))
            except BaseException:
                status = 1

        if status != 0:
            raise errors.DistutilsExecError("Return status of %s is %d" %
                                            (cmd, status))
        return
    # compile IDL by using dist.util.execute
    docdir = os.path.dirname(doxygen_conf)
    tmp = os.getcwd()
    os.chdir(docdir)
    cmd = ["doxygen", doxygen_conf]
    util.execute(exec_doxygen, [cmd],
                 "Generating documentation")
    os.chdir(tmp)
Example #18
0
def compile_idl(idl_compiler, include_dirs, current_dir, files):
    """
    compile_idl
      - idl_compiler: [string] path to omniidl executable
      - include_dirs: [list] path list for include directories
      - current_dir : [string] directory where stubs are generated
      - files       : [list] IDL file list
    """
    # create command and option list
    cmd = [idl_compiler, "-bpython"]
    if include_dirs:
        cmd += ["-I" + inc for inc in include_dirs]
    if current_dir:
        cmd += ["-C" + current_dir]
    cmd += files

    # function to be given dist.util.execute

    def exec_idl_compile(cmd_str):
        #cmdline = string.join(cmd_str)
        cmdline = " ".join(cmd_str)
        if os_is() == "win32":
            os.system(cmdline)
            return
        log.info(cmdline)
        if sys.version_info[0] == 2:
            status, output = commands.getstatusoutput(cmdline)
            log.info(output)
        else:
            try:
                proc = subprocess.run(cmdline,
                                      shell=True,
                                      check=True,
                                      stdout=subprocess.PIPE,
                                      stderr=subprocess.PIPE)
                status = 0
                log.info(proc.stdout.decode("UTF-8"))
            except BaseException:
                status = 1
        if status != 0:
            raise errors.DistutilsExecError("Return status of %s is %d" %
                                            (cmd, status))
        return

    # compile IDL by using dist.util.execute
    util.execute(exec_idl_compile, [cmd],
                 "Generating python stubs from IDL files")
Example #19
0
    def build_idl(self, path):
        path = self.get_idl_path(path)
        if not os.path.isfile(path):
            raise DistutilsFileError('Unable to find idl file, "%s"' %
                                     (path, ))

        # XXX "find" thrift instead of hardcoding the path here
        command = [
            '/usr/local/bin/thrift', '--gen', 'py', '-r', '-o', self.build_lib,
            path
        ]

        spawn(command, dry_run=self.dry_run)

        # thrift puts everything in a gen-py folder... That's lame; let's
        # dump it into the buildroot instead.
        gen_path = os.path.join(self.build_lib, 'gen-py')
        for item in os.listdir(gen_path):
            src = os.path.join(gen_path, item)
            dst = os.path.join(self.build_lib, item)

            # Skip move of __init__.py files if there are already ones in the
            # build dir.  In that case, just delete them.
            if item == '__init__.py' and os.path.isfile(dst):
                execute(os.remove, (src, ),
                        "skipping copy of %s" % dst,
                        dry_run=self.dry_run)
                continue

            # Target directory already copy files into it.. and then remove
            # the old tree.
            if os.path.isdir(src):

                # After we worked so hard to not stomp the __init__.py up above,
                # We stomp everything already in the subtree... *sigh*.  We should
                # probably write our own copy_tree() at some point
                copy_tree(src, dst, dry_run=self.dry_run)
                remove_tree(src, dry_run=self.dry_run)
                continue

            # Target dir or file doesn't exist yet.  Just move it
            self.move_file(src, dst, dry_run=self.dry_run)

        execute(os.rmdir, (gen_path, ),
                "cleaning up %s" % gen_path,
                dry_run=self.dry_run)
Example #20
0
 def build_configuration(self, arch_list):
     from distutils.util import split_quoted, execute
     #
     template, variables = self.get_config_data(arch_list)
     config_data = template % variables
     #
     build_lib   = self.build_lib
     dist_name   = self.distribution.get_name()
     config_file = os.path.join(build_lib, dist_name,'petsc.cfg')#cek hack
     #
     def write_file(filename, data):
         fh = open(filename, 'w')
         try: fh.write(config_data)
         finally: fh.close()
     execute(write_file, (config_file, config_data),
             msg='writing %s' % config_file, 
             verbose=self.verbose, dry_run=self.dry_run)
Example #21
0
 def make_distribution(self):
     """Update versioning data and build distribution"""
     news_format = "%s - " % __pkg_data__.MODULE.__version__
     news_matches = [line for line in open("NEWS.rst")
                     if line.startswith(news_format)]
     if not any(news_matches):
         print("NEWS.rst entry for %r missing"
               % (__pkg_data__.MODULE.__version__, ))
         sys.exit(1)
     news_time = time.mktime(time.strptime(news_matches[0].split()[-1],
                             "%Y-%m-%d"))
     if time.time() - news_time > 86400 and not self.force_build:
         print("NEWS.rst entry is older than a day, version may not have "
               "been updated")
         sys.exit(1)
     execute(self.write_version, ())
     sdist.make_distribution(self)
Example #22
0
  def run(self):
    #self.omniidl_params.append("-Wbpackage=OpenRTM_aist.RTM_IDL")
    self.omniidl_params.append("-COpenRTM_aist/RTM_IDL")
    self.omniidl_params.append("-IOpenRTM_aist/RTM_IDL")
    modules = ["BasicDataType", "DataPort", "ExtendedDataTypes",
               "InterfaceDataTypes", "Manager", "OpenRTM", "RTC",
               "SDOPackage"]
    util.execute(compile_idl,
                 (self.omniidl, self.omniidl_params,
                  [ gen_idl_name(self.idldir, module) for module in modules ]),
                 "Generating python stubs from IDL files")

    # for SimpleService
    self.idldir = os.path.join(os.getcwd(),"OpenRTM_aist","examples","SimpleService")
    self.omniidl_params[-2]=("-COpenRTM_aist/examples/SimpleService")
    self.omniidl_params[-1]=("-IOpenRTM_aist/examples/SimpleService")
    modules = ["MyService"]
    util.execute(compile_idl,
                 (self.omniidl, self.omniidl_params,
                  [ gen_idl_name(self.idldir, module) for module in modules ]),
                 "Generating python sample stubs from IDL files")

    # for AutoTest
    self.idldir = os.path.join(os.getcwd(),"OpenRTM_aist","examples","AutoTest")
    self.omniidl_params[-2]=("-COpenRTM_aist/examples/AutoTest")
    self.omniidl_params[-1]=("-IOpenRTM_aist/examples/AutoTest")
    modules = ["AutoTestService"]
    util.execute(compile_idl,
                 (self.omniidl, self.omniidl_params,
                  [ gen_idl_name(self.idldir, module) for module in modules ]),
                 "Generating python sample stubs from IDL files")
Example #23
0
    def build_idl(self, path):
        path = self.get_idl_path(path)
        if not os.path.isfile(path):
            raise DistutilsFileError('Unable to find idl file, "%s"' % (path,))

        # XXX "find" thrift instead of hardcoding the path here
        command = ["/usr/local/bin/thrift", "--gen", "py", "-r", "-o", self.build_lib, path]

        spawn(command, dry_run=self.dry_run)

        # thrift puts everything in a gen-py folder... That's lame; let's
        # dump it into the buildroot instead.
        gen_path = os.path.join(self.build_lib, "gen-py")
        for item in os.listdir(gen_path):
            src = os.path.join(gen_path, item)
            dst = os.path.join(self.build_lib, item)

            # Skip move of __init__.py files if there are already ones in the
            # build dir.  In that case, just delete them.
            if item == "__init__.py" and os.path.isfile(dst):
                execute(os.remove, (src,), "skipping copy of %s" % dst, dry_run=self.dry_run)
                continue

            # Target directory already copy files into it.. and then remove
            # the old tree.
            if os.path.isdir(src):

                # After we worked so hard to not stomp the __init__.py up above,
                # We stomp everything already in the subtree... *sigh*.  We should
                # probably write our own copy_tree() at some point
                copy_tree(src, dst, dry_run=self.dry_run)
                remove_tree(src, dry_run=self.dry_run)
                continue

            # Target dir or file doesn't exist yet.  Just move it
            self.move_file(src, dst, dry_run=self.dry_run)

        execute(os.rmdir, (gen_path,), "cleaning up %s" % gen_path, dry_run=self.dry_run)
Example #24
0
 def run(self):
     """Remove built and temporary files"""
     clean.run(self)
     if self.all:
         for filename in [".git_version", ".hg_version", "ChangeLog",
                          "MANIFEST"] \
             + glob("*.html") + glob("doc/*.html") \
             + glob("%s/*.pyc" % __pkg_data__.MODULE.__name__):
             if os.path.exists(filename):
                 os.unlink(filename)
         execute(shutil.rmtree, ("html", True))
         execute(shutil.rmtree, ("doc/html", True))
         execute(shutil.rmtree, ("doc/source/.doctrees", True))
     if hasattr(__pkg_data__, "MyClean_run"):
         __pkg_data__.MyClean_run(self.dry_run, self.force)
Example #25
0
"""distutils.cmd
Example #26
0
# -*- coding: utf-8 -*-

from distutils.core import setup, Extension
from distutils.util import execute, newer
from distutils.spawn import spawn

#
# hack to support linking when running
#  python setup.py sdist
#

import os
del os.link

if newer('getdate.y', 'getdate.c'):
    execute(spawn, (['bison', '-y', '-o', 'getdate.c', 'getdate.y'],))

setup(name='python-kadmin',
      version='0.1',
      description='Python module for kerberos admin (kadm5)',
      url='https://github.com/russjancewicz/python-kadmin',
      author='Russell Jancewicz',
      author_email='*****@*****.**',
      license='MIT',
      ext_modules=[
          Extension(
              "kadmin",
              libraries=["krb5", "kadm5clnt", "kdb5"],
              include_dirs=["/usr/include/", "/usr/include/et/"],
              sources=[
                  "./kadmin.c",
Example #27
0
"""distutils.cmd
Example #28
0
 def get_file_list(self):
     """Generate MANIFEST file contents from SCM"""
     manifest_files = scm_finder()
     execute(write_manifest, [manifest_files], "writing MANIFEST")
     sdist.get_file_list(self)
Example #29
0
 def execute(self, func, args, msg=None, level=1):
     execute(func, args, msg, self.dry_run)
Example #30
0
from distutils.core import setup, Extension
from distutils.util import execute, newer
from distutils.spawn import spawn

#
# hack to support linking when running
#  python setup.py sdist
#

import os

del os.link

if newer("getdate.y", "getdate.c"):
    execute(spawn, (["bison", "-y", "-o", "getdate.c", "getdate.y"],))

setup(
    name="python-kadmin",
    version="0.1",
    description="Python module for kerberos admin (kadm5)",
    url="https://github.com/russjancewicz/python-kadmin",
    download_url="https://github.com/russjancewicz/python-kadmin/tarball/0.0.1",
    author="Russell Jancewicz",
    author_email="*****@*****.**",
    license="MIT",
    ext_modules=[
        Extension(
            "kadmin",
            libraries=["krb5", "kadm5clnt", "kdb5"],
            include_dirs=["/usr/include/", "/usr/include/et/"],
Example #31
0
def byte_compile(py_files,
                 optimize=0,
                 force=0,
                 target_dir=None,
                 verbose=1,
                 dry_run=0,
                 direct=None):

    if direct is None:
        direct = (__debug__ and optimize == 0)

    # "Indirect" byte-compilation: write a temporary script and then
    # run it with the appropriate flags.
    if not direct:
        from tempfile import mktemp
        from distutils.util import execute, spawn
        script_name = mktemp(".py")
        if verbose:
            print("writing byte-compilation script '%s'" % script_name)
        if not dry_run:
            script = open(script_name, "w")
            script.write("""
from pluginbuilder.util import byte_compile
from modulegraph.modulegraph import *
files = [
""")

            for f in py_files:
                script.write(repr(f) + ",\n")
            script.write("]\n")
            script.write("""
byte_compile(files, optimize=%r, force=%r,
             target_dir=%r,
             verbose=%r, dry_run=0,
             direct=1)
""" % (optimize, force, target_dir, verbose))

            script.close()

        cmd = [sys.executable, script_name]
        if optimize == 1:
            cmd.insert(1, "-O")
        elif optimize == 2:
            cmd.insert(1, "-OO")
        spawn(cmd, verbose=verbose, dry_run=dry_run)
        execute(os.remove, (script_name, ),
                "removing %s" % script_name,
                verbose=verbose,
                dry_run=dry_run)

    else:
        from py_compile import compile
        from distutils.dir_util import mkpath

        for mod in py_files:
            # Terminology from the py_compile module:
            #   cfile - byte-compiled file
            #   dfile - purported source filename (same as 'file' by default)
            if mod.filename == mod.identifier:
                cfile = os.path.basename(mod.filename)
                dfile = cfile + (__debug__ and 'c' or 'o')
            else:
                cfile = mod.identifier.replace('.', os.sep)

                if mod.packagepath:
                    dfile = cfile + os.sep + '__init__.py' + (__debug__ and 'c'
                                                              or 'o')
                else:
                    dfile = cfile + '.py' + (__debug__ and 'c' or 'o')
            if target_dir:
                cfile = os.path.join(target_dir, dfile)

            if force or newer(mod.filename, cfile):
                if verbose:
                    print("byte-compiling %s to %s" % (mod.filename, dfile))
                if not dry_run:
                    mkpath(os.path.dirname(cfile))
                    suffix = os.path.splitext(mod.filename)[1]

                    if suffix in ('.py', '.pyw'):
                        zfile, pth = path_to_zip(mod.filename)
                        if zfile is None:
                            compile(mod.filename, cfile, dfile)
                        else:
                            fn = dfile + '.py'
                            open(fn, 'wb').write(get_zip_data(zfile, pth))
                            compile(mod.filename, cfile, dfile)
                            os.unlink(fn)

                    elif suffix in PY_SUFFIXES:
                        # Minor problem: This will happily copy a file
                        # <mod>.pyo to <mod>.pyc or <mod>.pyc to
                        # <mod>.pyo, but it does seem to work.
                        copy_file_data(mod.filename, cfile)
                    else:
                        raise RuntimeError \
                              ("Don't know how to handle %r" % mod.filename)
            else:
                if verbose:
                    print("skipping byte-compilation of %s to %s" % \
                          (mod.filename, dfile))
Example #32
0
# -*- coding: utf-8 -*-

from distutils.core import setup, Extension
from distutils.util import execute, newer
from distutils.spawn import spawn

#
# hack to support linking when running
#  python setup.py sdist
#

import os
del os.link

if newer('./src/getdate.y', './src/getdate.c'):
    execute(spawn,
            (['bison', '-y', '-o', './src/getdate.c', './src/getdate.y'], ))

setup(
    name='python-kadmin',
    version='0.1.1',
    description='Python module for kerberos admin (kadm5)',
    url='https://github.com/russjancewicz/python-kadmin',
    download_url=
    'https://github.com/russjancewicz/python-kadmin/tarball/v0.1.1',
    author='Russell Jancewicz',
    author_email='*****@*****.**',
    license='MIT',
    ext_modules=[
        Extension("kadmin",
                  libraries=["krb5", "kadm5clnt", "kdb5"],
                  include_dirs=["/usr/include/", "/usr/include/et/"],
Example #33
0
 def execute (self, func, args, msg=None, level=1):
     util.execute(func, args, msg, self.verbose >= level, self.dry_run)
Example #34
0
def byte_compile(py_files, optimize=0, force=0, target_dir=None, verbose=1, dry_run=0, direct=None):

    if direct is None:
        direct = __debug__ and optimize == 0

    # "Indirect" byte-compilation: write a temporary script and then
    # run it with the appropriate flags.
    if not direct:
        from tempfile import mktemp
        from distutils.util import execute, spawn

        script_name = mktemp(".py")
        if verbose:
            print "writing byte-compilation script '%s'" % script_name
        if not dry_run:
            script = open(script_name, "w")
            script.write(
                """
from py2app.util import byte_compile
from modulegraph.modulegraph import *
files = [
"""
            )

            for f in py_files:
                script.write(repr(f) + ",\n")
            script.write("]\n")
            script.write(
                """
byte_compile(files, optimize=%r, force=%r,
             target_dir=%r,
             verbose=%r, dry_run=0,
             direct=1)
"""
                % (optimize, force, target_dir, verbose)
            )

            script.close()

        cmd = [sys.executable, script_name]
        if optimize == 1:
            cmd.insert(1, "-O")
        elif optimize == 2:
            cmd.insert(1, "-OO")
        spawn(cmd, verbose=verbose, dry_run=dry_run)
        execute(os.remove, (script_name,), "removing %s" % script_name, verbose=verbose, dry_run=dry_run)

    else:
        from py_compile import compile
        from distutils.dir_util import mkpath

        for mod in py_files:
            # Terminology from the py_compile module:
            #   cfile - byte-compiled file
            #   dfile - purported source filename (same as 'file' by default)
            if mod.filename == mod.identifier:
                cfile = os.path.basename(mod.filename)
                dfile = cfile + (__debug__ and "c" or "o")
            else:
                cfile = mod.identifier.replace(".", os.sep)

                if mod.packagepath:
                    dfile = cfile + os.sep + "__init__.py" + (__debug__ and "c" or "o")
                else:
                    dfile = cfile + ".py" + (__debug__ and "c" or "o")
            if target_dir:
                cfile = os.path.join(target_dir, dfile)

            if force or newer(mod.filename, cfile):
                if verbose:
                    print "byte-compiling %s to %s" % (mod.filename, dfile)
                if not dry_run:
                    mkpath(os.path.dirname(cfile))
                    suffix = os.path.splitext(mod.filename)[1]

                    if suffix in (".py", ".pyw"):
                        zfile, pth = path_to_zip(mod.filename)
                        if zfile is None:
                            compile(mod.filename, cfile, dfile)
                        else:
                            fn = dfile + ".py"
                            open(fn, "wb").write(get_zip_data(zfile, pth))
                            compile(mod.filename, cfile, dfile)
                            os.unlink(fn)

                    elif suffix in PY_SUFFIXES:
                        # Minor problem: This will happily copy a file
                        # <mod>.pyo to <mod>.pyc or <mod>.pyc to
                        # <mod>.pyo, but it does seem to work.
                        copy_file(mod.filename, cfile)
                    else:
                        raise RuntimeError("Don't know how to handle %r" % mod.filename)
            else:
                if verbose:
                    print "skipping byte-compilation of %s to %s" % (mod.filename, dfile)
Example #35
0
    def run(self):
        """Build the required documentation"""
        if not DOCUTILS:
            raise DistutilsModuleError("docutils import failed, "
                                       "can't generate documentation")
        if not PYGMENTS:
            # This could be a warning with conditional support for users, but
            # how would coloured output be guaranteed in releases?
            raise DistutilsModuleError("pygments import failed, "
                                       "can't generate documentation")

        def pygments_directive(name, arguments, options, content, lineno,
                               content_offset, block_text, state,
                               state_machine):
            """Code colourising directive for :mod:`docutils`"""
            # Previously we tested to see if the lexer existed and set a
            # default of text if it didn't, but this hides bugs such as a typo
            # in the directive
            lexer = get_lexer_by_name(arguments[0])
            if sys.version_info[:2] >= (3, 0):
                parsed = highlight('\n'.join(content), lexer,
                                   pygments_formatter)
            else:
                parsed = highlight(unicode('\n'.join(content)), lexer,
                                   HtmlFormatter())
            return [nodes.raw('', parsed, format='html')]
        pygments_directive.arguments = (1, 0, 1)
        pygments_directive.content = 1
        directives.register_directive('code-block', pygments_directive)

        for source in sorted(["NEWS.rst", "README.rst"] + glob('doc/*.rst')):
            dest = os.path.splitext(source)[0] + '.html'
            if self.force or newer(source, dest):
                print('Building file %s' % dest)
                if self.dry_run:
                    continue
                publish_cmdline(writer_name='html',
                                argv=['--source-link', '--strict',
                                      '--generator',
                                      '--stylesheet-path=doc/docutils.css',
                                      '--link-stylesheet', source, dest])
        print("Building sphinx tree")
        if not os.path.isdir("doc/html"):
            os.mkdir("doc/html")
        check_call(["sphinx-build", "-b", "html", "-d", "doc/source/.doctrees",
                    "doc/source", "doc/html"])

        files = glob("%s/*.py" % __pkg_data__.MODULE.__name__)
        files.extend(["%s.py" % i.__name__ for i in __pkg_data__.SCRIPTS])
        if self.force or not os.path.isfile("ChangeLog"):
            execute(write_changelog, ("ChangeLog", ))
        else:
            cl_time = os.stat("ChangeLog").st_mtime
            if __pkg_data__.SCM == "hg" and os.path.isdir(".hg"):
                output = call_scm("tip --template '{date}'")
                tip_time = float(output[1:output.find("-")])
            elif __pkg_data__.SCM == "git" and os.path.isdir(".git"):
                output = call_scm("log -n 1 --pretty=format:%at HEAD")
                tip_time = int(output)
            else:
                print("Unable to build ChangeLog, dir is not a %s clone"
                      % __pkg_data__.SCM)
                return False
            if tip_time > cl_time:
                execute(write_changelog, ("ChangeLog", ))

        if hasattr(__pkg_data__, "BuildDoc_run"):
            __pkg_data__.BuildDoc_run(self.dry_run, self.force)
Example #36
0
 def run(self):
     util.execute(self.compile_idl,
                  (self.omniidl, self.omniidl_params,
                      [gen_idl_name(self.idl_dir, idl_file) \
                              for idl_file in self.idl_files]),
                  msg='Generating python stubs from IDL files')
Example #37
0
    def run(self):
        install.run(self)

        execute(udev_reload_rules, [], "Reloading udev rules")
        execute(udev_trigger, [], "Triggering udev rules")
Example #38
0
"""distutils.ccompiler
 def run(self):
     util.execute(self.compile_idl,
                  (self.omniidl, self.omniidl_params,
                      [gen_idl_name(self.idl_dir, idl_file) \
                              for idl_file in self.idl_files]),
                  msg='Generating python stubs from IDL files')
Example #40
0
def byte_compile(py_files, optimize=0, force=0,
                 target_dir=None, verbose=1, dry_run=0,
                 direct=None):

    if direct is None:
        direct = (__debug__ and optimize == 0)

    # "Indirect" byte-compilation: write a temporary script and then
    # run it with the appropriate flags.
    if not direct:
        from tempfile import mktemp
        from distutils.util import execute, spawn
        script_name = mktemp(".py")
        if verbose:
            print("writing byte-compilation script '%s'" % script_name)
        if not dry_run:
            with open(script_name, "w") as script:
                script.write("""
from py2app.util import byte_compile
from modulegraph.modulegraph import *
files = [
""")

                for f in py_files:
                    script.write(repr(f) + ",\n")
                script.write("]\n")
                script.write("""
byte_compile(files, optimize=%r, force=%r,
             target_dir=%r,
             verbose=%r, dry_run=0,
             direct=1)
""" % (optimize, force, target_dir, verbose))

        # Ensure that py2app is on PYTHONPATH, this ensures that
        # py2app.util can be found even when we're running from
        # an .egg that was downloaded by setuptools
        import py2app
        pp = os.path.dirname(os.path.dirname(py2app.__file__))
        if 'PYTHONPATH' in os.environ:
            pp = '%s:%s'%(pp, os.environ['PYTHONPATH'])

        cmd = ['/usr/bin/env', 'PYTHONPATH=%s'%(pp,), sys.executable, script_name]
        if optimize == 1:
            cmd.insert(3, "-O")
        elif optimize == 2:
            cmd.insert(3, "-OO")
        spawn(cmd, verbose=verbose, dry_run=dry_run)
        execute(os.remove, (script_name,), "removing %s" % script_name,
                verbose=verbose, dry_run=dry_run)


    else:
        from py_compile import compile
        from distutils.dir_util import mkpath

        for mod in py_files:
            # Terminology from the py_compile module:
            #   cfile - byte-compiled file
            #   dfile - purported source filename (same as 'file' by default)
            if mod.filename == mod.identifier:
                cfile = os.path.basename(mod.filename)
                dfile = cfile + (__debug__ and 'c' or 'o')
            else:
                cfile = mod.identifier.replace('.', os.sep)

                if mod.packagepath:
                    dfile = cfile + os.sep + '__init__.py' + (__debug__ and 'c' or 'o')
                else:
                    dfile = cfile + '.py' + (__debug__ and 'c' or 'o')
            if target_dir:
                cfile = os.path.join(target_dir, dfile)

            if force or newer(mod.filename, cfile):
                if verbose:
                    print("byte-compiling %s to %s" % (mod.filename, dfile))
                    
                if not dry_run:
                    mkpath(os.path.dirname(cfile))
                    suffix = os.path.splitext(mod.filename)[1]

                    if suffix in ('.py', '.pyw'):
                        fn = cfile + '.py'

                        with zipio.open(mod.filename, 'rb') as fp_in:
                            with open(fn, 'wb') as fp_out:
                                fp_out.write(fp_in.read())

                        compile(fn, cfile, dfile)
                        os.unlink(fn)

                    elif suffix in PY_SUFFIXES:
                        # Minor problem: This will happily copy a file
                        # <mod>.pyo to <mod>.pyc or <mod>.pyc to
                        # <mod>.pyo, but it does seem to work.
                        copy_file(mod.filename, cfile)

                    else:
                        raise RuntimeError \
                              ("Don't know how to handle %r" % mod.filename)
            else:
                if verbose:
                    print("skipping byte-compilation of %s to %s" % 
                          (mod.filename, dfile))
Example #41
0
 def execute(self, func, args, msg=None, level=1):
     util.execute(func, args, msg, dry_run=self.dry_run)
Example #42
0
"""distutils.ccompiler
Example #43
0
def byte_compile(py_files,
                 optimize=0,
                 force=0,
                 target_dir=None,
                 verbose=1,
                 dry_run=0,
                 direct=None):

    if direct is None:
        direct = (__debug__ and optimize == 0)

    # "Indirect" byte-compilation: write a temporary script and then
    # run it with the appropriate flags.
    if not direct:
        from tempfile import mktemp
        from distutils.util import execute, spawn
        script_name = mktemp(".py")
        if verbose:
            print("writing byte-compilation script '%s'" % script_name)
        if not dry_run:
            with open(script_name, "w") as script:
                script.write("""
from py2app.util import byte_compile
from modulegraph.modulegraph import *
files = [
""")

                for f in py_files:
                    script.write(repr(f) + ",\n")
                script.write("]\n")
                script.write("""
byte_compile(files, optimize=%r, force=%r,
             target_dir=%r,
             verbose=%r, dry_run=0,
             direct=1)
""" % (optimize, force, target_dir, verbose))

        # Ensure that py2app is on PYTHONPATH, this ensures that
        # py2app.util can be found even when we're running from
        # an .egg that was downloaded by setuptools
        import py2app
        pp = os.path.dirname(os.path.dirname(py2app.__file__))
        if 'PYTHONPATH' in os.environ:
            pp = '%s:%s' % (pp, os.environ['PYTHONPATH'])

        cmd = [
            '/usr/bin/env',
            'PYTHONPATH=%s' % (pp, ), sys.executable, script_name
        ]
        if optimize == 1:
            cmd.insert(3, "-O")
        elif optimize == 2:
            cmd.insert(3, "-OO")
        spawn(cmd, verbose=verbose, dry_run=dry_run)
        execute(os.remove, (script_name, ),
                "removing %s" % script_name,
                verbose=verbose,
                dry_run=dry_run)

    else:
        from py_compile import compile
        from distutils.dir_util import mkpath

        for mod in py_files:
            # Terminology from the py_compile module:
            #   cfile - byte-compiled file
            #   dfile - purported source filename (same as 'file' by default)
            if mod.filename == mod.identifier:
                cfile = os.path.basename(mod.filename)
                dfile = cfile + (__debug__ and 'c' or 'o')
            else:
                cfile = mod.identifier.replace('.', os.sep)

                if mod.packagepath:
                    dfile = cfile + os.sep + '__init__.py' + (__debug__ and 'c'
                                                              or 'o')
                else:
                    dfile = cfile + '.py' + (__debug__ and 'c' or 'o')
            if target_dir:
                cfile = os.path.join(target_dir, dfile)

            if force or newer(mod.filename, cfile):
                if verbose:
                    print("byte-compiling %s to %s" % (mod.filename, dfile))

                if not dry_run:
                    mkpath(os.path.dirname(cfile))
                    suffix = os.path.splitext(mod.filename)[1]

                    if suffix in ('.py', '.pyw'):
                        fn = cfile + '.py'

                        with zipio.open(mod.filename, 'rb') as fp_in:
                            with open(fn, 'wb') as fp_out:
                                fp_out.write(fp_in.read())

                        compile(fn, cfile, dfile)
                        os.unlink(fn)

                    elif suffix in PY_SUFFIXES:
                        # Minor problem: This will happily copy a file
                        # <mod>.pyo to <mod>.pyc or <mod>.pyc to
                        # <mod>.pyo, but it does seem to work.
                        copy_file(mod.filename, cfile, preserve_times=True)

                    else:
                        raise RuntimeError \
                              ("Don't know how to handle %r" % mod.filename)
            else:
                if verbose:
                    print("skipping byte-compilation of %s to %s" %
                          (mod.filename, dfile))
Example #44
0
 def execute(self, func, args, msg=None, level=1):
     util.execute(func, args, msg, self.verbose >= level, self.dry_run)
Example #45
0
 def execute(self, func, args, msg=None, level=1):
     util.execute(func, args, msg, dry_run=self.dry_run)
Example #46
0
def execute(command):
    sizeToRun=100;
    while(sizeToRun<101):
        listCommand=[]
        elapsedTimes = []
        listCommand.append(command)
        for i in range(NO_OF_SAMPLES):
            listCommand.append(str(sizeToRun))
            time = subprocess.Popen(listCommand,stdout=subprocess.PIPE).communicate()[0]
            listCommand.remove(str(sizeToRun))
            elapsedTimes.append(float(time))

        average = statistics.mean(elapsedTimes)
        standardDeviation = statistics.stdev(elapsedTimes)
        samples = math.ceil(math.pow(((100 * 1.96 * standardDeviation) / (5 * average)), 2))
        print('matrix size n: '+str(sizeToRun))
        print('Average: ' + str(average))
        print('Std.Dev: ' + str(standardDeviation))
        print('Samples: ' + str(samples))
        sizeToRun=sizeToRun+100


# Compile all the files
compileAll()
#print("Sequential")
execute('./MatrixMultiplicationSequential')
print("\nParallel")
execute('./MatrixMultiplicationParallel')
print("\nParallel Optimized")
execute('./MatrixMultiplicationParallelOptimized')
Example #47
0
 def execute(self, func, args, msg=None, level=1):
     execute(func, args, msg, self.dry_run)
Example #48
0
import setuptools

from setuptools.extension import Extension
from distutils.util import execute, newer
from distutils.spawn import spawn

#
# hack to support linking when running
#  python setup.py sdist
#

import os
del os.link

if newer('./src/getdate.y', './src/getdate.c'):
    execute(spawn, (['bison', '-y', '-o', './src/getdate.c', './src/getdate.y'],))

execute(spawn, (['mkdir', '-p', './build/bdist.linux-x86_64/wheel'],))

setuptools.setup(
    name='kadmin',
    version='0.0.3',
    description='Python module for kerberos admin (kadm5)',
    url='https://github.com/nightfly19/python-kadmin',
    download_url='https://github.com/nightfly19/python-kadmin/tarball/v0.0.2',
    author='Russell Jancewicz, Sage Imel',
    author_email='*****@*****.**',
    python_requires='>=3.8.5',
    license='MIT',
    ext_modules=[
        Extension(