Ejemplo n.º 1
0
def make_import_tuples(module_path, exclude_modnames=[]):
    """ Infer the IMPORT_TUPLES from a module_path """
    from utool import util_path
    kwargs = dict(private=False, full=False)
    module_list = util_path.ls_modulefiles(module_path, noext=True, **kwargs)
    package_list = util_path.ls_moduledirs(module_path, **kwargs)
    exclude_set = set(exclude_modnames)
    module_import_tuples = [(modname, None) for modname in module_list
                            if modname not in exclude_set]
    package_import_tuples = [(modname, None, True) for modname in package_list
                             if modname not in exclude_set]
    IMPORT_TUPLES = (module_import_tuples + package_import_tuples)
    return IMPORT_TUPLES
Ejemplo n.º 2
0
def make_import_tuples(module_path, exclude_modnames=[]):
    """ Infer the import_tuples from a module_path """
    from utool import util_path
    kwargs = dict(private=False, full=False)
    module_list  = util_path.ls_modulefiles(module_path, noext=True, **kwargs)
    package_list = util_path.ls_moduledirs(module_path, **kwargs)
    exclude_set = set(exclude_modnames)
    module_import_tuples = [(modname, None) for modname in module_list
                            if modname not in exclude_set]
    package_import_tuples = [(modname, None, True)  for modname in package_list
                            if modname not in exclude_set]
    import_tuples = (module_import_tuples + package_import_tuples)
    return import_tuples
Ejemplo n.º 3
0
def presetup_commands(setup_fpath, kwargs):
    if VERBOSE:
        print('[setup] presetup_commands()')
    name = kwargs.get('name', '')
    # Parse args
    project_dirs = kwargs.pop('project_dirs', None)
    chmod_patterns = kwargs.pop('chmod_patterns', [])
    clutter_dirs = kwargs.pop('clutter_dirs', None)
    clutter_patterns = kwargs.pop('clutter_patterns', [])
    build_command = kwargs.pop('build_command', NOOP)
    # Augment patterns with builtin patterns
    chmod_patterns += SETUP_PATTERNS.chmod_test if kwargs.pop(
        'chmod_tests', True) else []
    clutter_patterns += SETUP_PATTERNS.clutter_pybuild if kwargs.pop(
        'clean_pybuild', True) else []
    clutter_patterns += SETUP_PATTERNS.clutter_cyth if kwargs.pop(
        'clean_pybuild', True) else []
    setup_fpath = util_path.truepath(setup_fpath)
    #
    setup_dir = dirname(setup_fpath)
    build_dir = join(setup_dir, 'build')
    os.chdir(setup_dir)  # change into setup directory
    assert_in_setup_repo(setup_fpath, name)

    # Augment clutter dirs
    if clutter_dirs is None:
        clutter_dirs = []
    clutter_dirs += ['build', 'dist', name + '.egg-info', '__pycache__']

    if project_dirs is None:
        project_dirs = util_path.ls_moduledirs(setup_dir)


# Execute pre-setup commands based on argv
#BEXT = 'bext' in sys.argv
#BUILD_EXT = 'build_ext' in sys.argv
#CYTH = 'cyth' in sys.argv

#if CYTH:
#    translate_cyth()

    for arg in iter(sys.argv[:]):
        #print(arg)
        # Clean clutter files
        if arg in ['clean']:
            clean(setup_dir, clutter_patterns, clutter_dirs)
            #sys.exit(0)
        if arg in ['build'] or (not exists(build_dir)
                                and 'clean' not in sys.argv):
            if VERBOSE:
                print('[setup] Executing build command')
            try:
                build_command()
            except Exception as ex:
                printex(
                    ex,
                    'Error calling buildcommand from cwd=%r\n' % os.getcwd())
                raise
        if arg in ['versions']:
            print('+ ---')
            print('Testing preqres package versions')
            install_requires = kwargs.get('install_requires', [])
            import pip
            print('Checking install_requires = [\n%s\n]' %
                  '\n'.join(install_requires))
            pip.main(['show'] +
                     [depline.split(' ')[0] for depline in install_requires])
            print('L ___ Done Version Testing')
        if arg in ['docs']:
            # FIXME
            autogen_sphinx_apidoc()
        # Build optimized files
        if arg in ['o', 'pyo']:
            build_pyo(project_dirs)
        # Cythonize files
        #if arg in ['cython']:
        #    build_cython(cython_files)
        # Chmod files
        if arg in ['chmod']:
            setup_chmod(setup_fpath, setup_dir, chmod_patterns)

    try:
        sys.argv.remove('docs')
        sys.argv.remove('cyth')
        #sys.argv.remove('--cyth-write')
    except ValueError:
        pass

    try:
        # SUPER HACK
        # aliases bext to build_ext --inplace
        sys.argv.remove('bext')
        sys.argv.append('build_ext')
        sys.argv.append('--inplace')
    except ValueError:
        pass
