Python distutils.cmd() Examples

The following are 8 code examples of distutils.cmd(). 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 , or try the search function .
Example #1
Source File: setup.py    From django-localized-fields with MIT License 5 votes vote down vote up
def create_command(text, commands):
    """Creates a custom setup.py command."""

    class CustomCommand(BaseCommand):
        description = text

        def run(self):
            for cmd in commands:
                subprocess.check_call(cmd)

    return CustomCommand 
Example #2
Source File: dist.py    From rules_pip with MIT License 5 votes vote down vote up
def get_cmdline_options(self):
        """Return a '{cmd: {opt:val}}' map of all command-line options

        Option names are all long, but do not include the leading '--', and
        contain dashes rather than underscores.  If the option doesn't take
        an argument (e.g. '--quiet'), the 'val' is 'None'.

        Note that options provided by config files are intentionally excluded.
        """

        d = {}

        for cmd, opts in self.command_options.items():

            for opt, (src, val) in opts.items():

                if src != "command line":
                    continue

                opt = opt.replace('_', '-')

                if val == 0:
                    cmdobj = self.get_command_obj(cmd)
                    neg_opt = self.negative_opt.copy()
                    neg_opt.update(getattr(cmdobj, 'negative_opt', {}))
                    for neg, pos in neg_opt.items():
                        if pos == opt:
                            opt = neg
                            val = None
                            break
                    else:
                        raise AssertionError("Shouldn't be able to get here")

                elif val == 1:
                    val = None

                d.setdefault(cmd, {})[opt] = val

        return d 
Example #3
Source File: dist.py    From setuptools with MIT License 5 votes vote down vote up
def get_cmdline_options(self):
        """Return a '{cmd: {opt:val}}' map of all command-line options

        Option names are all long, but do not include the leading '--', and
        contain dashes rather than underscores.  If the option doesn't take
        an argument (e.g. '--quiet'), the 'val' is 'None'.

        Note that options provided by config files are intentionally excluded.
        """

        d = {}

        for cmd, opts in self.command_options.items():

            for opt, (src, val) in opts.items():

                if src != "command line":
                    continue

                opt = opt.replace('_', '-')

                if val == 0:
                    cmdobj = self.get_command_obj(cmd)
                    neg_opt = self.negative_opt.copy()
                    neg_opt.update(getattr(cmdobj, 'negative_opt', {}))
                    for neg, pos in neg_opt.items():
                        if pos == opt:
                            opt = neg
                            val = None
                            break
                    else:
                        raise AssertionError("Shouldn't be able to get here")

                elif val == 1:
                    val = None

                d.setdefault(cmd, {})[opt] = val

        return d 
Example #4
Source File: setup.py    From django-vies with MIT License 5 votes vote down vote up
def run(self):
        pattern = "vies/locale/*/LC_MESSAGES/django.po"
        for file in glob.glob(pattern):
            cmd = ["msgfmt", "-c"]
            name, ext = os.path.splitext(file)

            cmd += ["-o", "%s.mo" % name]
            cmd += ["%s.po" % name]
            self.announce(
                "running command: %s" % " ".join(cmd), level=distutils.log.INFO
            )
            subprocess.check_call(cmd, cwd=BASE_DIR)  # nosec 
Example #5
Source File: setup.py    From suds with GNU Lesser General Public License v3.0 5 votes vote down vote up
def run(self):
            # shamelessly lifted from setuptools.command.test.test.run()
            dist = self.distribution
            if dist.install_requires:
                dist.fetch_build_eggs(dist.install_requires)
            if dist.tests_require:
                dist.fetch_build_eggs(dist.tests_require)

            cmd = self._test_cmd_string()
            if self.dry_run:
                self.announce("skipping '%s' (dry run)" % (cmd,))
            else:
                self.announce("running '%s'" % (cmd,))
                self.with_project_on_sys_path(self.run_tests) 
Example #6
Source File: setup.py    From django-postgres-extra with MIT License 5 votes vote down vote up
def create_command(text, commands):
    """Creates a custom setup.py command."""

    class CustomCommand(BaseCommand):
        description = text

        def run(self):
            for cmd in commands:
                subprocess.check_call(cmd)

    return CustomCommand 
Example #7
Source File: setup.py    From caluma with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        for cmd in pipenv_setup:
            assert os.system(cmd) == 0
        print(
            "\npipenv run pytest      runs the tests"
            "\npipenv shell           enters the virtualenv"
        ) 
Example #8
Source File: dist.py    From pex with Apache License 2.0 3 votes vote down vote up
def get_cmdline_options(self):
        """Return a '{cmd: {opt:val}}' map of all command-line options

        Option names are all long, but do not include the leading '--', and
        contain dashes rather than underscores.  If the option doesn't take
        an argument (e.g. '--quiet'), the 'val' is 'None'.

        Note that options provided by config files are intentionally excluded.
        """

        d = {}

        for cmd, opts in self.command_options.items():

            for opt, (src, val) in opts.items():

                if src != "command line":
                    continue

                opt = opt.replace('_', '-')

                if val == 0:
                    cmdobj = self.get_command_obj(cmd)
                    neg_opt = self.negative_opt.copy()
                    neg_opt.update(getattr(cmdobj, 'negative_opt', {}))
                    for neg, pos in neg_opt.items():
                        if pos == opt:
                            opt = neg
                            val = None
                            break
                    else:
                        raise AssertionError("Shouldn't be able to get here")

                elif val == 1:
                    val = None

                d.setdefault(cmd, {})[opt] = val

        return d