示例#1
0
文件: test_wheel.py 项目: ronnix/pip
def test_pip_wheel_ignore_wheels_editables():
    """
    Test 'pip wheel' ignores editables and *.whl files in requirements
    """
    env = reset_env()
    pip_install_local('wheel')

    local_wheel = '%s/simple.dist-0.1-py2.py3-none-any.whl' % find_links
    local_editable = os.path.abspath(
        os.path.join(tests_data, 'packages', 'FSPkg'))
    write_file(
        'reqs.txt',
        textwrap.dedent("""\
        %s
        -e %s
        simple
        """ % (local_wheel, local_editable)))
    result = run_pip('wheel', '--no-index', '-f', find_links, '-r',
                     env.scratch_path / 'reqs.txt')
    wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion_nodot
    wheel_file_path = env.scratch / 'wheelhouse' / wheel_file_name
    assert wheel_file_path in result.files_created, (wheel_file_path,
                                                     result.files_created)
    assert "Successfully built simple" in result.stdout, result.stdout
    assert "Failed to build" not in result.stdout, result.stdout
    assert "ignoring %s" % local_wheel in result.stdout
    ignore_editable = "ignoring %s" % path_to_url(local_editable)
    #TODO: understand this divergence
    if sys.platform == 'win32':
        ignore_editable = "ignoring %s" % path_to_url_d(local_editable)
    assert ignore_editable in result.stdout, result.stdout
示例#2
0
文件: test_wheel.py 项目: Basis/pip
def test_pip_wheel_ignore_wheels_editables():
    """
    Test 'pip wheel' ignores editables and *.whl files in requirements
    """
    env = reset_env()
    pip_install_local('wheel')

    local_wheel = '%s/simple.dist-0.1-py2.py3-none-any.whl' % find_links
    local_editable = os.path.abspath(os.path.join(tests_data, 'packages', 'FSPkg'))
    write_file('reqs.txt', textwrap.dedent("""\
        %s
        -e %s
        simple
        """ % (local_wheel, local_editable)))
    result = run_pip('wheel', '--no-index', '-f', find_links, '-r', env.scratch_path / 'reqs.txt')
    wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion_nodot
    wheel_file_path = env.scratch/'wheelhouse'/wheel_file_name
    assert wheel_file_path in result.files_created, (wheel_file_path, result.files_created)
    assert "Successfully built simple" in result.stdout, result.stdout
    assert "Failed to build" not in result.stdout, result.stdout
    assert "ignoring %s" % local_wheel in result.stdout
    ignore_editable = "ignoring %s" % path_to_url(local_editable)
    #TODO: understand this divergence
    if sys.platform == 'win32':
        ignore_editable = "ignoring %s" % path_to_url_d(local_editable)
    assert ignore_editable in result.stdout, result.stdout
示例#3
0
文件: test_wheel.py 项目: Basis/pip
def test_no_clean_option_blocks_cleaning_after_wheel():
    """
    Test --no-clean option blocks cleaning after wheel build
    """
    env = reset_env()
    pip_install_local('wheel')
    result = run_pip('wheel', '--no-clean', '--no-index', '--find-links=%s' % find_links, 'simple')
    build = env.venv_path/'build'/'simple'
    assert exists(build), "build/simple should still exist %s" % str(result)
示例#4
0
 def test_install_user_wheel(self):
     """
     Test user install from wheel
     """
     env = reset_env(system_site_packages=True)
     pip_install_local('wheel')
     result = run_pip('install', 'simple.dist==0.1', '--user', '--use-wheel',
                  '--no-index', '--find-links='+find_links)
     egg_info_folder = env.user_site / 'simple.dist-0.1.dist-info'
     assert egg_info_folder in result.files_created, str(result)
示例#5
0
def test_install_wheel_with_target():
    """
    Test installing a wheel using pip install --target
    """
    env = reset_env()
    pip_install_local('wheel')
    target_dir = env.scratch_path/'target'
    result = run_pip('install', 'simple.dist==0.1', '-t', target_dir, '--use-wheel',
                     '--no-index', '--find-links='+find_links)
    assert Path('scratch')/'target'/'simpledist' in result.files_created, str(result)
示例#6
0
文件: test_wheel.py 项目: ronnix/pip
def test_no_clean_option_blocks_cleaning_after_wheel():
    """
    Test --no-clean option blocks cleaning after wheel build
    """
    env = reset_env()
    pip_install_local('wheel')
    result = run_pip('wheel', '--no-clean', '--no-index',
                     '--find-links=%s' % find_links, 'simple')
    build = env.venv_path / 'build' / 'simple'
    assert exists(build), "build/simple should still exist %s" % str(result)
示例#7
0
 def prep_ve(self, version, distribute=False):
     self.env = reset_env(pypi_cache=False)
     pip_install_local("virtualenv==%s" % version)
     args = ["virtualenv", self.env.scratch_path / "VE"]
     if distribute:
         args.insert(1, "--distribute")
     self.env.run(*args)
     self.ve_bin = self.env.scratch_path / "VE" / "bin"
     self.env.run(self.ve_bin / "pip", "uninstall", "-y", "pip")
     self.env.run(self.ve_bin / "python", "setup.py", "install", cwd=src_folder, expect_stderr=True)
