Repository: conda/conda-build

Issue:
--no-build-id does not seem to work
we still presently get the build folders with the long string, which occupy a lot of prefix space.

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
@@ -973,7 +973,9 @@ def build_tree(recipe_list, config, build_only=False, post=False, notest=False,
         if hasattr(recipe, 'config'):
             metadata = recipe
             recipe_config = metadata.config
-            if recipe.config.set_build_id:
+            # this code is duplicated below because we need to be sure that the build id is set
+            #    before downloading happens - or else we lose where downloads are
+            if recipe_config.set_build_id:
                 recipe_config.compute_build_id(metadata.name(), reset=True)
             recipe_parent_dir = ""
             to_build_recursive.append(metadata.name())
@@ -982,6 +984,7 @@ def build_tree(recipe_list, config, build_only=False, post=False, notest=False,
             recipe_config = config
             to_build_recursive.append(os.path.basename(recipe))
 
+            #    before downloading happens - or else we lose where downloads are
             if recipe_config.set_build_id:
                 recipe_config.compute_build_id(os.path.basename(recipe), reset=True)
             metadata, need_source_download, need_reparse_in_env = render_recipe(recipe,
diff --git a/conda_build/config.py b/conda_build/config.py
--- a/conda_build/config.py
+++ b/conda_build/config.py
@@ -347,8 +347,13 @@ def test_dir(self):
     def clean(self):
         # build folder is the whole burrito containing envs and source folders
         #   It will only exist if we download source, or create a build or test environment
-        if os.path.isdir(self.build_folder):
-            rm_rf(self.build_folder)
+        if self.build_id:
+            if os.path.isdir(self.build_folder):
+                rm_rf(self.build_folder)
+        else:
+            for path in [self.work_dir, self.test_dir, self.build_prefix, self.test_prefix]:
+                if os.path.isdir(path):
+                    rm_rf(path)
 
     def clean_pkgs(self):
         for folder in self.bldpkgs_dirs:
diff --git a/conda_build/render.py b/conda_build/render.py
--- a/conda_build/render.py
+++ b/conda_build/render.py
@@ -142,8 +142,9 @@ def render_recipe(recipe_path, config, no_download_source=False):
     if not isdir(recipe_dir):
         sys.exit("Error: no such directory: %s" % recipe_dir)
 
-    # updates a unique build id if not already computed
-    config.compute_build_id(os.path.basename(recipe_dir))
+    if config.set_build_id:
+        # updates a unique build id if not already computed
+        config.compute_build_id(os.path.basename(recipe_dir))
     try:
         m = MetaData(recipe_dir, config=config)
     except exceptions.YamlParsingError as e:


Test patch:
diff --git a/tests/test_cli.py b/tests/test_cli.py
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -88,6 +88,19 @@ def test_build_output_build_path_multiple_recipes(testing_workdir, test_config,
     assert output.rstrip().splitlines() == test_paths, error
 
 
+def test_build_no_build_id(testing_workdir, test_config, capfd):
+    args = [os.path.join(metadata_dir, "has_prefix_files"), '--no-build-id',
+            '--croot', test_config.croot]
+    main_build.execute(args)
+    fn = api.get_output_file_path(os.path.join(metadata_dir, "has_prefix_files"),
+                                  config=test_config)
+    assert package_has_file(fn, 'info/has_prefix')
+    data = package_has_file(fn, 'info/has_prefix')
+    if hasattr(data, 'decode'):
+        data = data.decode('UTF-8')
+    assert 'has_prefix_files_1' not in data
+
+
 def test_render_output_build_path_set_python(testing_workdir, capfd):
     # build the other major thing, whatever it is
     if sys.version_info.major == 3: