Python setuptools.command.install.install() Examples

The following are 30 code examples of setuptools.command.install.install(). 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 setuptools.command.install , or try the search function .
Example #1
Source File: setup.py    From pyspinel with Apache License 2.0 6 votes vote down vote up
def run(self):
        if self.extcap_path:
            _copy_script('extcap_ot.py', self.extcap_path)
            if sys.platform == 'win32':
                _copy_script('extcap_ot.bat', self.extcap_path)
        else:
            print('WARNING: Wireshark extcap is not installed. To install:',
                  file=sys.stderr)
            print(
                '1. Get Wireshark extcap path from Wireshark -> About -> Folders -> Extcap path',
                file=sys.stderr)
            print(
                '2. Run setup.py with --extcap-path=<extcap path> if you are installing by executing setup.py',
                file=sys.stderr)
            print('   or', file=sys.stderr)
            print(
                '   Provide --install-option="--extcap-path=<extcap path>" if you are installing by pip',
                file=sys.stderr)
        super(_InstallCommand, self).run() 
Example #2
Source File: setup.py    From Bashfuscator with MIT License 6 votes vote down vote up
def findArgcompletePath(command):
    proc = Popen("which " + command, stdout=PIPE, stderr=PIPE, shell=True, universal_newlines=True)
    command1Path, __ = proc.communicate()

    proc = Popen("which " + command + "3", stdout=PIPE, stderr=PIPE, shell=True, universal_newlines=True)
    command2Path, __ = proc.communicate()

    if command1Path:
        finalCommandPath = command1Path
    elif command2Path:
        finalCommandPath = command2Path
    else:
        print("ERROR: python3-argcomplete is not installed, install it with your package manager to activate autocompletion")
        exit(1)

    return finalCommandPath[:-1] 
Example #3
Source File: setup.py    From dm_control with Apache License 2.0 5 votes vote down vote up
def run(self):
    self.reinitialize_command('build_mjbindings',
                              inplace=self.inplace,
                              headers_dir=self.headers_dir)
    self.run_command('build_mjbindings')
    install.install.run(self) 
Example #4
Source File: setup.py    From deepdiy with MIT License 5 votes vote down vote up
def _post_install():
	os.system('pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew')
	os.system('pip install kivy')
	os.system('garden install --kivy matplotlib')
	print('FINISHED') 
Example #5
Source File: setup.py    From pomoxis with Mozilla Public License 2.0 5 votes vote down vote up
def get_setuptools_script_dir():
    # Run the above class just to get paths
    dist = Distribution({'cmdclass': {'install': GetPaths}})
    dist.dry_run = True
    dist.parse_config_files()
    command = dist.get_command_obj('install')
    command.ensure_finalized()
    command.run()

    src_dir = glob(os.path.join(dist.install_libbase, 'pomoxis-*', 'exes'))[0]
    for exe in (os.path.join(src_dir, x) for x in os.listdir(src_dir)):
        print("Copying", os.path.basename(exe), '->', dist.install_scripts)
        shutil.copy(exe, dist.install_scripts)
    return dist.install_libbase, dist.install_scripts 
Example #6
Source File: install.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def setuptools_run(self):
        """ The setuptools version of the .run() method.

        We must pull in the entire code so we can override the level used in the
        _getframe() call since we wrap this call by one more level.
        """
        from distutils.command.install import install as distutils_install

        # Explicit request for old-style install?  Just do it
        if self.old_and_unmanageable or self.single_version_externally_managed:
            return distutils_install.run(self)

        # Attempt to detect whether we were called from setup() or by another
        # command.  If we were called by setup(), our caller will be the
        # 'run_command' method in 'distutils.dist', and *its* caller will be
        # the 'run_commands' method.  If we were called any other way, our
        # immediate caller *might* be 'run_command', but it won't have been
        # called by 'run_commands'.  This is slightly kludgy, but seems to
        # work.
        #
        caller = sys._getframe(3)
        caller_module = caller.f_globals.get('__name__', '')
        caller_name = caller.f_code.co_name

        if caller_module != 'distutils.dist' or caller_name!='run_commands':
            # We weren't called from the command line or setup(), so we
            # should run in backward-compatibility mode to support bdist_*
            # commands.
            distutils_install.run(self)
        else:
            self.do_egg_install() 
Example #7
Source File: setup.py    From medaka with Mozilla Public License 2.0 5 votes vote down vote up
def get_setuptools_script_dir():
    # Run the above class just to get paths
    dist = Distribution({'cmdclass': {'install': GetPaths}})
    dist.dry_run = True
    dist.parse_config_files()
    command = dist.get_command_obj('install')
    command.ensure_finalized()
    command.run()

    print(dist.install_libbase)
    src_dir = glob(os.path.join(dist.install_libbase, 'medaka-*', 'exes'))[0]
    for exe in (os.path.join(src_dir, x) for x in os.listdir(src_dir)):
        print("Copying", os.path.basename(exe), '->', dist.install_scripts)
        shutil.copy(exe, dist.install_scripts)
    return dist.install_libbase, dist.install_scripts 
Example #8
Source File: install.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def setuptools_run(self):
        """ The setuptools version of the .run() method.

        We must pull in the entire code so we can override the level used in the
        _getframe() call since we wrap this call by one more level.
        """
        from distutils.command.install import install as distutils_install

        # Explicit request for old-style install?  Just do it
        if self.old_and_unmanageable or self.single_version_externally_managed:
            return distutils_install.run(self)

        # Attempt to detect whether we were called from setup() or by another
        # command.  If we were called by setup(), our caller will be the
        # 'run_command' method in 'distutils.dist', and *its* caller will be
        # the 'run_commands' method.  If we were called any other way, our
        # immediate caller *might* be 'run_command', but it won't have been
        # called by 'run_commands'.  This is slightly kludgy, but seems to
        # work.
        #
        caller = sys._getframe(3)
        caller_module = caller.f_globals.get('__name__', '')
        caller_name = caller.f_code.co_name

        if caller_module != 'distutils.dist' or caller_name!='run_commands':
            # We weren't called from the command line or setup(), so we
            # should run in backward-compatibility mode to support bdist_*
            # commands.
            distutils_install.run(self)
        else:
            self.do_egg_install() 
Example #9
Source File: setup.py    From kytos with MIT License 5 votes vote down vote up
def _install_deps_wheels():
        """Python wheels are much faster (no compiling)."""
        print('Installing dependencies...')
        check_call([sys.executable, '-m', 'pip', 'install', '-r',
                    'requirements/run.txt'])


# pylint: disable=attribute-defined-outside-init, abstract-method 
Example #10
Source File: setup.py    From kytos with MIT License 5 votes vote down vote up
def run(self):
        """Install the package in install mode.

        super().run() does not install dependencies when running
        ``python setup.py install`` (pypa/setuptools#456).
        """
        if 'bdist_wheel' in sys.argv:
            # do not use eggs, but wheels
            super().run()
        else:
            # force install of deps' eggs during setup.py install
            self.do_egg_install()


# class DevelopMode(develop):
#    """Recommended setup for developers.
#
#    The following feature are temporarily remove from code:
#    Instead of copying the files to the expected directories, a symlink is
#    created on the system aiming the current source code.
#    """
#
#    def run(self):
#        """Install the package in a developer mode."""
#        super().run()


# We are parsing the metadata file as if it was a text file because if we
# import it as a python module, necessarily the kytos.core module would be
# initialized, which means that kyots/core/__init__.py would be run and, then,
# kytos.core.controller.Controller would be called and it will try to import
# some modules that are dependencies from this project and that were not yet
# installed, since the requirements installation from this project hasn't yet
# happened. 
Example #11
Source File: install.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def setuptools_run(self):
        """ The setuptools version of the .run() method.

        We must pull in the entire code so we can override the level used in the
        _getframe() call since we wrap this call by one more level.
        """
        from distutils.command.install import install as distutils_install

        # Explicit request for old-style install?  Just do it
        if self.old_and_unmanageable or self.single_version_externally_managed:
            return distutils_install.run(self)

        # Attempt to detect whether we were called from setup() or by another
        # command.  If we were called by setup(), our caller will be the
        # 'run_command' method in 'distutils.dist', and *its* caller will be
        # the 'run_commands' method.  If we were called any other way, our
        # immediate caller *might* be 'run_command', but it won't have been
        # called by 'run_commands'.  This is slightly kludgy, but seems to
        # work.
        #
        caller = sys._getframe(3)
        caller_module = caller.f_globals.get('__name__', '')
        caller_name = caller.f_code.co_name

        if caller_module != 'distutils.dist' or caller_name!='run_commands':
            # We weren't called from the command line or setup(), so we
            # should run in backward-compatibility mode to support bdist_*
            # commands.
            distutils_install.run(self)
        else:
            self.do_egg_install() 
Example #12
Source File: setup.py    From dm_control with Apache License 2.0 5 votes vote down vote up
def initialize_options(self):
    install.install.initialize_options(self)
    _initialize_mjbindings_options(self) 
Example #13
Source File: setup.py    From dm_control with Apache License 2.0 5 votes vote down vote up
def finalize_options(self):
    install.install.finalize_options(self)
    _finalize_mjbindings_options(self) 
Example #14
Source File: install.py    From recruit with Apache License 2.0 5 votes vote down vote up
def setuptools_run(self):
        """ The setuptools version of the .run() method.

        We must pull in the entire code so we can override the level used in the
        _getframe() call since we wrap this call by one more level.
        """
        from distutils.command.install import install as distutils_install

        # Explicit request for old-style install?  Just do it
        if self.old_and_unmanageable or self.single_version_externally_managed:
            return distutils_install.run(self)

        # Attempt to detect whether we were called from setup() or by another
        # command.  If we were called by setup(), our caller will be the
        # 'run_command' method in 'distutils.dist', and *its* caller will be
        # the 'run_commands' method.  If we were called any other way, our
        # immediate caller *might* be 'run_command', but it won't have been
        # called by 'run_commands'.  This is slightly kludgy, but seems to
        # work.
        #
        caller = sys._getframe(3)
        caller_module = caller.f_globals.get('__name__', '')
        caller_name = caller.f_code.co_name

        if caller_module != 'distutils.dist' or caller_name!='run_commands':
            # We weren't called from the command line or setup(), so we
            # should run in backward-compatibility mode to support bdist_*
            # commands.
            distutils_install.run(self)
        else:
            self.do_egg_install() 
Example #15
Source File: setup.py    From geonotebook with Apache License 2.0 5 votes vote down vote up
def post_install(func, **kwargs):
    def command_wrapper(command_subclass):
        # Keep a reference to the command subclasses 'run' function
        _run = command_subclass.run

        def run(self):
            _run(self)
            log.info("running post install function {}".format(func.__name__))
            func(self, **kwargs)

        command_subclass.run = run
        return command_subclass

    return command_wrapper 
Example #16
Source File: setup.py    From geonotebook with Apache License 2.0 5 votes vote down vote up
def install_kernel(cmd):
    # Install the kernel spec when we install the package
    from ipykernel import kernelspec
    from jupyter_client.kernelspec import KernelSpecManager

    kernel_name = 'geonotebook%i' % sys.version_info[0]

    path = os.path.join(tempfile.mkdtemp(suffix='_kernels'), kernel_name)
    try:
        os.makedirs(path)
    except OSError:
        pass

    kernel_dict = {
        'argv': kernelspec.make_ipkernel_cmd(mod='geonotebook'),
        'display_name': 'Geonotebook (Python %i)' % sys.version_info[0],
        'language': 'python',
    }

    with open(os.path.join(path, 'kernel.json'), 'w') as fh:
        json.dump(kernel_dict, fh, indent=1)

    ksm = KernelSpecManager()
    ksm.install_kernel_spec(
        path, kernel_name=kernel_name, user=False, prefix=sys.prefix)

    shutil.rmtree(path)


# shamelessly taken from ipyleaflet: https://github.com/ellisonbg/ipyleaflet
# Copyright (c) 2014 Brian E. Granger 
Example #17
Source File: setup.py    From geonotebook with Apache License 2.0 5 votes vote down vote up
def run(self):
        has_npm = self.has_npm()
        if not has_npm:
            log.error(
                "`npm` unavailable.  If you're running this command using "
                "sudo, make sure `npm` is available to sudo"
            )

        env = os.environ.copy()
        env['PATH'] = npm_path

        if self.should_run_npm_install():
            log.info(
                "Installing build dependencies with npm.  "
                "This may take a while..."
            )
            check_call(
                ['npm', 'install'],
                cwd=node_root, stdout=sys.stdout, stderr=sys.stderr
            )
            log.info(
                "Building static assets.  "
            )
            check_call(
                ['npm', 'run', 'build'],
                cwd=node_root, stdout=sys.stdout, stderr=sys.stderr
            )
            os.utime(self.node_modules, None)

        for t in self.targets:
            if not os.path.exists(t):
                msg = 'Missing file: %s' % t
                if not has_npm:
                    msg += '\nnpm is required to build a development version'
                raise ValueError(msg)

        # update package data in case this created new files
        update_package_data(self.distribution) 
Example #18
Source File: setup.py    From geonotebook with Apache License 2.0 5 votes vote down vote up
def install_geonotebook_ini(cmd, link=False):

    # cmd.dist is a pkg_resources.Distribution class, See:
    # http://setuptools.readthedocs.io/en/latest/pkg_resources.html#distribution-objects

    # pkg_resources.Distribution.location can be a lot of things,  but in the
    # case of a develop install it will be the path to the source tree. This
    # will not work if applied to more exotic install targets
    # (e.g. pip install -e git@github.com:OpenGeoscience/geonotebook.git)
    base_dir = cmd.dist.location
    # cmd.distribution is a setuptools.dist.Distribution class, See:
    # https://github.com/pypa/setuptools/blob/master/setuptools/dist.py#L215
    for sys_path, local_paths in cmd.distribution.data_files:
        try:
            os.makedirs(os.path.join(sys.prefix, sys_path))
        except OSError:
            pass

        for local_path in local_paths:
            for l in glob.glob(local_path):
                src = os.path.join(base_dir, l)

                dest = os.path.join(sys_path, os.path.basename(src))\
                    if sys_path.startswith("/") else \
                    os.path.join(sys.prefix, sys_path, os.path.basename(src))

                if os.path.lexists(dest):
                    os.remove(dest)

                if link:
                    log.info("linking {} to {}".format(src, dest))
                    os.symlink(src, dest)
                else:
                    log.info("copying {} to {}".format(src, dest))
                    shutil.copyfile(src, dest) 
Example #19
Source File: environment.py    From signac-flow with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def setup(py_modules, **attrs):
    """Setup function for environment modules.

    Use this function in place of setuptools.setup to not only install
    an environment's module, but also register it with the global signac
    configuration. Once registered, the environment is automatically
    imported when the :py:meth:`~.get_environment` function is called.
    """
    import setuptools
    from setuptools.command.install import install

    class InstallAndConfig(install):

        def run(self):
            super(InstallAndConfig, self).run()
            cfg = config.read_config_file(config.FN_CONFIG)
            try:
                envs = cfg['flow'].as_list('environment_modules')
            except KeyError:
                envs = []
            new = set(py_modules).difference(envs)
            if new:
                for name in new:
                    self.announce(
                        msg="registering module '{}' in global signac configuration".format(name),
                        level=2)
                cfg.setdefault('flow', dict())
                cfg['flow']['environment_modules'] = envs + list(new)
                cfg.write()

    return setuptools.setup(
        py_modules=py_modules,
        cmdclass={'install': InstallAndConfig},
        **attrs) 
Example #20
Source File: install.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def setuptools_run(self):
        """ The setuptools version of the .run() method.

        We must pull in the entire code so we can override the level used in the
        _getframe() call since we wrap this call by one more level.
        """
        from distutils.command.install import install as distutils_install

        # Explicit request for old-style install?  Just do it
        if self.old_and_unmanageable or self.single_version_externally_managed:
            return distutils_install.run(self)

        # Attempt to detect whether we were called from setup() or by another
        # command.  If we were called by setup(), our caller will be the
        # 'run_command' method in 'distutils.dist', and *its* caller will be
        # the 'run_commands' method.  If we were called any other way, our
        # immediate caller *might* be 'run_command', but it won't have been
        # called by 'run_commands'.  This is slightly kludgy, but seems to
        # work.
        #
        caller = sys._getframe(3)
        caller_module = caller.f_globals.get('__name__', '')
        caller_name = caller.f_code.co_name

        if caller_module != 'distutils.dist' or caller_name!='run_commands':
            # We weren't called from the command line or setup(), so we
            # should run in backward-compatibility mode to support bdist_*
            # commands.
            distutils_install.run(self)
        else:
            self.do_egg_install() 
Example #21
Source File: install.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
def setuptools_run(self):
        """ The setuptools version of the .run() method.

        We must pull in the entire code so we can override the level used in the
        _getframe() call since we wrap this call by one more level.
        """
        from distutils.command.install import install as distutils_install

        # Explicit request for old-style install?  Just do it
        if self.old_and_unmanageable or self.single_version_externally_managed:
            return distutils_install.run(self)

        # Attempt to detect whether we were called from setup() or by another
        # command.  If we were called by setup(), our caller will be the
        # 'run_command' method in 'distutils.dist', and *its* caller will be
        # the 'run_commands' method.  If we were called any other way, our
        # immediate caller *might* be 'run_command', but it won't have been
        # called by 'run_commands'.  This is slightly kludgy, but seems to
        # work.
        #
        caller = sys._getframe(3)
        caller_module = caller.f_globals.get('__name__', '')
        caller_name = caller.f_code.co_name

        if caller_module != 'distutils.dist' or caller_name!='run_commands':
            # We weren't called from the command line or setup(), so we
            # should run in backward-compatibility mode to support bdist_*
            # commands.
            distutils_install.run(self)
        else:
            self.do_egg_install() 
Example #22
Source File: install.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def setuptools_run(self):
        """ The setuptools version of the .run() method.

        We must pull in the entire code so we can override the level used in the
        _getframe() call since we wrap this call by one more level.
        """
        from distutils.command.install import install as distutils_install

        # Explicit request for old-style install?  Just do it
        if self.old_and_unmanageable or self.single_version_externally_managed:
            return distutils_install.run(self)

        # Attempt to detect whether we were called from setup() or by another
        # command.  If we were called by setup(), our caller will be the
        # 'run_command' method in 'distutils.dist', and *its* caller will be
        # the 'run_commands' method.  If we were called any other way, our
        # immediate caller *might* be 'run_command', but it won't have been
        # called by 'run_commands'.  This is slightly kludgy, but seems to
        # work.
        #
        caller = sys._getframe(3)
        caller_module = caller.f_globals.get('__name__', '')
        caller_name = caller.f_code.co_name

        if caller_module != 'distutils.dist' or caller_name!='run_commands':
            # We weren't called from the command line or setup(), so we
            # should run in backward-compatibility mode to support bdist_*
            # commands.
            distutils_install.run(self)
        else:
            self.do_egg_install() 
Example #23
Source File: install.py    From keras-lambda with MIT License 5 votes vote down vote up
def setuptools_run(self):
        """ The setuptools version of the .run() method.

        We must pull in the entire code so we can override the level used in the
        _getframe() call since we wrap this call by one more level.
        """
        from distutils.command.install import install as distutils_install

        # Explicit request for old-style install?  Just do it
        if self.old_and_unmanageable or self.single_version_externally_managed:
            return distutils_install.run(self)

        # Attempt to detect whether we were called from setup() or by another
        # command.  If we were called by setup(), our caller will be the
        # 'run_command' method in 'distutils.dist', and *its* caller will be
        # the 'run_commands' method.  If we were called any other way, our
        # immediate caller *might* be 'run_command', but it won't have been
        # called by 'run_commands'.  This is slightly kludgy, but seems to
        # work.
        #
        caller = sys._getframe(3)
        caller_module = caller.f_globals.get('__name__', '')
        caller_name = caller.f_code.co_name

        if caller_module != 'distutils.dist' or caller_name!='run_commands':
            # We weren't called from the command line or setup(), so we
            # should run in backward-compatibility mode to support bdist_*
            # commands.
            distutils_install.run(self)
        else:
            self.do_egg_install() 
Example #24
Source File: packaging.py    From keras-lambda with MIT License 5 votes vote down vote up
def run(self):
        _from_git(self.distribution)
        return install.install.run(self) 