Ejemplo n.º 4
0
def presetup_commands(setup_fpath, kwargs):
    if VERBOSE:
        print('[setup] presetup_commands()')
    name = kwargs.get('name', '')
    # Parse args
    project_dirs     = kwargs.pop('project_dirs', None)
    chmod_patterns   = kwargs.pop('chmod_patterns', [])
    clutter_dirs     = kwargs.pop('clutter_dirs', None)
    clutter_patterns = kwargs.pop('clutter_patterns', [])
    build_command    = kwargs.pop('build_command', NOOP)
    # Augment patterns with builtin patterns
    chmod_patterns   += SETUP_PATTERNS.chmod_test if kwargs.pop('chmod_tests', True) else []
    clutter_patterns += SETUP_PATTERNS.clutter_pybuild if kwargs.pop('clean_pybuild', True) else []
    clutter_patterns += SETUP_PATTERNS.clutter_cyth if kwargs.pop('clean_pybuild', True) else []
    setup_fpath = util_path.truepath(setup_fpath)
    #
    setup_dir = dirname(setup_fpath)
    build_dir = join(setup_dir, 'build')
    os.chdir(setup_dir)  # change into setup directory
    assert_in_setup_repo(setup_fpath, name)

    # Augment clutter dirs
    if clutter_dirs is None:
        clutter_dirs = []
    clutter_dirs += [
        'build',
        'dist',
        name + '.egg-info',
        '__pycache__'
    ]

    if project_dirs is None:
        project_dirs = util_path.ls_moduledirs(setup_dir)
# Execute pre-setup commands based on argv
    #BEXT = 'bext' in sys.argv
    #BUILD_EXT = 'build_ext' in sys.argv
    #CYTH = 'cyth' in sys.argv

    #if CYTH:
    #    translate_cyth()

    for arg in iter(sys.argv[:]):
        #print(arg)
        # Clean clutter files
        if arg in ['clean']:
            clean(setup_dir, clutter_patterns, clutter_dirs)
            #sys.exit(0)
        if arg in ['build'] or (not exists(build_dir) and
                                'clean' not in sys.argv):
            if VERBOSE:
                print('[setup] Executing build command')
            try:
                build_command()
            except Exception as ex:
                printex(ex, 'Error calling buildcommand from cwd=%r\n' % os.getcwd())
                raise
        if arg in ['versions']:
            print('+ ---')
            print('Testing preqres package versions')
            install_requires = kwargs.get('install_requires', [])
            import pip
            print('Checking install_requires = [\n%s\n]' % '\n'.join(install_requires))
            pip.main(['show'] + [depline.split(' ')[0] for depline in install_requires])
            print('L ___ Done Version Testing')
        if arg in ['docs']:
            # FIXME
            autogen_sphinx_apidoc()
        # Build optimized files
        if arg in ['o', 'pyo']:
            build_pyo(project_dirs)
        # Cythonize files
        #if arg in ['cython']:
        #    build_cython(cython_files)
        # Chmod files
        if arg in ['chmod']:
            setup_chmod(setup_fpath, setup_dir, chmod_patterns)

    try:
        sys.argv.remove('docs')
        sys.argv.remove('cyth')
        #sys.argv.remove('--cyth-write')
    except ValueError:
        pass

    try:
        # SUPER HACK
        # aliases bext to build_ext --inplace
        sys.argv.remove('bext')
        sys.argv.append('build_ext')
        sys.argv.append('--inplace')
    except ValueError:
        pass