Python distutils.core.setup() Examples

The following are 30 code examples of distutils.core.setup(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module distutils.core , or try the search function .
Example #1
Source File: setup.py    From cgpm with Apache License 2.0 6 votes vote down vote up
def make_release_tree(self, base_dir, files):
        import os
        sdist.make_release_tree(self, base_dir, files)
        version_file = os.path.join(base_dir, 'VERSION')
        print('updating %s' % (version_file,))
        # Write to temporary file first and rename over permanent not
        # just to avoid atomicity issues (not likely an issue since if
        # interrupted the whole sdist directory is only partially
        # written) but because the upstream sdist may have made a hard
        # link, so overwriting in place will edit the source tree.
        with open(version_file + '.tmp', 'wb') as f:
            f.write('%s\n' % (pkg_version,))
        os.rename(version_file + '.tmp', version_file)

# XXX These should be attributes of `setup', but helpful distutils
# doesn't pass them through when it doesn't know about them a priori. 
Example #2
Source File: setup.py    From KiCost with MIT License 6 votes vote down vote up
def post_install_setup():
    # Run the KiCost integration script.
    try:
        import sys
        if sys.platform.startswith("win32"):
            # For Windows it is necessary one additional library (used to create the shortcut).
            print('Installing additional library need for Windows setup...')
            try:
                if sys.version_info < (3,0):
                    from pip._internal import main as pipmain
                else:
                    from pip import main as pipmain
                pipmain(['install', 'pywin32'])
            except:
                print('Error to install Windows additional Python library. KiCost configuration related to Windows registry may not work.')
        # Run setup: shortcut, BOM module to Eeschema and OS context menu.
        try:
            from .kicost.kicost_config import kicost_setup
            kicost_setup()
        except:
            print('Running the external configuration command...')
            from subprocess import call
            call(['kicost', '--setup'])
    except:
        print('Error to run KiCost integration script.') 
Example #3
Source File: setup.py    From miasm with GNU General Public License v2.0 6 votes vote down vote up
def win_use_clang():
    # Recent (>= 8 ?) LLVM versions does not ship anymore a cl.exe binary in
    # the msbuild-bin directory. Thus, we need to
    # * copy-paste bin/clang-cl.exe into a temporary directory
    # * rename it to cl.exe
    # * add that path first in %Path%
    # * clean this mess on exit
    # We could use the build directory created by distutils for this, but it
    # seems non trivial to gather
    # (https://stackoverflow.com/questions/12896367/reliable-way-to-get-the-build-directory-from-within-setup-py).
    clang_path = win_find_clang_path()
    if clang_path is None:
        return False
    tmpdir = tempfile.mkdtemp(prefix="llvm")
    copyfile(os.path.join(clang_path, "bin", "clang-cl.exe"), os.path.join(tmpdir, "cl.exe"))
    os.environ['Path'] = "%s;%s" % (tmpdir, os.environ["Path"])
    atexit.register(lambda dir_: rmtree(dir_), tmpdir)

    return True 
Example #4
Source File: BuildLibrary.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def InstallPy2exePatch():
    """
    Tricks py2exe to include the win32com module.

    ModuleFinder can't handle runtime changes to __path__, but win32com
    uses them, particularly for people who build from sources.
    """
    try:
        import modulefinder
        import win32com
        for path in win32com.__path__[1:]:
            modulefinder.AddPackagePath("win32com", path)
        for extra in ["win32com.shell"]:
            __import__(extra)
            module = sys.modules[extra]
            for path in module.__path__[1:]:
                modulefinder.AddPackagePath(extra, path)
    except ImportError:  # IGNORE:W0704
        # no build path setup, no worries.
        pass 
Example #5
Source File: setup.py    From pscript with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def copy_for_legacy_python(src_dir, dest_dir):
    from translate_to_legacy import LegacyPythonTranslator
    # Dirs and files to explicitly not translate
    skip = ['tests/python_sample.py',
            'tests/python_sample2.py',
            'tests/python_sample3.py']
    # Make a fresh copy of the package
    if os.path.isdir(dest_dir):
        shutil.rmtree(dest_dir)
    ignore = lambda src, names: [n for n in names if n == '__pycache__']
    shutil.copytree(src_dir, dest_dir, ignore=ignore)
    # Translate in-place
    LegacyPythonTranslator.translate_dir(dest_dir, skip=skip)


## Collect info for setup() 
Example #6
Source File: setup.py    From artview with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def setup_package():

    # rewrite version file
    write_version_py()

    try:
        from numpy.distutils.core import setup
    except:
        from distutils.core import setup

    setup(
        name=NAME,
        maintainer=MAINTAINER,
        maintainer_email=MAINTAINER_EMAIL,
        description=DESCRIPTION,
        long_description=LONG_DESCRIPTION,
        url=URL,
        version=VERSION,
        download_url=DOWNLOAD_URL,
        license=LICENSE,
        classifiers=CLASSIFIERS,
        platforms=PLATFORMS,
        configuration=configuration,
        scripts=SCRIPTS,
    ) 
Example #7
Source File: setup.py    From gemBS with GNU General Public License v3.0 6 votes vote down vote up
def run(self):
        options=['setup', '_bcftools', '_utils']
        if not self.minimal:
            if not self.no_samtools:
                options.append('_samtools')
            if not self.no_gem3:
                options.append('gem3')
            if not self.no_bscall:
                options.append('_bs_call')

        if not self.enable_cuda:
            self.diable_cuda = True
            
        compile_gemBS_tools(options, self.enable_cuda, self.disable_cuda)
        _install.run(self)

        # find target folder
        install_dir = os.path.join(gemBS_install_dir, "gemBS")
        _install_bundle(install_dir, self) 
Example #8
Source File: setuppy.py    From dephell with MIT License 5 votes vote down vote up
def can_parse(self, path: Path, content: Optional[str] = None) -> bool:
        if isinstance(path, str):
            path = Path(path)
        if path.name == 'setup.py':
            return True
        if not content:
            return False
        if 'setuptools' not in content and 'distutils' not in content:
            return False
        return ('setup(' in content) 
Example #9
Source File: setup.py    From jenks with MIT License 5 votes vote down vote up
def run(self):
        # Import numpy here, only when headers are needed
        try:
            import numpy
        except ImportError:
            log.critical("Numpy is required to run setup(). Exiting.")
            sys.exit(1)
        # Add numpy headers to include_dirs
        self.include_dirs.append(numpy.get_include())
        # Call original build_ext command
        build_ext.run(self) 
Example #10
Source File: BuildLibrary.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def RemoveAllManifests(scanDir):
    """
    Remove embedded manifest resource for all DLLs and PYDs in the supplied
    directory.

    This seems to be the only way how the setup can run with Python 2.6
    on Vista and above.
    """
    import ctypes
    BeginUpdateResource = ctypes.windll.kernel32.BeginUpdateResourceW
    UpdateResource = ctypes.windll.kernel32.UpdateResourceW
    EndUpdateResource = ctypes.windll.kernel32.EndUpdateResourceW

    for name in os.listdir(scanDir):
        path = os.path.join(scanDir, name)
        if not os.path.isfile(path):
            continue
        ext = os.path.splitext(name)[1].lower()
        if ext not in (".pyd", ".dll"):
            continue
        handle = BeginUpdateResource(path, 0)
        if not handle:
            raise ctypes.WinError()
        res = UpdateResource(handle, RT_MANIFEST, 2, 1033, None, 0)
        if not res:
            continue
        if not EndUpdateResource(handle, 0):
            raise ctypes.WinError() 
Example #11
Source File: dist.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def setup(**kw):
    """
    An alternative to distutils' setup() which is specially designed
    for Twisted subprojects.

    Pass twisted_subproject=projname if you want package and data
    files to automatically be found for you.

    @param conditionalExtensions: Extensions to optionally build.
    @type conditionalExtensions: C{list} of L{ConditionalExtension}
    """
    return core.setup(**get_setup_args(**kw)) 
Example #12
Source File: setup.py    From flask-raml with MIT License 5 votes vote down vote up
def main(properties=properties, options=options, **custom_options):
    """Imports and runs setup function with given properties."""
    return init(**dict(options, **custom_options))(**properties) 
Example #13
Source File: setup.py    From gemBS with GNU General Public License v3.0 5 votes vote down vote up
def write_script(self, script_name, contents, mode="t", *ignored):
        i = contents.find('__requires__')
        if i >= 0:
            j = contents.rfind('\n', 0, i)
            if j >= 0:
                contents = contents[:j+1] + "import sys\nsys.path.insert(0,'{}')\n".format(gemBS_install_dir) + contents[j+1:]
        _install_scripts.write_script(self, script_name, contents, mode, *ignored)
            
# hack the setup tools cleaning 
Example #14
Source File: setup.py    From scikit-umfpack with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def write_version_py(filename='scikits/umfpack/version.py'):
    cnt = """# THIS FILE IS GENERATED FROM scikit-umfpack SETUP.PY
short_version = '%(version)s'
version = '%(version)s'
full_version = '%(full_version)s'
git_revision = '%(git_revision)s'
release = %(isrelease)s

if not release:
    version = full_version
"""
    FULLVERSION, GIT_REVISION = get_version_info()

    a = open(filename, 'w')
    try:
        a.write(cnt % {'version': VERSION,
                       'full_version': FULLVERSION,
                       'git_revision': GIT_REVISION,
                       'isrelease': str(ISRELEASED)})
    finally:
        a.close()

###############################################################################
# Optional setuptools features
# We need to import setuptools early, if we want setuptools features,
# as it monkey-patches the 'setup' function

# For some commands, use setuptools 
Example #15
Source File: setup.py    From bayeslite with Apache License 2.0 5 votes vote down vote up
def run_tests(self):
        import subprocess
        subprocess.check_call(["./check.sh"])
        print "Using ./check.sh directly gives you more options for testing."

# XXX These should be attributes of `setup', but helpful distutils
# doesn't pass them through when it doesn't know about them a priori. 
Example #16
Source File: twisted_distutils.py    From clonedigger with GNU General Public License v3.0 5 votes vote down vote up
def setup(**attrs):
    from distutils import core
    attrs['distclass'] = TwistedDistribution
    core.setup(**attrs) 
Example #17
Source File: disthelpers.py    From winpython with MIT License 5 votes vote down vote up
def build_cx_freeze(
        self, cleanup=True, create_archive=None
    ):
        """Build executable with cx_Freeze

        cleanup: remove 'build/dist' directories before building distribution

        create_archive (requires the executable `zip`):
            * None or False: do nothing
            * 'add': add target directory to a ZIP archive
            * 'move': move target directory to a ZIP archive
        """
        assert (
            not self._py2exe_is_loaded
        ), "cx_Freeze can't be executed after py2exe"
        from cx_Freeze import setup

        if cleanup:
            self.__cleanup()
        sys.argv += ["build"]
        build_exe = dict(
            include_files=to_include_files(self.data_files),
            includes=self.includes,
            excludes=self.excludes,
            bin_excludes=self.bin_excludes,
            bin_includes=self.bin_includes,
            bin_path_includes=self.bin_path_includes,
            bin_path_excludes=self.bin_path_excludes,
            build_exe=self.target_dir,
        )
        setup(
            name=self.name,
            version=self.version,
            description=self.description,
            executables=self.executables,
            options=dict(build_exe=build_exe),
        )
        if create_archive:
            self.__create_archive(create_archive) 
Example #18
Source File: setup.py    From flexx with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def get_all_resources():
    import logging  # noqa - prevent mixup with logging module inside flexx.util
    sys.path.insert(0, os.path.join(THIS_DIR, 'flexx', 'util'))
    from getresource import RESOURCES, get_resoure_path
    for name in RESOURCES.keys():
        get_resoure_path(name)
    sys.path.pop(0)


## Collect info for setup() 
Example #19
Source File: eduactiv82exe.py    From eduActiv8 with GNU General Public License v3.0 4 votes vote down vote up
def run(self):
        if os.path.isdir(self.dist_dir):  # Erase previous destination dir
            shutil.rmtree(self.dist_dir)

        # Use the default pygame icon, if none given
        if self.icon_file is None:
            path = os.path.split(pygame.__file__)[0]
            self.icon_file = os.path.join(path, 'pygame.ico')

        # List all data files to add
        extra_datas = ["__init__.py", "CHANGES.txt", "CREDITS.txt", "eduactiv8.py", "LICENSE", "README.txt"]

        for data in self.extra_datas:
            if os.path.isdir(data):
                extra_datas.extend(self.find_data_files(data, '*'))
            else:
                extra_datas.append(('.', [data]))

        setup(
            cmdclass={'py2exe': pygame2exe},
            version=self.project_version,
            description=self.project_description,
            name=self.project_name,
            url=self.project_url,
            author=self.author_name,
            author_email=self.author_email,
            license=self.license,

            # targets to build
            # console = [{
            windows=[{
                'script': self.script,
                'icon_resources': [(0, self.icon_file)],
                'copyright': self.copyright
            }],
            options={'py2exe': {'optimize': 2, 'bundle_files': 1, 'compressed': True,
                                'excludes': self.exclude_modules, 'packages': self.extra_modules,
                                'dll_excludes': self.exclude_dll,
                                'includes': self.extra_scripts}},
            zipfile=self.zipfile_name,
            data_files=extra_datas,
            dist_dir=self.dist_dir
        )

        if os.path.isdir('build'):  # Clean up build dir
            shutil.rmtree('build') 
Example #20
Source File: setup.py    From flask-raml with MIT License 4 votes vote down vote up
def init(
    dist='dist',
    minver=None,
    maxver=None,
    use_markdown_readme=True,
    use_stdeb=False,
    use_distribute=False,
    ):
    """Imports and returns a setup function.

    If use_markdown_readme is set,
    then README.md is added to setuptools READMES list.

    If use_stdeb is set on a Debian based system,
    then module stdeb is imported.
    Stdeb supports building deb packages on Debian based systems.
    The package should only be installed on the same system version
    it was built on, though. See http://github.com/astraw/stdeb.

    If use_distribute is set, then distribute_setup.py is imported.
    """
    if not minver == maxver == None:
        import sys
        if not minver <= sys.version < (maxver or 'Any'):
            sys.stderr.write(
                '%s: requires python version in <%s, %s), not %s\n' % (
                sys.argv[0], minver or 'any', maxver or 'any', sys.version.split()[0]))
            sys.exit(1)

    if use_distribute:
        from distribute_setup import use_setuptools
        use_setuptools(to_dir=dist)
        from setuptools import setup
    else:
        try:
            from setuptools import setup
        except ImportError:
            from distutils.core import setup

    if use_markdown_readme:
        try:
            import setuptools.command.sdist
            setuptools.command.sdist.READMES = tuple(list(getattr(setuptools.command.sdist, 'READMES', ()))
                + ['README.md'])
        except ImportError:
            pass

    if use_stdeb:
        import platform
        if 'debian' in platform.dist():
            try:
                import stdeb
            except ImportError:
                pass

    return setup 
Example #21
Source File: eduactiv82exe.py    From eduActiv8 with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self):
        # Name of starting .py
        self.script = "eduactiv8.py"

        # Name of program
        self.project_name = "eduActiv8"

        # Project url
        self.project_url = "https://www.eduactiv8.org"

        # Version of program
        self.project_version = "1.0"

        # License of the program
        self.license = "GPL3"

        # Auhor of program
        self.author_name = "Ireneusz Imiolek"
        self.author_email = "imiolek.i@gmail.com"
        self.copyright = "Copyright (c) 2012-2019 Ireneusz Imiolek"

        # Description
        self.project_description = "eduActiv8 - Educational Activities for Kids"

        # Icon file (None will use pygame default icon)
        self.icon_file = os.path.join("res", "icon", "eduactiv8.ico")

        # Extra files/dirs copied to game
        self.extra_datas = ["classes", "game_boards", "i18n", "locale", "res", "xml"]

        # Extra/excludes python modules
        self.extra_modules = []

        # showed missing in result compilation
        self.exclude_modules = []

        # DLL Excludes
        self.exclude_dll = ['']

        # python scripts (strings) to be included, seperated by a comma
        self.extra_scripts = []

        # Zip file name (None will bundle files in exe instead of zip file)
        self.zipfile_name = None

        # Dist directory
        self.dist_dir = 'dist'

    # Code from DistUtils tutorial at http://wiki.python.org/moin/Distutils/Tutorial
    # Originally borrowed from wxPython's setup and config files 
