当前位置: 首页>>代码示例>>Python>>正文


Python dist.Distribution类代码示例

本文整理汇总了Python中setuptools.dist.Distribution的典型用法代码示例。如果您正苦于以下问题:Python Distribution类的具体用法?Python Distribution怎么用?Python Distribution使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Distribution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_sdist_with_latin1_encoded_filename

    def test_sdist_with_latin1_encoded_filename(self):
        # Test for #303.
        dist = Distribution(SETUP_ATTRS)
        dist.script_name = 'setup.py'
        cmd = sdist(dist)
        cmd.ensure_finalized()

        # Latin-1 filename
        filename = os.path.join(b('sdist_test'), LATIN1_FILENAME)
        open(filename, 'w').close()

        quiet()
        try:
            cmd.run()
        finally:
            unquiet()

        if sys.version_info >= (3,):
            filename = filename.decode('latin-1')
            if sys.platform == 'win32':
                # Latin-1 is similar to Windows-1252
                self.assertTrue(filename in cmd.filelist.files)
            else:
                # The Latin-1 filename should have been skipped
                self.assertFalse(filename in cmd.filelist.files)
        else:
            # No conversion takes place under Python 2 and the file
            # is included. We shall keep it that way for BBB.
            self.assertTrue(filename in cmd.filelist.files)
开发者ID:670information,项目名称:SmartCalendar,代码行数:29,代码来源:test_sdist.py

示例2: test_run_ok

    def test_run_ok(self):
        """ Assert spawn is called with the right parameters """
        from setuptools.dist import Distribution
        dist = Distribution(
            dict(name='foo',
                 packages=['foo'],
                 use_2to3=True,
                 version='0.0',
                 ))
        dist.script_name = 'setup.py'
        from build_commands import BowerCommand
        cmd = BowerCommand(dist)
        import tempfile
        cmd.instance_dir = tempfile.mkdtemp()
        import mock
        with mock.patch('build_commands.bower.find_executable') \
                as find_executable:
            find_executable.return_value = '/tmp/bower'
            cmd.finalize_options()

        spawn_mock = mock.MagicMock()
        cmd.spawn = spawn_mock
        import sys
        old_stdout = sys.stdout
        try:
            cmd.run()
        finally:
            sys.stdout = old_stdout

        expected = ['bower', 'install', cmd.instance_dir]
        spawn_mock.assert_called_once_with(expected)
开发者ID:pombredanne,项目名称:build_commands,代码行数:31,代码来源:test_bower.py

示例3: test_write_manifest_skips_non_utf8_filenames

        def test_write_manifest_skips_non_utf8_filenames(self):
            # Test for #303.
            dist = Distribution(SETUP_ATTRS)
            dist.script_name = 'setup.py'
            mm = manifest_maker(dist)
            mm.manifest = os.path.join('sdist_test.egg-info', 'SOURCES.txt')
            os.mkdir('sdist_test.egg-info')

            # Latin-1 filename
            filename = os.path.join(b('sdist_test'), LATIN1_FILENAME)

            # Add filename with surrogates and write manifest
            quiet()
            try:
                mm.run()
                u_filename = filename.decode('utf-8', 'surrogateescape')
                mm.filelist.files.append(u_filename)
                # Re-write manifest
                mm.write_manifest()
            finally:
                unquiet()

            manifest = open(mm.manifest, 'rbU')
            contents = manifest.read()
            manifest.close()

            # The manifest should be UTF-8 encoded
            try:
                contents.decode('UTF-8')
            except UnicodeDecodeError, e:
                self.fail(e)
开发者ID:670information,项目名称:SmartCalendar,代码行数:31,代码来源:test_sdist.py

示例4: test_sdist_with_utf8_encoded_filename

    def test_sdist_with_utf8_encoded_filename(self):
        # Test for #303.
        dist = Distribution(SETUP_ATTRS)
        dist.script_name = 'setup.py'
        cmd = sdist(dist)
        cmd.ensure_finalized()

        # UTF-8 filename
        filename = os.path.join(b('sdist_test'), b('smörbröd.py'))
        open(filename, 'w').close()

        quiet()
        try:
            cmd.run()
        finally:
            unquiet()

        if sys.platform == 'darwin':
            filename = decompose(filename)

        if sys.version_info >= (3,):
            if sys.platform == 'win32':
                # Python 3 mangles the UTF-8 filename
                filename = filename.decode('cp1252')
                self.assertTrue(filename in cmd.filelist.files)
            else:
                filename = filename.decode('utf-8')
                self.assertTrue(filename in cmd.filelist.files)
        else:
            self.assertTrue(filename in cmd.filelist.files)
