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


Python Distribution.script_name方法代码示例

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


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

示例1: test_write_manifest_skips_non_utf8_filenames

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
        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,代码行数:33,代码来源:test_sdist.py

示例2: test_sdist_with_utf8_encoded_filename

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
    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,代码行数:32,代码来源:test_sdist.py

示例3: test_manifest_is_written_with_utf8_encoding

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
    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,代码行数:31,代码来源:test_sdist.py

示例4: test_local_index

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
    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,代码行数:36,代码来源:test_easy_install.py

示例5: test_manifest_is_written_with_utf8_encoding

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
    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,代码行数:37,代码来源:test_sdist.py

示例6: test_read_manifest_skips_non_utf8_filenames

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
    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,代码行数:31,代码来源:test_sdist.py

示例7: test_sdist_with_utf8_encoded_filename

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
    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,代码行数:35,代码来源:test_sdist.py

示例8: test_manifest_is_read_with_utf8_encoding

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
    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,代码行数:32,代码来源:test_sdist.py

示例9: test_manifest_is_read_with_surrogateescape_error_handler

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
    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,代码行数:33,代码来源:test_sdist.py

示例10: test_manifest_is_written_with_surrogateescape_error_handler

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
    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,代码行数:32,代码来源:test_sdist.py

示例11: test_sdist_with_latin1_encoded_filename

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
    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,代码行数:31,代码来源:test_sdist.py

示例12: test_run_ok

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
    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,代码行数:33,代码来源:test_bower.py

示例13: test_run_ok_custom_executable

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
    def test_run_ok_custom_executable(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 GulpCommand
        cmd = GulpCommand(dist)
        import tempfile
        cmd.instance_dir = tempfile.mkdtemp()
        gulpfile = tempfile.mkstemp(dir=cmd.instance_dir)[1]
        import os
        cmd.gulpfile = os.path.basename(gulpfile)
        cmd.executable = '/tmp/gulp'
        import mock
        with mock.patch('build_commands.gulp.find_executable') \
                as find_executable:
            find_executable.return_value = '/tmp/gulp'
            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 = ['/tmp/gulp', 'build', '--base', cmd.instance_dir, '--gulpfile', gulpfile]
        spawn_mock.assert_called_once_with(expected)
开发者ID:pombredanne,项目名称:build_commands,代码行数:37,代码来源:test_gulp.py

示例14: test_sdist_with_utf8_encoded_filename

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
    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()

        filename = os.path.join(b'sdist_test', Filenames.utf_8)
        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:Slicer,项目名称:setuptools,代码行数:34,代码来源:test_sdist.py

示例15: test_develop

# 需要导入模块: from setuptools.dist import Distribution [as 别名]
# 或者: from setuptools.dist.Distribution import script_name [as 别名]
    def test_develop(self):
        if sys.version < "2.6" or hasattr(sys, 'real_prefix'):
            return
        dist = Distribution(
            dict(name='foo',
                 packages=['foo'],
                 use_2to3=True,
                 version='0.0',
                 ))
        dist.script_name = 'setup.py'
        cmd = develop(dist)
        cmd.user = 1
        cmd.ensure_finalized()
        cmd.install_dir = site.USER_SITE
        cmd.user = 1
        old_stdout = sys.stdout
        #sys.stdout = StringIO()
        try:
            cmd.run()
        finally:
            sys.stdout = old_stdout

        # let's see if we got our egg link at the right place
        content = os.listdir(site.USER_SITE)
        content.sort()
        self.assertEqual(content, ['easy-install.pth', 'foo.egg-link'])

        # Check that we are using the right code.
        path = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt').read().split()[0].strip()
        init = open(os.path.join(path, 'foo', '__init__.py'), 'rt').read().strip()
        if sys.version < "3":
            self.assertEqual(init, 'print "foo"')
        else:
            self.assertEqual(init, 'print("foo")')
开发者ID:Aminoz,项目名称:DYE,代码行数:36,代码来源:test_develop.py


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