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


Python setuptools.setup方法代碼示例

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


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

示例1: package_source_root

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def package_source_root(tmpdir):
    # type: ('py.path.LocalPath') -> 'py.path.LocalPath'
    root = tmpdir.join('test_packaging')

    root.join('setup.py').write("""
import setuptools
setuptools.setup(
    name='test_packaging',
    install_requires=[
        'shopify_python'
    ],
    entry_points={
        'egg_info.writers': [
            'git_sha.txt = shopify_python.packaging:write_package_revision',
        ],
    }
)
    """, ensure=True)
    return root 
開發者ID:Shopify,項目名稱:shopify_python,代碼行數:21,代碼來源:test_packaging.py

示例2: __enter__

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def __enter__(self):
        import distutils.core

        self._distutils_setup = distutils.core.setup
        distutils.core.setup = self.distutils_setup_replacement

        try:
            import setuptools

            self._setuptools_setup = setuptools.setup
            setuptools.setup = self.setuptools_setup_replacement
        except ImportError:
            self._setuptools_setup = None

        self._kw = {}
        return self 
開發者ID:regebro,項目名稱:pyroma,代碼行數:18,代碼來源:projectdata.py

示例3: test_skip_unknown_interpreter_result_json

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def test_skip_unknown_interpreter_result_json(cmd, initproj, tmpdir):
    report_path = tmpdir.join("toxresult.json")
    initproj(
        "interp123-0.5",
        filedefs={
            "tests": {"test_hello.py": "def test_hello(): pass"},
            "tox.ini": """
            [testenv:python]
            basepython=xyz_unknown_interpreter
            [testenv]
            changedir=tests
        """,
        },
    )
    result = cmd("--skip-missing-interpreters", "--result-json", report_path)
    result.assert_success()
    msg = "SKIPPED:  python: InterpreterNotFound: xyz_unknown_interpreter"
    assert any(msg == line for line in result.outlines), result.outlines
    setup_result_from_json = json.load(report_path)["testenvs"]["python"]["setup"]
    for setup_step in setup_result_from_json:
        assert "InterpreterNotFound" in setup_step["output"]
        assert setup_step["retcode"] == 0 
開發者ID:tox-dev,項目名稱:tox,代碼行數:24,代碼來源:test_z_cmdline.py

示例4: test_sdist_fails

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def test_sdist_fails(cmd, initproj):
    initproj(
        "pkg123-0.7",
        filedefs={
            "tests": {"test_hello.py": "def test_hello(): pass"},
            "setup.py": """
            syntax error
        """,
            "tox.ini": "",
        },
    )
    result = cmd()
    result.assert_fail()
    assert any(
        re.match(r".*FAIL.*could not package project.*", line) for line in result.outlines
    ), result.outlines 
開發者ID:tox-dev,項目名稱:tox,代碼行數:18,代碼來源:test_z_cmdline.py

示例5: test_no_setup_py_exits

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def test_no_setup_py_exits(cmd, initproj):
    initproj(
        "pkg123-0.7",
        filedefs={
            "tox.ini": """
            [testenv]
            commands=python -c "2 + 2"
        """,
        },
    )
    os.remove("setup.py")
    result = cmd()
    result.assert_fail()
    assert any(
        re.match(r".*ERROR.*No pyproject.toml or setup.py file found.*", line)
        for line in result.outlines
    ), result.outlines 
開發者ID:tox-dev,項目名稱:tox,代碼行數:19,代碼來源:test_z_cmdline.py

示例6: test_no_setup_py_exits_but_pyproject_toml_does

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def test_no_setup_py_exits_but_pyproject_toml_does(cmd, initproj):
    initproj(
        "pkg123-0.7",
        filedefs={
            "tox.ini": """
            [testenv]
            commands=python -c "2 + 2"
        """,
        },
    )
    os.remove("setup.py")
    pathlib2.Path("pyproject.toml").touch()
    result = cmd()
    result.assert_fail()
    assert any(
        re.match(r".*ERROR.*pyproject.toml file found.*", line) for line in result.outlines
    ), result.outlines
    assert any(
        re.match(r".*To use a PEP 517 build-backend you are required to*", line)
        for line in result.outlines
    ), result.outlines 
開發者ID:tox-dev,項目名稱:tox,代碼行數:23,代碼來源:test_z_cmdline.py

示例7: test_package_install_fails

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def test_package_install_fails(cmd, initproj):
    initproj(
        "pkg123-0.7",
        filedefs={
            "tests": {"test_hello.py": "def test_hello(): pass"},
            "setup.py": """
            from setuptools import setup
            setup(
                name='pkg123',
                description='pkg123 project',
                version='0.7',
                license='MIT',
                platforms=['unix', 'win32'],
                packages=['pkg123',],
                install_requires=['qweqwe123'],
                )
            """,
            "tox.ini": "",
        },
    )
    result = cmd()
    result.assert_fail()
    assert result.outlines[-1].startswith("ERROR:   python: InvocationError for command ") 
開發者ID:tox-dev,項目名稱:tox,代碼行數:25,代碼來源:test_z_cmdline.py

示例8: test_devenv

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def test_devenv(initproj, cmd):
    initproj(
        "example123",
        filedefs={
            "setup.py": """\
                from setuptools import setup
                setup(name='x')
            """,
            "tox.ini": """\
            [tox]
            # envlist is ignored for --devenv
            envlist = foo,bar,baz

            [testenv]
            # --devenv implies --notest
            commands = python -c "exit(1)"
            """,
        },
    )
    result = cmd("--devenv", "venv")
    result.assert_success()
    # `--devenv` defaults to the `py` environment and a develop install
    assert "py develop-inst:" in result.out
    assert re.search("py create:.*venv", result.out) 
開發者ID:tox-dev,項目名稱:tox,代碼行數:26,代碼來源:test_z_cmdline.py

示例9: test_devenv_does_not_allow_multiple_environments

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def test_devenv_does_not_allow_multiple_environments(initproj, cmd):
    initproj(
        "example123",
        filedefs={
            "setup.py": """\
                from setuptools import setup
                setup(name='x')
            """,
            "tox.ini": """\
            [tox]
            envlist=foo,bar,baz
            """,
        },
    )

    result = cmd("--devenv", "venv", "-e", "foo,bar")
    result.assert_fail()
    assert result.err == "ERROR: --devenv requires only a single -e\n" 
開發者ID:tox-dev,項目名稱:tox,代碼行數:20,代碼來源:test_z_cmdline.py

示例10: test_devenv_does_not_delete_project

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def test_devenv_does_not_delete_project(initproj, cmd):
    initproj(
        "example123",
        filedefs={
            "setup.py": """\
                from setuptools import setup
                setup(name='x')
            """,
            "tox.ini": """\
            [tox]
            envlist=foo,bar,baz
            """,
        },
    )

    result = cmd("--devenv", "")
    result.assert_fail()
    assert "would delete project" in result.out
    assert "ERROR: ConfigError: envdir must not equal toxinidir" in result.out 
開發者ID:tox-dev,項目名稱:tox,代碼行數:21,代碼來源:test_z_cmdline.py

示例11: test_setup_prints_non_ascii

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def test_setup_prints_non_ascii(initproj, cmd):
    initproj(
        "example123",
        filedefs={
            "setup.py": """\
import sys
getattr(sys.stdout, 'buffer', sys.stdout).write(b'\\xe2\\x98\\x83\\n')

import setuptools
setuptools.setup(name='example123')
""",
            "tox.ini": "",
        },
    )
    result = cmd("--notest")
    result.assert_success()
    assert "create" in result.out 
開發者ID:tox-dev,項目名稱:tox,代碼行數:19,代碼來源:test_z_cmdline.py

示例12: create_setup_file

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def create_setup_file():
    lib_version = VersionInfo("spotify_tensorflow").version_string()
    contents_for_setup_file = """
    import setuptools
    
    if __name__ == "__main__":
        setuptools.setup(
            name="spotify_tensorflow_dataflow",
            packages=setuptools.find_packages(),
            install_requires=[
                "spotify-tensorflow=={version}"
        ])
    """.format(version=lib_version)  # noqa: W293
    setup_file_path = os.path.join(tempfile.mkdtemp(), "setup.py")
    with open(setup_file_path, "w") as f:
        f.writelines(textwrap.dedent(contents_for_setup_file))
    return setup_file_path 
開發者ID:spotify,項目名稱:spotify-tensorflow,代碼行數:19,代碼來源:utils.py

示例13: make_release_tree

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def make_release_tree(self, base_dir, files):
        import os
        sdist.make_release_tree(self, base_dir, files)
        version_file = os.path.join(base_dir, 'VERSION')
        print('updating %s' % (version_file,))
        # Write to temporary file first and rename over permanent not
        # just to avoid atomicity issues (not likely an issue since if
        # interrupted the whole sdist directory is only partially
        # written) but because the upstream sdist may have made a hard
        # link, so overwriting in place will edit the source tree.
        with open(version_file + '.tmp', 'wb') as f:
            f.write('%s\n' % (pkg_version,))
        os.rename(version_file + '.tmp', version_file)

# XXX These should be attributes of `setup', but helpful distutils
# doesn't pass them through when it doesn't know about them a priori. 
開發者ID:probcomp,項目名稱:cgpm,代碼行數:18,代碼來源:setup.py

示例14: setUp

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def setUp(self):
        self.dir = tempfile.mkdtemp()
        setup = os.path.join(self.dir, 'setup.py')
        f = open(setup, 'w')
        f.write(SETUP_PY)
        f.close()
        self.old_cwd = os.getcwd()
        os.chdir(self.dir)

        self.old_enable_site = site.ENABLE_USER_SITE
        self.old_file = easy_install_pkg.__file__
        self.old_base = site.USER_BASE
        site.USER_BASE = tempfile.mkdtemp()
        self.old_site = site.USER_SITE
        site.USER_SITE = tempfile.mkdtemp()
        easy_install_pkg.__file__ = site.USER_SITE 
開發者ID:MayOneUS,項目名稱:pledgeservice,代碼行數:18,代碼來源:test_easy_install.py

示例15: test_setup_requires

# 需要導入模塊: import setuptools [as 別名]
# 或者: from setuptools import setup [as 別名]
def test_setup_requires(self):
        """Regression test for Distribute issue #318

        Ensure that a package with setup_requires can be installed when
        setuptools is installed in the user site-packages without causing a
        SandboxViolation.
        """

        test_pkg = create_setup_requires_package(self.dir)
        test_setup_py = os.path.join(test_pkg, 'setup.py')

        try:
            with quiet_context():
                with reset_setup_stop_context():
                    run_setup(test_setup_py, ['install'])
        except SandboxViolation:
            self.fail('Installation caused SandboxViolation')
        except IndexError:
            # Test fails in some cases due to bugs in Python
            # See https://bitbucket.org/pypa/setuptools/issue/201
            pass 
開發者ID:MayOneUS,項目名稱:pledgeservice,代碼行數:23,代碼來源:test_easy_install.py


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