Repository: conda/conda-build

Issue:
Conda-build uploads my package even with "binstar_upload: no"
After upgrading conda, `binstar_upload: no` is no longer respected 

```
cat ~/.condarc 
show_channel_urls: yes
binstar_upload: no
```

```
conda build .
Removing old build environment
BUILD START: conda_gc_test-1.2.1-py35_3
prepending /Users/sean/anaconda/envs/_build/bin to PATH
Package: conda_gc_test-1.2.1-py35_3
no source
+ echo Building
Building
number of files: 0
Fixing permissions
Fixing permissions
BUILD END: conda_gc_test-1.2.1-py35_3
Nothing to test for: conda_gc_test-1.2.1-py35_3
Uploading to anaconda.org
Using Anaconda Cloud api site https://api.anaconda.org
detecting package type ...
conda
extracting package attributes for upload ...
done

Uploading file sean/conda_gc_test/1.2.1/osx-64/conda_gc_test-1.2.1-py35_3.tar.bz2 ... 
Distribution already exists. Please use the -i/--interactive or --force options or `anaconda remove sean/conda_gc_test/1.2.1/osx-64/conda_gc_test-1.2.1-py35_3.tar.bz2`
[Conflict] ('file osx-64/conda_gc_test-1.2.1-py35_3.tar.bz2 already exists for package conda_gc_test version 1.2.1', 409)
```



Discussion:

Resolving patch:
diff --git a/conda_build/main_build.py b/conda_build/main_build.py
--- a/conda_build/main_build.py
+++ b/conda_build/main_build.py
@@ -144,16 +144,17 @@ def handle_binstar_upload(path, args):
     import subprocess
     from conda_build.external import find_executable
 
+    upload = False
+    # this is the default, for no explicit argument.
+    # remember that args.binstar_upload takes defaults from condarc
     if args.binstar_upload is None:
         args.yes = False
         args.dry_run = False
-#        upload = common.confirm_yn(
-#            args,
-#            message="Do you want to upload this "
-#            "package to binstar", default='yes', exit_no=False)
-        upload = False
+    # rc file has uploading explicitly turned off
+    elif args.binstar_upload is False:
+        print("# Automatic uploading is disabled")
     else:
-        upload = args.binstar_upload
+        upload = True
 
     no_upload_message = """\
 # If you want to upload this package to anaconda.org later, type:


Test patch:
diff --git a/tests/test_build_recipes.py b/tests/test_build_recipes.py
--- a/tests/test_build_recipes.py
+++ b/tests/test_build_recipes.py
@@ -271,6 +271,26 @@ def test_token_upload():
     subprocess.check_call(cmd.split())
 
 
+@pytest.mark.parametrize("service_name", ["binstar", "anaconda"])
+def test_no_anaconda_upload_condarc(service_name):
+    with TemporaryDirectory() as tmp:
+        rcfile = os.path.join(tmp, ".condarc")
+        with open(rcfile, 'w') as f:
+            f.write("{}_upload: False\n".format(service_name))
+        env = os.environ.copy()
+        env["CONDARC"] = rcfile
+        cmd = "conda build {}/empty_sections".format(metadata_dir)
+        process = subprocess.Popen(cmd.split(),
+                                   stdout=subprocess.PIPE,
+                                   stderr=subprocess.PIPE,
+                                   env=env)
+        output, error = process.communicate()
+        output = output.decode('utf-8')
+        error = error.decode('utf-8')
+        sys.stderr.write(output)
+        assert "Automatic uploading is disabled" in output, error
+
+
 def test_patch_strip_level():
     patchfiles = set(('some/common/prefix/one.txt',
                       'some/common/prefix/two.txt',