當前位置: 首頁>>代碼示例>>Python>>正文


Python dist.Distribution方法代碼示例

本文整理匯總了Python中setuptools.dist.Distribution方法的典型用法代碼示例。如果您正苦於以下問題:Python dist.Distribution方法的具體用法?Python dist.Distribution怎麽用?Python dist.Distribution使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在setuptools.dist的用法示例。


在下文中一共展示了dist.Distribution方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_view

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def test_view(self):
        stub_mod_call(self, cli)
        tmpdir = mkdtemp(self)
        os.chdir(tmpdir)
        dist = Distribution(dict(
            script_name='setup.py',
            script_args=['npm', '--view'],
            name='foo',
        ))
        dist.parse_command_line()
        dist.run_commands()

        self.assertFalse(exists(join(tmpdir, 'package.json')))
        # also log handlers removed.
        self.assertEqual(len(getLogger('calmjs.cli').handlers), 0)
        # written to stdout with the correct indentation level.
        self.assertIn('\n        "jquery": "~1.11.0"', sys.stdout.getvalue()) 
開發者ID:calmjs,項目名稱:calmjs,代碼行數:19,代碼來源:test_npm.py

示例2: test_install_no_init_nodevnoprod

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def test_install_no_init_nodevnoprod(self):
        # install implies init
        stub_mod_call(self, cli)
        stub_base_which(self, which_npm)
        tmpdir = mkdtemp(self)
        os.chdir(tmpdir)
        dist = Distribution(dict(
            script_name='setup.py',
            script_args=['npm', '--install'],
            name='foo',
        ))
        dist.parse_command_line()
        dist.run_commands()

        with open(os.path.join(tmpdir, 'package.json')) as fd:
            result = json.load(fd)

        # The cli will still automatically write to that, as install
        # implies init.
        self.assertEqual(result, {
            'dependencies': {'jquery': '~1.11.0'},
            'devDependencies': {},
            'name': 'foo',
        })
        self.assertEqual(self.call_args[0], ([which_npm, 'install'],)) 
開發者ID:calmjs,項目名稱:calmjs,代碼行數:27,代碼來源:test_npm.py

示例3: test_install_init_install_production

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def test_install_init_install_production(self):
        stub_mod_call(self, cli)
        stub_base_which(self, which_npm)
        tmpdir = mkdtemp(self)
        os.chdir(tmpdir)
        dist = Distribution(dict(
            script_name='setup.py',
            script_args=['npm', '--init', '--install', '--production'],
            name='foo',
        ))
        dist.parse_command_line()
        dist.run_commands()

        with open(os.path.join(tmpdir, 'package.json')) as fd:
            result = json.load(fd)

        self.assertEqual(result, {
            'dependencies': {'jquery': '~1.11.0'},
            'devDependencies': {},
            'name': 'foo',
        })
        # Should still invoke install
        self.assertEqual(self.call_args[0], (
            [which_npm, 'install', '--production=true'],)) 
開發者ID:calmjs,項目名稱:calmjs,代碼行數:26,代碼來源:test_npm.py

示例4: test_install_init_install_develop

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def test_install_init_install_develop(self):
        stub_mod_call(self, cli)
        stub_base_which(self, which_npm)
        tmpdir = mkdtemp(self)
        os.chdir(tmpdir)
        dist = Distribution(dict(
            script_name='setup.py',
            script_args=['npm', '--init', '--install', '--development'],
            name='foo',
        ))
        dist.parse_command_line()
        dist.run_commands()

        with open(os.path.join(tmpdir, 'package.json')) as fd:
            result = json.load(fd)

        self.assertEqual(result, {
            'dependencies': {'jquery': '~1.11.0'},
            'devDependencies': {},
            'name': 'foo',
        })
        # Should still invoke install
        self.assertEqual(self.call_args[0], (
            [which_npm, 'install', '--production=false'],)) 
開發者ID:calmjs,項目名稱:calmjs,代碼行數:26,代碼來源:test_npm.py

示例5: test_install_view

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def test_install_view(self):
        stub_mod_call(self, cli)
        stub_base_which(self, which_npm)
        tmpdir = mkdtemp(self)
        os.chdir(tmpdir)
        dist = Distribution(dict(
            script_name='setup.py',
            script_args=['npm', '--install', '--view'],
            name='foo',
        ))
        dist.parse_command_line()
        dist.run_commands()

        with open(os.path.join(tmpdir, 'package.json')) as fd:
            result = json.load(fd)

        self.assertEqual(result, {
            'dependencies': {'jquery': '~1.11.0'},
            'devDependencies': {},
            'name': 'foo',
        })
        self.assertEqual(self.call_args[0], ([which_npm, 'install'],)) 
開發者ID:calmjs,項目名稱:calmjs,代碼行數:24,代碼來源:test_npm.py

示例6: test_get_dist_package_decoding_error

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def test_get_dist_package_decoding_error(self):
        # Quiet stdout from distutils logs
        stub_stdouts(self)

        # trailing comma
        package_json = '{"dependencies": {"left-pad": "~1.1.1"},}'
        # bad data could be created by a competiting package.
        mock_provider = MockProvider({
            self.pkgname: package_json,
        })
        mock_dist = pkg_resources.Distribution(
            metadata=mock_provider, project_name='dummydist', version='0.0.0')

        results = calmjs_dist.read_dist_egginfo_json(mock_dist)

        # Should still not fail.
        self.assertIsNone(results) 
開發者ID:calmjs,項目名稱:calmjs,代碼行數:19,代碼來源:test_dist.py

示例7: test_build_calmjs_artifacts_standard

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def test_build_calmjs_artifacts_standard(self):
        dist = distutils_dist.Distribution()
        build_cmd = dist.get_command_obj('build')
        original_subcmds = list(build_cmd.sub_commands)
        calmjs_dist.build_calmjs_artifacts(dist, 'build_artifact', False)
        self.assertEqual(original_subcmds, build_cmd.sub_commands)

        # keys are named after the build step.
        calmjs_dist.build_calmjs_artifacts(dist, 'build_artifact', True)
        self.assertEqual(
            ('build_artifact', calmjs_dist.has_calmjs_artifact_declarations),
            build_cmd.sub_commands[-1],
        )

        calmjs_dist.build_calmjs_artifacts(dist, 'calmjs_artifact', True)
        self.assertEqual(
            ('calmjs_artifact', calmjs_dist.has_calmjs_artifact_declarations),
            build_cmd.sub_commands[-1],
        ) 
開發者ID:calmjs,項目名稱:calmjs,代碼行數:21,代碼來源:test_dist.py

示例8: test_view

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def test_view(self):
        stub_mod_call(self, cli)
        tmpdir = mkdtemp(self)
        os.chdir(tmpdir)
        dist = Distribution(dict(
            script_name='setup.py',
            script_args=['yarn', '--view'],
            name='foo',
        ))
        dist.parse_command_line()
        dist.run_commands()

        self.assertFalse(exists(join(tmpdir, 'package.json')))
        # also log handlers removed.
        self.assertEqual(len(getLogger('calmjs.cli').handlers), 0)
        # written to stdout with the correct indentation level.
        self.assertIn('\n        "jquery": "~1.11.0"', sys.stdout.getvalue()) 
開發者ID:calmjs,項目名稱:calmjs,代碼行數:19,代碼來源:test_yarn.py

示例9: test_install_no_init_nodevnoprod

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def test_install_no_init_nodevnoprod(self):
        # install implies init
        stub_mod_call(self, cli)
        stub_base_which(self, which_yarn)
        tmpdir = mkdtemp(self)
        os.chdir(tmpdir)
        dist = Distribution(dict(
            script_name='setup.py',
            script_args=['yarn', '--install'],
            name='foo',
        ))
        dist.parse_command_line()
        dist.run_commands()

        with open(os.path.join(tmpdir, 'package.json')) as fd:
            result = json.load(fd)

        # The cli will still automatically write to that, as install
        # implies init.
        self.assertEqual(result, {
            'dependencies': {'jquery': '~1.11.0'},
            'devDependencies': {},
            'name': 'foo',
        })
        self.assertEqual(self.call_args[0], ([which_yarn, 'install'],)) 
開發者ID:calmjs,項目名稱:calmjs,代碼行數:27,代碼來源:test_yarn.py

示例10: test_install_init_install_production

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def test_install_init_install_production(self):
        stub_mod_call(self, cli)
        stub_base_which(self, which_yarn)
        tmpdir = mkdtemp(self)
        os.chdir(tmpdir)
        dist = Distribution(dict(
            script_name='setup.py',
            script_args=['yarn', '--init', '--install', '--production'],
            name='foo',
        ))
        dist.parse_command_line()
        dist.run_commands()

        with open(os.path.join(tmpdir, 'package.json')) as fd:
            result = json.load(fd)

        self.assertEqual(result, {
            'dependencies': {'jquery': '~1.11.0'},
            'devDependencies': {},
            'name': 'foo',
        })
        # Should still invoke install
        self.assertEqual(self.call_args[0], (
            [which_yarn, 'install', '--production=true'],)) 
