Repository: conda/conda-build

Issue:
Test after package build fails on Windows if whitespace in root path
Hi,
when I install Anaconda to `C:\Program Files\Anaconda3` (other paths not possible, see https://github.com/ContinuumIO/anaconda-issues/issues/1147), it seems that `conda build` doesn't deal properly with the whitespace in the path.
Package build works, but in the test step, I get the following output:

```
TEST START: packagexy-0.1.0-py35_0
[...]
The following packages will be downloaded:

    package                    |            build
   ---------------------------|-----------------
   packagexy-0.1.0            |           py35_0           2 KB  local

The following NEW packages will be INSTALLED:
[...]

C:\Users\XXXX\conda-bld\test_pkg_1476116784137\test_tmp>call C:\Program Files\Anaconda3\Scripts\activate.bat C:\Users\XXXX\conda-bld\test_pkg_1476116784137\_t_env  1>nul 2>&1

C:\Users\XXXX\conda-bld\test_pkg_1476116784137\test_tmp>if errorlevel 1 exit 1

TESTS FAILED: packagexy-0.1.0-py35_0
```

If you look at the line with the `call C:\...`, you will notice that this line will fail due to the whitespace in the path to activate.bat. CMD will read `call C:\Program [some other args]` which is invalid as `C:\Program` doesn't exist.

Adding quotes around the path to `activate.bat` will resolve this issue.

Using conda-build 2.0.2 and conda 4.2.9 on Windows 7 with Anaconda 3 64bit.



Discussion:
Thanks.  Will fix for next release.  Workaround might be to pass `--no-activate` to conda build.  This does not activate the environment, but does prepend the appropriate paths.

Thanks for the suggested workaround. Unfortunately it only brings up another error: Running `conda build --no-activate packagexy` ends also in the test phase with:

```
TEST START: packagexy-0.1.0-py35_0
updating index in: C:\Users\XXXXXX\conda-bld\win-64
updating index in: C:\Users\XXXXXX\conda-bld\noarch

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    packagexy-0.1.0            |           py35_0           2 KB  local

The following NEW packages will be INSTALLED:

[...]

WARNING conda.lock:touch(53): Failed to create lock, do not run conda in paralle
l processes [errno 13]
Runtime error: Could not open 'C:\\Program Files\\Anaconda3\\pkgs\\packagexy-0.1
.0-py35_0.tar.bz2.part' for writing ([Errno 13] Permission denied: 'C:\\Program
Files\\Anaconda3\\pkgs\\packagexy-0.1.0-py35_0.tar.bz2.part').
```

I have seen this error before, see [this thread on the conda mailing list](https://groups.google.com/a/continuum.io/forum/#!topic/conda/fMqO2GNQqSU)

Note on the previous comment: Running `conda build --no-activate packagexy` doesn't work with conda-build 2.0.2 but works with conda-build 2.0.4.

So it seems to be already fixed. However this doesn't help me as I need a full Anaconda installer which contains this fix for conda-build. 

@msarahan Will there be an Anaconda release 4.2.1 soon?

We do not have current plans for a 4.2.1 Anaconda release.  The next general Anaconda release is planned for the end of January.  If you need a custom installer sooner, I recommend Constructor: https://github.com/conda/constructor which should allow you to create your own installers with similar features to Anaconda, but with whatever packages (and package versions) you want.


Resolving patch:
diff --git a/conda_build/build.py b/conda_build/build.py
--- a/conda_build/build.py
+++ b/conda_build/build.py
@@ -733,8 +733,8 @@ def build(m, config, post=None, need_source_download=True, need_reparse_in_env=F
                             else:
                                 data = open(work_file).read()
                             with open(work_file, 'w') as bf:
-                                bf.write("source {conda_root}activate {build_prefix} &> "
-                                    "/dev/null\n".format(conda_root=root_script_dir + os.path.sep,
+                                bf.write('source "{conda_root}activate" "{build_prefix}" &> '
+                                         '/dev/null\n'.format(conda_root=root_script_dir + os.path.sep,
                                                          build_prefix=config.build_prefix))
                                 bf.write(data)
                         else:
@@ -953,7 +953,7 @@ def test(m, config, move_broken=True):
         with open(test_script, 'w') as tf:
             if config.activate:
                 ext = ".bat" if on_win else ""
-                tf.write("{source} {conda_root}activate{ext} {test_env} {squelch}\n".format(
+                tf.write('{source} "{conda_root}activate{ext}" "{test_env}" {squelch}\n'.format(
                     conda_root=root_script_dir + os.path.sep,
                     source="call" if on_win else "source",
                     ext=ext,
diff --git a/conda_build/windows.py b/conda_build/windows.py
--- a/conda_build/windows.py
+++ b/conda_build/windows.py
@@ -190,7 +190,7 @@ def build(m, bld_bat, config):
             fo.write('set "INCLUDE={};%INCLUDE%"\n'.format(env["LIBRARY_INC"]))
             fo.write('set "LIB={};%LIB%"\n'.format(env["LIBRARY_LIB"]))
             if config.activate:
-                fo.write("call {conda_root}\\activate.bat {prefix}\n".format(
+                fo.write('call "{conda_root}\\activate.bat" "{prefix}"\n'.format(
                     conda_root=root_script_dir,
                     prefix=config.build_prefix))
             fo.write("REM ===== end generated header =====\n")


Test patch: