|
37 | 37 | import pkg_resources
|
38 | 38 |
|
39 | 39 | from . import contexts
|
| 40 | +from .files import build_files |
40 | 41 | from .textwrap import DALS
|
41 | 42 |
|
42 | 43 | __metaclass__ = type
|
@@ -744,6 +745,54 @@ def test_setup_requires_with_python_requires(self, monkeypatch, tmpdir):
|
744 | 745 | eggs = list(map(str, pkg_resources.find_distributions(os.path.join(test_pkg, '.eggs'))))
|
745 | 746 | assert eggs == ['dep 1.0']
|
746 | 747 |
|
| 748 | + def test_setup_requires_with_transitive_extra_dependency(self, monkeypatch): |
| 749 | + # Use case: installing a package with a build dependency on |
| 750 | + # an already installed `dep[extra]`, which in turn depends |
| 751 | + # on `extra_dep` (whose is not already installed). |
| 752 | + monkeypatch.setenv(str('PIP_RETRIES'), str('0')) |
| 753 | + monkeypatch.setenv(str('PIP_TIMEOUT'), str('0')) |
| 754 | + monkeypatch.setenv(str('PIP_NO_INDEX'), str('1')) |
| 755 | + with contexts.save_pkg_resources_state(): |
| 756 | + with contexts.tempdir() as temp_dir: |
| 757 | + # Create source distribution for `extra_dep`. |
| 758 | + make_trivial_sdist(os.path.join(temp_dir, 'extra_dep-1.0.tar.gz'), 'extra_dep', '1.0') |
| 759 | + # Create source tree for `dep`. |
| 760 | + dep_pkg = os.path.join(temp_dir, 'dep') |
| 761 | + os.mkdir(dep_pkg) |
| 762 | + build_files({ |
| 763 | + 'setup.py': |
| 764 | + DALS(""" |
| 765 | + import setuptools |
| 766 | + setuptools.setup( |
| 767 | + name='dep', version='2.0', |
| 768 | + extras_require={'extra': ['extra_dep']}, |
| 769 | + ) |
| 770 | + """), |
| 771 | + 'setup.cfg': '', |
| 772 | + }, prefix=dep_pkg) |
| 773 | + # "Install" dep. |
| 774 | + run_setup(os.path.join(dep_pkg, 'setup.py'), [str('dist_info')]) |
| 775 | + working_set.add_entry(dep_pkg) |
| 776 | + # Create source tree for test package. |
| 777 | + test_pkg = os.path.join(temp_dir, 'test_pkg') |
| 778 | + test_setup_py = os.path.join(test_pkg, 'setup.py') |
| 779 | + test_setup_cfg = os.path.join(test_pkg, 'setup.cfg') |
| 780 | + os.mkdir(test_pkg) |
| 781 | + with open(test_setup_py, 'w') as fp: |
| 782 | + fp.write(DALS( |
| 783 | + ''' |
| 784 | + from setuptools import installer, setup |
| 785 | + setup(setup_requires='dep[extra]') |
| 786 | + ''')) |
| 787 | + with open(test_setup_cfg, 'w') as fp: |
| 788 | + fp.write(DALS( |
| 789 | + ''' |
| 790 | + [easy_install] |
| 791 | + find_links = {find_links} |
| 792 | + ''').format(find_links=temp_dir)) |
| 793 | + # Check... |
| 794 | + run_setup(test_setup_py, [str('--version')]) |
| 795 | + |
747 | 796 |
|
748 | 797 | def make_trivial_sdist(dist_path, distname, version):
|
749 | 798 | """
|
|
0 commit comments