Repository: conda/conda-build

Issue:
disable_pip option is removing explicitly specified dependencies
This option is meant to disable conda's implicit addition of pip, setuptools, and wheel.  However, it is overly zealous and removes these packages even when they are explicitly specified in the recipe dependencies.  The only packages it removes should be the implicit ones.

cc @mingwandroid 


Discussion:

Resolving patch:
diff --git a/conda_build/build.py b/conda_build/build.py
--- a/conda_build/build.py
+++ b/conda_build/build.py
@@ -674,8 +674,10 @@ def create_env(prefix, specs, config, clear_cache=True, retry=0):
                         index = get_build_index(config=config, clear_cache=True)
                         actions = install_actions(prefix, index, specs)
                         if config.disable_pip:
-                            actions['LINK'] = [spec for spec in actions['LINK'] if not spec.startswith('pip-')]  # noqa
-                            actions['LINK'] = [spec for spec in actions['LINK'] if not spec.startswith('setuptools-')]  # noqa
+                            for pkg in ('pip', 'setuptools', 'wheel'):
+                                if not any(re.match('^%s(?:$| .*)' % pkg, dep) for dep in specs):
+                                    actions['LINK'] = [spec for spec in actions['LINK']
+                                                       if not spec.startswith(pkg + '-')]
                         display_actions(actions, index)
                         if utils.on_win:
                             for k, v in os.environ.items():
diff --git a/conda_build/convert.py b/conda_build/convert.py
--- a/conda_build/convert.py
+++ b/conda_build/convert.py
@@ -106,12 +106,6 @@ def retrieve_python_version(file_path):
             build_version_number[0], build_version_number[1])
 
 
-def remove_all_pyc(file_path):
-    for root, dirs, files in os.walk(file_path):
-        if '__pycache__' in dirs:
-            utils.rm_rf(os.path.join(root, '__pycache__'))
-
-
 def extract_temporary_directory(file_path):
     """Extract the source tar archive contents to a temporary directory.
 


Test patch:
diff --git a/tests/test-recipes/metadata/_disable_pip/bld.bat b/tests/test-recipes/metadata/_disable_pip/bld.bat
new file mode 100644
--- /dev/null
+++ b/tests/test-recipes/metadata/_disable_pip/bld.bat
@@ -0,0 +1 @@
+python %RECIPE_DIR%/build_script.py
diff --git a/tests/test-recipes/metadata/_disable_pip/build.sh b/tests/test-recipes/metadata/_disable_pip/build.sh
new file mode 100644
--- /dev/null
+++ b/tests/test-recipes/metadata/_disable_pip/build.sh
@@ -0,0 +1 @@
+python $RECIPE_DIR/build_script.py
diff --git a/tests/test-recipes/metadata/_disable_pip/build_script.py b/tests/test-recipes/metadata/_disable_pip/build_script.py
new file mode 100644
--- /dev/null
+++ b/tests/test-recipes/metadata/_disable_pip/build_script.py
@@ -0,0 +1,9 @@
+import sys
+# import setuptools should work
+import setuptools
+try:
+    # import pip should not.  The exception is what we want to see.
+    import pip
+except ImportError:
+    sys.exit(0)
+sys.exit(1)
diff --git a/tests/test-recipes/metadata/_disable_pip/meta.yaml b/tests/test-recipes/metadata/_disable_pip/meta.yaml
--- a/tests/test-recipes/metadata/_disable_pip/meta.yaml
+++ b/tests/test-recipes/metadata/_disable_pip/meta.yaml
@@ -8,3 +8,4 @@ build:
 requirements:
   build:
     - python
+    - setuptools
diff --git a/tests/test_api_build.py b/tests/test_api_build.py
--- a/tests/test_api_build.py
+++ b/tests/test_api_build.py
@@ -575,13 +575,7 @@ def test_disable_pip(test_config):
     recipe_path = os.path.join(metadata_dir, '_disable_pip')
     metadata, _, _ = api.render(recipe_path, config=test_config)
 
-    metadata.meta['build']['script'] = 'python -c "import pip"'
-    with pytest.raises(subprocess.CalledProcessError):
-        api.build(metadata)
-
-    metadata.meta['build']['script'] = 'python -c "import setuptools"'
-    with pytest.raises(subprocess.CalledProcessError):
-        api.build(metadata)
+    api.build(metadata)
 
 
 @pytest.mark.skipif(not sys.platform.startswith('linux'),