Example #22
Source File: dist.py    From python-for-android with Apache License 2.0 4 votes vote down vote up
def get_setup_args(**kw):
    if 'twisted_subproject' in kw:
        if 'twisted' not in os.listdir('.'):
            raise RuntimeError("Sorry, you need to run setup.py from the "
                               "toplevel source directory.")
        projname = kw['twisted_subproject']
        projdir = os.path.join('twisted', projname)

        kw['packages'] = getPackages(projdir, parent='twisted')
        kw['version'] = getVersion(projname)

        plugin = "twisted/plugins/twisted_" + projname + ".py"
        if os.path.exists(plugin):
            kw.setdefault('py_modules', []).append(
                plugin.replace("/", ".")[:-3])

        kw['data_files'] = getDataFiles(projdir, parent='twisted')

        del kw['twisted_subproject']
    else:
        if 'plugins' in kw:
            py_modules = []
            for plg in kw['plugins']:
                py_modules.append("twisted.plugins." + plg)
            kw.setdefault('py_modules', []).extend(py_modules)
            del kw['plugins']

    if 'cmdclass' not in kw:
        kw['cmdclass'] = {
            'install_data': install_data_twisted,
            'build_scripts': build_scripts_twisted}
        if sys.version_info[:3] < (2, 3, 0):
            kw['cmdclass']['build_py'] = build_py_twisted

    if "conditionalExtensions" in kw:
        extensions = kw["conditionalExtensions"]
        del kw["conditionalExtensions"]

        if 'ext_modules' not in kw:
            # This is a workaround for distutils behavior; ext_modules isn't
            # actually used by our custom builder.  distutils deep-down checks
            # to see if there are any ext_modules defined before invoking
            # the build_ext command.  We need to trigger build_ext regardless
            # because it is the thing that does the conditional checks to see
            # if it should build any extensions.  The reason we have to delay
            # the conditional checks until then is that the compiler objects
            # are not yet set up when this code is executed.
            kw["ext_modules"] = extensions

        class my_build_ext(build_ext_twisted):
            conditionalExtensions = extensions
        kw.setdefault('cmdclass', {})['build_ext'] = my_build_ext
    return kw 
