Пример #1
0
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
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
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
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
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
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
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
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
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
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
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
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
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
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)