开发者ID:670information,项目名称:SmartCalendar,代码行数:30,代码来源:test_sdist.py

示例5: test_manifest_is_written_with_utf8_encoding

    def test_manifest_is_written_with_utf8_encoding(self):
        # Test for #303.
        dist = Distribution(SETUP_ATTRS)
        dist.script_name = 'setup.py'
        mm = manifest_maker(dist)
        mm.manifest = os.path.join('sdist_test.egg-info', 'SOURCES.txt')
        os.mkdir('sdist_test.egg-info')

        # UTF-8 filename
        filename = os.path.join('sdist_test', 'smörbröd.py')

        # Add UTF-8 filename and write manifest
        quiet()
        try:
            mm.run()
            mm.filelist.files.append(filename)
            mm.write_manifest()
        finally:
            unquiet()

        manifest = open(mm.manifest, 'rbU')
        contents = manifest.read()
        manifest.close()

        # The manifest should be UTF-8 encoded
        try:
            u_contents = contents.decode('UTF-8')
        except UnicodeDecodeError, e:
            self.fail(e)
开发者ID:670information,项目名称:SmartCalendar,代码行数:29,代码来源:test_sdist.py

示例6: test_local_index

    def test_local_index(self):
        # make sure the local index is used
        # when easy_install looks for installed
        # packages
        new_location = tempfile.mkdtemp()
        target = tempfile.mkdtemp()
        egg_file = os.path.join(new_location, 'foo-1.0.egg-info')
        f = open(egg_file, 'w')
        try:
            f.write('Name: foo\n')
        except:
            f.close()

        sys.path.append(target)
        old_ppath = os.environ.get('PYTHONPATH')
        os.environ['PYTHONPATH'] = ':'.join(sys.path)
        try:
            dist = Distribution()
            dist.script_name = 'setup.py'
            cmd = easy_install(dist)
            cmd.install_dir = target
            cmd.args = ['foo']
            cmd.ensure_finalized()
            cmd.local_index.scan([new_location])
            res = cmd.easy_install('foo')
            self.assertEquals(res.location, new_location)
        finally:
            sys.path.remove(target)
            shutil.rmtree(new_location)
            shutil.rmtree(target)
            if old_ppath is not None:
                os.environ['PYTHONPATH'] = old_ppath
            else:
                del os.environ['PYTHONPATH']
开发者ID:runt18,项目名称:jython-plugin,代码行数:34,代码来源:test_easy_install.py

示例7: test_test

    def test_test(self):
        if sys.version < "2.6" or hasattr(sys, 'real_prefix'):
            return

        dist = Distribution(dict(
            name='foo',
            packages=['name', 'name.space', 'name.space.tests'],
            namespace_packages=['name'],
            test_suite='name.space.tests.test_suite',
            use_2to3=True,
            ))
        dist.script_name = 'setup.py'
        cmd = test(dist)
        cmd.user = 1
        cmd.ensure_finalized()
        cmd.install_dir = site.USER_SITE
        cmd.user = 1
        old_stdout = sys.stdout
        sys.stdout = StringIO()
        try:
            try: # try/except/finally doesn't work in Python 2.4, so we need nested try-statements.
                cmd.run()
            except SystemExit: # The test runner calls sys.exit, stop that making an error.
                pass
        finally:
            sys.stdout = old_stdout
开发者ID:Orav,项目名称:kbengine,代码行数:26,代码来源:test_test.py

示例8: test_read_manifest_skips_non_utf8_filenames

    def test_read_manifest_skips_non_utf8_filenames(self):
        # Test for #303.
        dist = Distribution(SETUP_ATTRS)
        dist.script_name = "setup.py"
        cmd = sdist(dist)
        cmd.ensure_finalized()

        # Create manifest
        with quiet():
            cmd.run()

        # Add Latin-1 filename to manifest
        filename = os.path.join(b("sdist_test"), LATIN1_FILENAME)
        cmd.manifest = os.path.join("sdist_test.egg-info", "SOURCES.txt")
        manifest = open(cmd.manifest, "ab")
        manifest.write(b("\n") + filename)
        manifest.close()

        # The file must exist to be included in the filelist
        open(filename, "w").close()

        # Re-read manifest
        cmd.filelist.files = []
        with quiet():
            cmd.read_manifest()

        # The Latin-1 filename should have been skipped
        filename = filename.decode("latin-1")
        assert filename not in cmd.filelist.files
开发者ID:haloteam,项目名称:halo,代码行数:29,代码来源:test_sdist.py

示例9: test_sdist_with_utf8_encoded_filename

    def test_sdist_with_utf8_encoded_filename(self):
        # Test for #303.
        dist = Distribution(SETUP_ATTRS)
        dist.script_name = "setup.py"
        cmd = sdist(dist)
        cmd.ensure_finalized()

        # UTF-8 filename
        filename = os.path.join(b("sdist_test"), b("smörbröd.py"))
        open(filename, "w").close()

        with quiet():
            cmd.run()

        if sys.platform == "darwin":
            filename = decompose(filename)

        if six.PY3:
            fs_enc = sys.getfilesystemencoding()

            if sys.platform == "win32":
                if fs_enc == "cp1252":
                    # Python 3 mangles the UTF-8 filename
                    filename = filename.decode("cp1252")
                    assert filename in cmd.filelist.files
                else:
                    filename = filename.decode("mbcs")
                    assert filename in cmd.filelist.files
            else:
                filename = filename.decode("utf-8")
                assert filename in cmd.filelist.files
        else:
            assert filename in cmd.filelist.files
开发者ID:haloteam,项目名称:halo,代码行数:33,代码来源:test_sdist.py

示例10: test_manifest_is_read_with_utf8_encoding

    def test_manifest_is_read_with_utf8_encoding(self):
        # Test for #303.
        dist = Distribution(SETUP_ATTRS)
        dist.script_name = "setup.py"
        cmd = sdist(dist)
        cmd.ensure_finalized()

        # Create manifest
        with quiet():
            cmd.run()

        # Add UTF-8 filename to manifest
        filename = os.path.join(b("sdist_test"), b("smörbröd.py"))
        cmd.manifest = os.path.join("sdist_test.egg-info", "SOURCES.txt")
        manifest = open(cmd.manifest, "ab")
        manifest.write(b("\n") + filename)
        manifest.close()

        # The file must exist to be included in the filelist
        open(filename, "w").close()

        # Re-read manifest
        cmd.filelist.files = []
        with quiet():
            cmd.read_manifest()

        # The filelist should contain the UTF-8 filename
        if six.PY3:
            filename = filename.decode("utf-8")
        assert filename in cmd.filelist.files
开发者ID:haloteam,项目名称:halo,代码行数:30,代码来源:test_sdist.py

示例11: test_manifest_is_read_with_surrogateescape_error_handler

    def test_manifest_is_read_with_surrogateescape_error_handler(self):
        # Test for #303.

        # This is hard to test on HFS Plus because it quotes unknown
        # bytes (see previous test). Furthermore, egg_info.FileList
        # only appends filenames that os.path.exist.

        # We therefore write the manifest file by hand and check whether
        # read_manifest produces a UnicodeDecodeError.
        dist = Distribution(SETUP_ATTRS)
        dist.script_name = 'setup.py'
        cmd = sdist(dist)
        cmd.ensure_finalized()

        filename = os.path.join(b('sdist_test'), LATIN1_FILENAME)

        quiet()
        try:
            cmd.run()
            # Add Latin-1 filename to manifest
            cmd.manifest = os.path.join('sdist_test.egg-info', 'SOURCES.txt')
            manifest = open(cmd.manifest, 'ab')
            manifest.write(filename+b('\n'))
            manifest.close()
            # Re-read manifest
            try:
                cmd.read_manifest()
            except UnicodeDecodeError, e:
                self.fail(e)
        finally:
            unquiet()
开发者ID:CfABrigadePhiladelphia,项目名称:Wikidelphia,代码行数:31,代码来源:test_sdist.py

示例12: test_manifest_is_written_with_surrogateescape_error_handler

    def test_manifest_is_written_with_surrogateescape_error_handler(self):
        # Test for #303.
        dist = Distribution(SETUP_ATTRS)
        dist.script_name = 'setup.py'
        mm = manifest_maker(dist)
        mm.manifest = os.path.join('sdist_test.egg-info', 'SOURCES.txt')
        os.mkdir('sdist_test.egg-info')

        # Latin-1 filename
        filename = posixpath.join(b('sdist_test'), LATIN1_FILENAME)

        # Add filename with surrogates and write manifest
        quiet()
        try:
            mm.run()
            if sys.version_info >= (3,):
                u = filename.decode('utf-8', 'surrogateescape')
                mm.filelist.files.append(u)
            else:
                mm.filelist.files.append(filename)
            mm.write_manifest()
        finally:
            unquiet()

        manifest = open(mm.manifest, 'rbU')
        contents = manifest.read()
        manifest.close()

        # The manifest should contain the Latin-1 filename
        self.assertTrue(filename in contents)
开发者ID:CfABrigadePhiladelphia,项目名称:Wikidelphia,代码行数:30,代码来源:test_sdist.py

示例13: test_tests_are_run_once

def test_tests_are_run_once(capfd):
    params = dict(
        name='foo',
        packages=['dummy'],
    )
    with open('setup.py', 'wt') as f:
        f.write('from setuptools import setup; setup(\n')
        for k, v in sorted(params.items()):
            f.write('    %s=%r,\n' % (k, v))
        f.write(')\n')
    os.makedirs('dummy')
    with open('dummy/__init__.py', 'wt'):
        pass
    with open('dummy/test_dummy.py', 'wt') as f:
        f.write(DALS(
            """
            from __future__ import print_function
            import unittest
            class TestTest(unittest.TestCase):
                def test_test(self):
                    print('Foo')
             """))
    dist = Distribution(params)
    dist.script_name = 'setup.py'
    cmd = test(dist)
    cmd.ensure_finalized()
    # The test runner calls sys.exit
    with contexts.suppress_exceptions(SystemExit):
        cmd.run()
    out, err = capfd.readouterr()
    assert out == 'Foo\n'
开发者ID:pypa,项目名称:setuptools,代码行数:31,代码来源:test_test.py

示例14: test_manifest_is_written_with_utf8_encoding

    def test_manifest_is_written_with_utf8_encoding(self):
        # Test for #303.
        dist = Distribution(SETUP_ATTRS)
        dist.script_name = "setup.py"
        mm = manifest_maker(dist)
        mm.manifest = os.path.join("sdist_test.egg-info", "SOURCES.txt")
        os.mkdir("sdist_test.egg-info")

        # UTF-8 filename
        filename = os.path.join("sdist_test", "smörbröd.py")

        # Add UTF-8 filename and write manifest
        quiet()
        try:
            mm.run()
            mm.filelist.files.append(filename)
            mm.write_manifest()
        finally:
            unquiet()

        manifest = open(mm.manifest, "rbU")
        contents = manifest.read()
        manifest.close()

        # The manifest should be UTF-8 encoded
        try:
            u_contents = contents.decode("UTF-8")
        except UnicodeDecodeError as e:
            self.fail(e)

        # The manifest should contain the UTF-8 filename
        if sys.version_info >= (3,):
            self.assertTrue(posix(filename) in u_contents)
        else:
            self.assertTrue(posix(filename) in contents)
开发者ID:rupenp,项目名称:python-nlg,代码行数:35,代码来源:test_sdist.py

示例15: __init__

 def __init__(self, *attrs):
     Distribution.__init__(self, *attrs)
     self.cmdclass['install'] = uWSGIInstall
     self.cmdclass['install_lib'] = uWSGIInstallLib
     self.cmdclass['build_ext'] = uWSGIBuilder
     if HAS_WHEEL:
         self.cmdclass['bdist_wheel'] = uWSGIWheel
开发者ID:comel,项目名称:uwsgi,代码行数:7,代码来源:setup.py


注:本文中的setuptools.dist.Distribution类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。