Example #23
Source File: setup.py    From VUT-FIT-IFJ-2017-toolkit with GNU General Public License v3.0 4 votes vote down vote up
def setup():
    core.setup(
        name='IFJcode17-toolkit',
        version=ifj2017.__version__,
        license='GNU GENERAL PUBLIC LICENSE Version 3',
        description='Toolkit for IFJ17 language compiler (as project at FIT BUT in Brno) with '
                    'interactive debugger and automatic tests.',
        long_description=long_description,
        url='https://github.com/thejoeejoee/VUT-FIT-IFJ-2017-toolkit',
        classifiers=[
            'Development Status :: 5 - Production/Stable',
            'Environment :: X11 Applications :: Qt',

            'License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)',

            'Programming Language :: Python',
            'Programming Language :: Python :: 3.5',
            'Programming Language :: Python :: 3.6',
            'Programming Language :: Python :: 3 :: Only',

            'Topic :: Scientific/Engineering',
            'Topic :: Utilities'
        ],
        author='Josef Kolář, Son Hai Nguyen',
        author_email='xkolar71@stud.fit.vutbr.cz, xnguye16@stud.fit.vutbr.cz',
        keywords='ifj17 ifjcode17 language ide utils debugger editor',
        packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
        install_requires=[
            'PyOpenGL',
            'PyQt5==5.7.1',
        ],
        requires=[
            'termcolor',
            'PyOpenGL',
            'PyQt5',
        ],
        # package_dir={'': base_path},
        entry_points={
            'console_scripts': [
                'ifjcode17-ide=ifj2017.ide.main:main',
                'ifjcode17-tests=ifj2017.test.main:main',
                'ifjcode17-interpreter=ifj2017.interpreter.main:main',
            ]
        },
        data_files=[
            ('share/icons/hicolor/scalable/apps', ['data/ifjcode17-ide.svg']),
            ('share/applications', ['data/ifjcode17-ide.desktop'])
        ],
        include_package_data=True,
        zip_safe=False,
    ) 