示例#8
0
 def test_install_user_wheel(self):
     """
     Test user install from wheel
     """
     env = reset_env(system_site_packages=True)
     pip_install_local('wheel')
     result = run_pip('install', 'simple.dist==0.1', '--user',
                      '--use-wheel', '--no-index',
                      '--find-links=' + find_links)
     egg_info_folder = env.user_site / 'simple.dist-0.1.dist-info'
     assert egg_info_folder in result.files_created, str(result)
示例#9
0
文件: test_wheel.py 项目: Basis/pip
def test_pip_wheel_success():
    """
    Test 'pip wheel' success.
    """
    env = reset_env()
    pip_install_local('wheel')
    result = run_pip('wheel', '--no-index', '-f', find_links, 'simple==3.0')
    wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion_nodot
    wheel_file_path = env.scratch/'wheelhouse'/wheel_file_name
    assert wheel_file_path in result.files_created, result.stdout
    assert "Successfully built simple" in result.stdout, result.stdout
示例#10
0
文件: test_wheel.py 项目: ronnix/pip
def test_pip_wheel_success():
    """
    Test 'pip wheel' success.
    """
    env = reset_env()
    pip_install_local('wheel')
    result = run_pip('wheel', '--no-index', '-f', find_links, 'simple==3.0')
    wheel_file_name = 'simple-3.0-py%s-none-any.whl' % pyversion_nodot
    wheel_file_path = env.scratch / 'wheelhouse' / wheel_file_name
    assert wheel_file_path in result.files_created, result.stdout
    assert "Successfully built simple" in result.stdout, result.stdout
示例#11
0
文件: test_wheel.py 项目: Basis/pip
def test_pip_wheel_source_deps():
    """
    Test 'pip wheel --use-wheel' finds and builds source archive dependencies of wheels
    """
    # 'requires_source' is a wheel that depends on the 'source' project
    env = reset_env()
    pip_install_local('wheel')
    result = run_pip('wheel', '--use-wheel', '--no-index', '-f', find_links, 'requires_source')
    wheel_file_name = 'source-1.0-py%s-none-any.whl' % pyversion_nodot
    wheel_file_path = env.scratch/'wheelhouse'/wheel_file_name
    assert wheel_file_path in result.files_created, result.stdout
    assert "Successfully built source" in result.stdout, result.stdout
示例#12
0
文件: test_wheel.py 项目: Basis/pip
def test_pip_wheel_fail():
    """
    Test 'pip wheel' failure.
    """
    env = reset_env()
    pip_install_local('wheel')
    result = run_pip('wheel', '--no-index', '-f', find_links, 'wheelbroken==0.1')
    wheel_file_name = 'wheelbroken-0.1-py%s-none-any.whl' % pyversion_nodot
    wheel_file_path = env.scratch/'wheelhouse'/wheel_file_name
    assert wheel_file_path not in result.files_created, (wheel_file_path, result.files_created)
    assert "FakeError" in result.stdout, result.stdout
    assert "Failed to build wheelbroken" in result.stdout, result.stdout
示例#13
0
def test_install_wheel_with_target():
    """
    Test installing a wheel using pip install --target
    """
    env = reset_env()
    pip_install_local('wheel')
    target_dir = env.scratch_path / 'target'
    result = run_pip('install', 'simple.dist==0.1', '-t', target_dir,
                     '--use-wheel', '--no-index', '--find-links=' + find_links)
    assert Path(
        'scratch') / 'target' / 'simpledist' in result.files_created, str(
            result)
示例#14
0
文件: test_wheel.py 项目: ronnix/pip
def test_pip_wheel_source_deps():
    """
    Test 'pip wheel --use-wheel' finds and builds source archive dependencies of wheels
    """
    # 'requires_source' is a wheel that depends on the 'source' project
    env = reset_env()
    pip_install_local('wheel')
    result = run_pip('wheel', '--use-wheel', '--no-index', '-f', find_links,
                     'requires_source')
    wheel_file_name = 'source-1.0-py%s-none-any.whl' % pyversion_nodot
    wheel_file_path = env.scratch / 'wheelhouse' / wheel_file_name
    assert wheel_file_path in result.files_created, result.stdout
    assert "Successfully built source" in result.stdout, result.stdout
示例#15
0
 def prep_ve(self, version, distribute=False):
     self.env = reset_env(pypi_cache=False)
     pip_install_local('virtualenv==%s' % version)
     args = ['virtualenv', self.env.scratch_path / 'VE']
     if distribute:
         args.insert(1, '--distribute')
     self.env.run(*args)
     self.ve_bin = self.env.scratch_path / 'VE' / 'bin'
     self.env.run(self.ve_bin / 'pip', 'uninstall', '-y', 'pip')
     self.env.run(self.ve_bin / 'python',
                  'setup.py',
                  'install',
                  cwd=src_folder,
                  expect_stderr=True)
示例#16
0
文件: test_wheel.py 项目: ronnix/pip
def test_pip_wheel_fail():
    """
    Test 'pip wheel' failure.
    """
    env = reset_env()
    pip_install_local('wheel')
    result = run_pip('wheel', '--no-index', '-f', find_links,
                     'wheelbroken==0.1')
    wheel_file_name = 'wheelbroken-0.1-py%s-none-any.whl' % pyversion_nodot
    wheel_file_path = env.scratch / 'wheelhouse' / wheel_file_name
    assert wheel_file_path not in result.files_created, (wheel_file_path,
                                                         result.files_created)
    assert "FakeError" in result.stdout, result.stdout
    assert "Failed to build wheelbroken" in result.stdout, result.stdout
示例#17
0
文件: test_freeze.py 项目: ronnix/pip
def test_freeze_basic():
    """
    Some tests of freeze, first we have to install some stuff.  Note that
    the test is a little crude at the end because Python 2.5+ adds egg
    info to the standard library, so stuff like wsgiref will show up in
    the freezing.  (Probably that should be accounted for in pip, but
    currently it is not).

    """
    env = reset_env()
    write_file(
        'initools-req.txt',
        textwrap.dedent("""\
        simple==2.0
        # and something else to test out:
        simple2<=3.0
        """))
    result = pip_install_local('-r', env.scratch_path / 'initools-req.txt')
    result = run_pip('freeze', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: pip freeze
        -- stdout: --------------------
        ...simple==2.0
        simple2==3.0...
        <BLANKLINE>""")
    _check_output(result, expected)
示例#18
0
文件: test_freeze.py 项目: Basis/pip
def test_freeze_with_requirement_option():
    """
    Test that new requirements are created correctly with --requirement hints

    """
    reset_env()
    ignores = textwrap.dedent("""\
        # Unchanged requirements below this line
        -r ignore.txt
        --requirement ignore.txt
        -Z ignore
        --always-unzip ignore
        -f http://ignore
        -i http://ignore
        --extra-index-url http://ignore
        --find-links http://ignore
        --index-url http://ignore
        """)
    write_file('hint.txt', textwrap.dedent("""\
        INITools==0.1
        NoExist==4.2
        """) + ignores)
    result = run_pip('install', 'initools==0.2')
    result = pip_install_local('simple')
    result = run_pip('freeze', '--requirement', 'hint.txt', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: pip freeze --requirement hint.txt
        -- stderr: --------------------
        Requirement file contains NoExist==4.2, but that package is not installed

        -- stdout: --------------------
        INITools==0.2
        """) + ignores + "## The following requirements were added by pip --freeze:..."
    _check_output(result, expected)
示例#19
0
def test_install_pybundle():
    """
    Test intalling a *.pybundle file
    """
    env = reset_env()
    result = pip_install_local(os.path.join(packages, 'simplebundle.pybundle'), expect_temp=True)
    result.assert_installed('simple', editable=False)
    result.assert_installed('simple2', editable=False)
示例#20
0
文件: test_freeze.py 项目: ronnix/pip
def test_freeze_with_requirement_option():
    """
    Test that new requirements are created correctly with --requirement hints

    """
    reset_env()
    ignores = textwrap.dedent("""\
        # Unchanged requirements below this line
        -r ignore.txt
        --requirement ignore.txt
        -Z ignore
        --always-unzip ignore
        -f http://ignore
        -i http://ignore
        --extra-index-url http://ignore
        --find-links http://ignore
        --index-url http://ignore
        """)
    write_file(
        'hint.txt',
        textwrap.dedent("""\
        INITools==0.1
        NoExist==4.2
        """) + ignores)
    result = run_pip('install', 'initools==0.2')
    result = pip_install_local('simple')
    result = run_pip('freeze', '--requirement', 'hint.txt', expect_stderr=True)
    expected = textwrap.dedent(
        """\
        Script result: pip freeze --requirement hint.txt
        -- stderr: --------------------
        Requirement file contains NoExist==4.2, but that package is not installed

        -- stdout: --------------------
        INITools==0.2
        """
    ) + ignores + "## The following requirements were added by pip --freeze:..."
    _check_output(result, expected)
示例#21
0
文件: test_freeze.py 项目: Basis/pip
def test_freeze_basic():
    """
    Some tests of freeze, first we have to install some stuff.  Note that
    the test is a little crude at the end because Python 2.5+ adds egg
    info to the standard library, so stuff like wsgiref will show up in
    the freezing.  (Probably that should be accounted for in pip, but
    currently it is not).

    """
    env = reset_env()
    write_file('initools-req.txt', textwrap.dedent("""\
        simple==2.0
        # and something else to test out:
        simple2<=3.0
        """))
    result = pip_install_local('-r', env.scratch_path/'initools-req.txt')
    result = run_pip('freeze', expect_stderr=True)
    expected = textwrap.dedent("""\
        Script result: pip freeze
        -- stdout: --------------------
        ...simple==2.0
        simple2==3.0...
        <BLANKLINE>""")
    _check_output(result, expected)