開發者ID:calmjs,項目名稱:calmjs,代碼行數:26,代碼來源:test_yarn.py

示例11: test_install_init_install_develop

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def test_install_init_install_develop(self):
        stub_mod_call(self, cli)
        stub_base_which(self, which_yarn)
        tmpdir = mkdtemp(self)
        os.chdir(tmpdir)
        dist = Distribution(dict(
            script_name='setup.py',
            script_args=['yarn', '--init', '--install', '--development'],
            name='foo',
        ))
        dist.parse_command_line()
        dist.run_commands()

        with open(os.path.join(tmpdir, 'package.json')) as fd:
            result = json.load(fd)

        self.assertEqual(result, {
            'dependencies': {'jquery': '~1.11.0'},
            'devDependencies': {},
            'name': 'foo',
        })
        # Should still invoke install
        self.assertEqual(self.call_args[0], (
            [which_yarn, 'install', '--production=false'],)) 
開發者ID:calmjs,項目名稱:calmjs,代碼行數:26,代碼來源:test_yarn.py

示例12: test_install_view

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def test_install_view(self):
        stub_mod_call(self, cli)
        stub_base_which(self, which_yarn)
        tmpdir = mkdtemp(self)
        os.chdir(tmpdir)
        dist = Distribution(dict(
            script_name='setup.py',
            script_args=['yarn', '--install', '--view'],
            name='foo',
        ))
        dist.parse_command_line()
        dist.run_commands()

        with open(os.path.join(tmpdir, 'package.json')) as fd:
            result = json.load(fd)

        self.assertEqual(result, {
            'dependencies': {'jquery': '~1.11.0'},
            'devDependencies': {},
            'name': 'foo',
        })
        self.assertEqual(self.call_args[0], ([which_yarn, 'install'],)) 
開發者ID:calmjs,項目名稱:calmjs,代碼行數:24,代碼來源:test_yarn.py

示例13: parse_configuration

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def parse_configuration(
        distribution, command_options, ignore_option_errors=False):
    """Performs additional parsing of configuration options
    for a distribution.

    Returns a list of used option handlers.

    :param Distribution distribution:
    :param dict command_options:
    :param bool ignore_option_errors: Whether to silently ignore
        options, values of which could not be resolved (e.g. due to exceptions
        in directives such as file:, attr:, etc.).
        If False exceptions are propagated as expected.
    :rtype: list
    """
    meta = ConfigMetadataHandler(
        distribution.metadata, command_options, ignore_option_errors)
    meta.parse()

    options = ConfigOptionsHandler(
        distribution, command_options, ignore_option_errors)
    options.parse()

    return [meta, options] 
開發者ID:sofia-netsurv,項目名稱:python-netsurv,代碼行數:26,代碼來源:config.py

示例14: notest_develop_with_setup_requires

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def notest_develop_with_setup_requires(self):

        wanted = ("Could not find suitable distribution for "
                  "Requirement.parse('I-DONT-EXIST')")
        old_dir = os.getcwd()
        os.chdir(self.dir)
        try:
            try:
                dist = Distribution({'setup_requires': ['I_DONT_EXIST']})
            except DistutilsError:
                e = sys.exc_info()[1]
                error = str(e)
                if error ==  wanted:
                    pass
        finally:
            os.chdir(old_dir) 
開發者ID:MayOneUS,項目名稱:pledgeservice,代碼行數:18,代碼來源:test_develop.py

示例15: test_package_data_in_sdist

# 需要導入模塊: from setuptools import dist [as 別名]
# 或者: from setuptools.dist import Distribution [as 別名]
def test_package_data_in_sdist(self):
        """Regression test for pull request #4: ensures that files listed in
        package_data are included in the manifest even if they're not added to
        version control.
        """

        dist = Distribution(SETUP_ATTRS)
        dist.script_name = 'setup.py'
        cmd = sdist(dist)
        cmd.ensure_finalized()

        # squelch output
        quiet()
        try:
            cmd.run()
        finally:
            unquiet()

        manifest = cmd.filelist.files
        self.assertTrue(os.path.join('sdist_test', 'a.txt') in manifest)
        self.assertTrue(os.path.join('sdist_test', 'b.txt') in manifest)
        self.assertTrue(os.path.join('sdist_test', 'c.rst') not in manifest) 
開發者ID:MayOneUS,項目名稱:pledgeservice,代碼行數:24,代碼來源:test_sdist.py


注:本文中的setuptools.dist.Distribution方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。