Example #24
Source File: build.py    From games-in-pygame with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self):
        #Name of starting .py
        self.script = "../asteroides.py"

        #Name of program
        self.project_name = "Asteroides"

        #Project url
        self.project_url = "https://github.com/rodrigets/games-in-pygame"

        #Version of program
        self.project_version = "1.0"

        #License of the program
        self.license = "GPL-3.0"

        #Auhor of program
        self.author_name = ""
        self.author_email = ""
        self.copyright = ""

        #Description
        self.project_description = "Collection of games made with PyGame."

        #Icon file (None will use pygame default icon)
        self.icon_file = "../resources/ship.ico"

        #Extra files/dirs copied to game
        self.extra_datas = []

        #Extra/excludes python modules
        self.extra_modules = []
        self.exclude_modules = []
        
        #DLL Excludes
        self.exclude_dll = ['']
        #python scripts (strings) to be included, seperated by a comma
        self.extra_scripts = []

        #Zip file name (None will bundle files in exe instead of zip file)
        self.zipfile_name = None

        #Dist directory
        self.dist_dir ='dist'

    ## Code from DistUtils tutorial at http://wiki.python.org/moin/Distutils/Tutorial
    ## Originally borrowed from wxPython's setup and config files 
Example #25
Source File: build.py    From games-in-pygame with GNU General Public License v3.0 4 votes vote down vote up
def run(self):
        if os.path.isdir(self.dist_dir): #Erase previous destination dir
            shutil.rmtree(self.dist_dir)
        
        #Use the default pygame icon, if none given
        if self.icon_file == None:
            path = os.path.split(pygame.__file__)[0]
            self.icon_file = os.path.join(path, 'pygame.ico')

        #List all data files to add
        extra_datas = []
        for data in self.extra_datas:
            if os.path.isdir(data):
                extra_datas.extend(self.find_data_files(data, '*'))
            else:
                extra_datas.append(('.', [data]))
        
        setup(
            cmdclass = {'py2exe': pygame2exe},
            version = self.project_version,
            description = self.project_description,
            name = self.project_name,
            url = self.project_url,
            author = self.author_name,
            author_email = self.author_email,
            license = self.license,

            # targets to build
            windows = [{
                'script': self.script,
                'icon_resources': [(0, self.icon_file)],
                'copyright': self.copyright
            }],
            options = {'py2exe': {'optimize': 2, 'bundle_files': 1, 'compressed': True, \
                                  'excludes': self.exclude_modules, 'packages': self.extra_modules, \
                                  'dll_excludes': self.exclude_dll,
                                  'includes': self.extra_scripts} },
            zipfile = self.zipfile_name,
            data_files = extra_datas,
            dist_dir = self.dist_dir
            )
        
        if os.path.isdir('build'): #Clean up build dir
            shutil.rmtree('build') 
Example #26
Source File: dist.py    From BitTorrent with GNU General Public License v3.0 4 votes vote down vote up
def setup(**kw):
    """
    An alternative to distutils' setup() which is specially designed
    for Twisted subprojects.

    Pass twisted_subproject=projname if you want package and data
    files to automatically be found for you.

    Pass detectExtensions=detectorFunction if your project has
    extension modules. detectorFunction will be called with an
    instance of build_ext_twisted and should return a list of
    distutils Extensions.
    """
    if 'twisted_subproject' in kw:
        if 'twisted' not in os.listdir('.'):
            raise RuntimeError("Sorry, you need to run setup.py from the "
                               "toplevel source directory.")
        projname = kw['twisted_subproject']
        projdir = os.path.join('twisted', projname)

        kw['packages'] = getPackages(projdir, parent='twisted')
        kw['version'] = getVersion(projname)

        plugin = "twisted/plugins/twisted_" + projname + ".py"
        if os.path.exists(plugin):
            kw.setdefault('py_modules', []).append(plugin.replace("/", ".")[:-3])

        kw['data_files'] = getDataFiles(projdir, parent='twisted')

        del kw['twisted_subproject']
    else:
        if 'plugins' in kw:
            py_modules = []
            for plg in kw['plugins']:
                py_modules.append("twisted.plugins." + plg)
            kw.setdefault('py_modules', []).extend(py_modules)
            del kw['plugins']

    if 'cmdclass' not in kw:
        kw['cmdclass'] = {
            'install_data': install_data_twisted,
            'build_scripts': build_scripts_twisted}
        if sys.version_info[:3] < (2, 3, 0):
            kw['cmdclass']['build_py'] = build_py_twisted

    if 'detectExtensions' in kw:
        if 'ext_modules' not in kw:
            kw['ext_modules'] = [True] # distutils is so lame

        dE = kw['detectExtensions']
        del kw['detectExtensions']
        class my_build_ext(build_ext_twisted):
            detectExtensions = dE
        kw.setdefault('cmdclass', {})['build_ext'] = my_build_ext
    return core.setup(**kw) 
Example #27
Source File: setup.py    From smrt with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def do_setup():
    # setup the config
    metadata = dict(name=DISTNAME,
                    maintainer=MAINTAINER,
                    maintainer_email=MAINTAINER_EMAIL,
                    description=DESCRIPTION,
                    license=LICENSE,
                    version=VERSION,
                    classifiers=['Intended Audience :: Science/Research',
                                 'Intended Audience :: Developers',
                                 'Intended Audience :: Scikit-learn users',
                                 'Programming Language :: Python',
                                 'Topic :: Machine Learning',
                                 'Topic :: Software Development',
                                 'Topic :: Scientific/Engineering',
                                 'Operating System :: Microsoft :: Windows',
                                 'Operating System :: POSIX',
                                 'Operating System :: Unix',
                                 'Operating System :: MacOS',
                                 'Programming Language :: Python :: 2.7'
                                 ],
                    keywords='sklearn scikit-learn tensorflow auto-encoders neural-networks class-imbalance',
                    # packages=[DISTNAME],
                    # install_requires=REQUIREMENTS,
                    cmdclass=cmdclass)

    if len(sys.argv) == 1 or (
            len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or
                                    sys.argv[1] in ('--help-commands',
                                                    'egg-info',
                                                    '--version',
                                                    'clean'))):
        # For these actions, NumPy is not required
        try:
            from setuptools import setup
        except ImportError:
            from distutils.core import setup

    else:  # we DO need numpy
        try:
            from numpy.distutils.core import setup
        except ImportError:
            raise RuntimeError('Need numpy to build %s' % DISTNAME)

        # add the config to the metadata
        metadata['configuration'] = configuration

    # call setup on the dict
    setup(**metadata) 