Example #25
Source File: packaging.py    From keras-lambda with MIT License 5 votes vote down vote up
def run(self):
        _from_git(self.distribution)
        return du_install.install.run(self) 
Example #26
Source File: setup.py    From blobtools with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        for req in reqs:
            pip._internal.main(["install", req]) 
Example #27
Source File: setup.py    From bluescan with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        super().run()
        print('[INFO] install bluescan_prompt.bash')
        shutil.copy(
            'src/bluescan/bluescan_prompt.bash', '/etc/bash_completion.d'
        ) 
Example #28
Source File: setup.py    From tf-pose with Apache License 2.0 5 votes vote down vote up
def run(self):
        global path, version, initVersion, forcedVersion, installVersion
        
        name = self.config_vars['dist_name']
        path = os.path.join(self.install_libbase, 'pyqtgraph')
        if os.path.exists(path):
            raise Exception("It appears another version of %s is already "
                            "installed at %s; remove this before installing." 
                            % (name, path))
        print("Installing to %s" % path)
        rval = install.install.run(self)

        
        # If the version in __init__ is different from the automatically-generated
        # version string, then we will update __init__ in the install directory
        if initVersion == version:
            return rval
        
        try:
            initfile = os.path.join(path, '__init__.py')
            data = open(initfile, 'r').read()
            open(initfile, 'w').write(re.sub(r"__version__ = .*", "__version__ = '%s'" % version, data))
            installVersion = version
        except:
            sys.stderr.write("Warning: Error occurred while setting version string in build path. "
                             "Installation will use the original version string "
                             "%s instead.\n" % (initVersion)
                             )
            if forcedVersion:
                raise
            installVersion = initVersion
            sys.excepthook(*sys.exc_info())
    
        return rval 
Example #29
Source File: install.py    From lambda-packs with MIT License 5 votes vote down vote up
def setuptools_run(self):
        """ The setuptools version of the .run() method.

        We must pull in the entire code so we can override the level used in the
        _getframe() call since we wrap this call by one more level.
        """
        from distutils.command.install import install as distutils_install

        # Explicit request for old-style install?  Just do it
        if self.old_and_unmanageable or self.single_version_externally_managed:
            return distutils_install.run(self)

        # Attempt to detect whether we were called from setup() or by another
        # command.  If we were called by setup(), our caller will be the
        # 'run_command' method in 'distutils.dist', and *its* caller will be
        # the 'run_commands' method.  If we were called any other way, our
        # immediate caller *might* be 'run_command', but it won't have been
        # called by 'run_commands'.  This is slightly kludgy, but seems to
        # work.
        #
        caller = sys._getframe(3)
        caller_module = caller.f_globals.get('__name__', '')
        caller_name = caller.f_code.co_name

        if caller_module != 'distutils.dist' or caller_name!='run_commands':
            # We weren't called from the command line or setup(), so we
            # should run in backward-compatibility mode to support bdist_*
            # commands.
            distutils_install.run(self)
        else:
            self.do_egg_install() 
Example #30
Source File: install.py    From lambda-packs with MIT License 5 votes vote down vote up
def setuptools_run(self):
        """ The setuptools version of the .run() method.

        We must pull in the entire code so we can override the level used in the
        _getframe() call since we wrap this call by one more level.
        """
        from distutils.command.install import install as distutils_install

        # Explicit request for old-style install?  Just do it
        if self.old_and_unmanageable or self.single_version_externally_managed:
            return distutils_install.run(self)

        # Attempt to detect whether we were called from setup() or by another
        # command.  If we were called by setup(), our caller will be the
        # 'run_command' method in 'distutils.dist', and *its* caller will be
        # the 'run_commands' method.  If we were called any other way, our
        # immediate caller *might* be 'run_command', but it won't have been
        # called by 'run_commands'.  This is slightly kludgy, but seems to
        # work.
        #
        caller = sys._getframe(3)
        caller_module = caller.f_globals.get('__name__', '')
        caller_name = caller.f_code.co_name

        if caller_module != 'distutils.dist' or caller_name!='run_commands':
            # We weren't called from the command line or setup(), so we
            # should run in backward-compatibility mode to support bdist_*
            # commands.
            distutils_install.run(self)
        else:
            self.do_egg_install()