Example #28
Source File: pygame2exe.py    From universalSmashSystem with GNU General Public License v3.0 4 votes vote down vote up
def run(self):
        if os.path.isdir(self.dist_dir): #Erase previous destination dir
            shutil.rmtree(self.dist_dir)
        
        #Use the default pygame icon, if none given
        if self.icon_file == None:
            path = os.path.split(pygame.__file__)[0]
            self.icon_file = os.path.join(path, 'pygame.ico')
 
        #List all data files to add
        extra_datas = []
        for data in self.extra_datas:
            if os.path.isdir(data):
                extra_datas.extend(self.find_data_files(data, '*'))
            else:
                extra_datas.append(('.', [data]))
        
        setup(
            cmdclass = {'py2exe': pygame2exe},
            version = self.project_version,
            description = self.project_description,
            name = self.project_name,
            url = self.project_url,
            author = self.author_name,
            author_email = self.author_email,
            license = self.license,
 
            # targets to build
            windows = [{
                'script': self.script,
                'icon_resources': [(0, self.icon_file)],
                'copyright': self.copyright
            }],
            options = {'py2exe': {'optimize': 2, 'bundle_files': 1, 'compressed': True, \
                                  'excludes': self.exclude_modules, 'packages': self.extra_modules, \
                                  'dll_excludes': self.exclude_dll,
                                  'includes': self.extra_scripts} },
            zipfile = self.zipfile_name,
            data_files = extra_datas,
            dist_dir = self.dist_dir
            )
        
        if os.path.isdir('build'): #Clean up build dir
            shutil.rmtree('build') 
Example #29
Source File: disthelpers.py    From winpython with MIT License 4 votes vote down vote up
def build_py2exe(
        self,
        cleanup=True,
        compressed=2,
        optimize=2,
        company_name=None,
        copyright=None,
        create_archive=None,
    ):
        """Build executable with py2exe

        cleanup: remove 'build/dist' directories before building distribution

        create_archive (requires the executable `zip`):
            * None or False: do nothing
            * 'add': add target directory to a ZIP archive
            * 'move': move target directory to a ZIP archive
        """
        from distutils.core import setup
        import py2exe  # Patching distutils -- analysis:ignore

        self._py2exe_is_loaded = True
        if cleanup:
            self.__cleanup()
        sys.argv += ["py2exe"]
        options = dict(
            compressed=compressed,
            optimize=optimize,
            includes=self.includes,
            excludes=self.excludes,
            dll_excludes=self.bin_excludes,
            dist_dir=self.target_dir,
        )
        windows = dict(
            name=self.name,
            description=self.description,
            script=self.script,
            icon_resources=[(0, self.icon)],
            bitmap_resources=[],
            other_resources=[],
            dest_base=osp.splitext(self.target_name)[0],
            version=self.version,
            company_name=company_name,
            copyright=copyright,
        )
        setup(
            data_files=self.data_files,
            windows=[windows],
            options=dict(py2exe=options),
        )
        if create_archive:
            self.__create_archive(create_archive) 
Example #30
Source File: pygame2exe.py    From universalSmashSystem with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self):
        #Name of starting .py
        self.script = "main.py"
 
        #Name of program
        self.project_name = "Project TUSSLE"
 
        #Project url
        self.project_url = "http://reddit.com/r/projecttussle"
 
        #Version of program
        self.project_version = "0.1"
 
        #License of the program
        self.license = "Creative Commons"
 
        #Auhor of program
        self.author_name = "digiholic"
        self.author_email = "digikun@gmail.com"
        self.copyright = ""
 
        #Description
        self.project_description = "Your game. Your fight. Your rules."
 
        #Icon file (None will use pygame default icon)
        self.icon_file = None
 
        #Extra files/dirs copied to game
        self.extra_datas = []
 
        #Extra/excludes python modules
        self.extra_modules = ['engine','fighters','menu','stages','builder']
        self.exclude_modules = []

        
        #DLL Excludes
        self.exclude_dll = ['Tkconstants', 'Tkinter']
        #python scripts (strings) to be included, seperated by a comma
        self.extra_scripts = []
 
        #Zip file name (None will bundle files in exe instead of zip file)
        self.zipfile_name = None
 
        #Dist directory
        self.dist_dir ='dist'
 
    ## Code from DistUtils tutorial at http://wiki.python.org/moin/Distutils/Tutorial
    ## Originally borrowed from wxPython's setup and config files