Repository: conda/conda-build

Issue:
conda convert: win-to-unix results in CondaVerificationErrors because of backslashes
<!--
Thanks for opening an issue! A few things to keep in mind:

- This issue tracker is for issues with or enhancements for conda-build.

For conda issues, you should open an issue at https://github.com/conda/conda/issues
For Anaconda issues, you should open an issue at https://github.com/ContinuumIO/anaconda-issues/issues
For an issue with a particular conda-forge package, you should open an issue on the 
corresponding feedstock: https://github.com/conda-forge
-->

### Actual Behavior
`info/files` and `info/paths.json` both contain backslashes as path separators, resulting in the following when installing a Linux package that has been converted from a Windows package (error for every path).
```
CondaVerificationError: The package for imageio located at /opt/conda/pkgs/imageio-2.3.0-py36_0
appears to be corrupted. The path 'lib\python3.6\site-packages\imageio-2.3.0-py3.6.egg-info'
specified in the package manifest cannot be found.

CondaVerificationError: The package for imageio located at /opt/conda/pkgs/imageio-2.3.0-py36_0
appears to be corrupted. The path 'lib\python3.6\site-packages\imageio\__init__.py'
specified in the package manifest cannot be found.

CondaVerificationError: The package for imageio located at /opt/conda/pkgs/imageio-2.3.0-py36_0
appears to be corrupted. The path 'lib\python3.6\site-packages\imageio\__main__.py'
specified in the package manifest cannot be found.

etc...
```
### Expected Behavior
All path separators in `info/files` and `info/paths.json` should be a forward slash ("/") as per  <a href="https://conda.io/docs/user-guide/tasks/build-packages/package-spec.html">docs</a>
 > The directory delimiter for the files in info/files should always be “/”, even on Windows.

In `convert.py`:<br>
`update_files_file` seems like it simply writes Windows paths to `files`.

`paths.json` seems like it contains backslashes because of <a href="https://docs.python.org/3/library/os.path.html#os.path.normpath">os.path.normpath</a> in `update_lib_path`
> On Windows, it converts forward slashes to backward slashes.

### Steps to Reproduce

On a Windows machine in an env with conda-build, convert package to Linux:

    conda convert --platform linux-64 <some_pure_python_package.tar.bz2>

On a Linux machine in an env with conda-build, setup local channel from env directory:
```
mkdir -p conda-bld/noarch conda-bld/linux-64
echo '{}' > conda-bld/noarch/repodata.json
bzip2 -k conda-bld/noarch/repodata.json
```
Copy converted package to conda-bld/linux-64 directory. 
Index package and attempt to install from local channel:
```
conda index conda-bld/linux-64
conda install -c file://<path_to_env>/conda-bld --override-channels <some_pure_python_package>
```
##### `Output of conda info`
<!-- Between the ticks below, paste the output of 'conda info' -->
```
active environment : base
    active env location : ...\AppData\Local\Continuum\miniconda3\envs\conda-orig
            shell level : 2
       user config file : ...\.condarc
 populated config files : ...\.condarc
          conda version : 4.5.3
    conda-build version : 3.10.2
         python version : 3.6.5.final.0
       base environment : ...\AppData\Local\Continuum\miniconda3\envs\conda-orig  (writable)
           channel URLs : https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/win-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/win-64
                          https://repo.anaconda.com/pkgs/pro/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : ...\AppData\Local\Continuum\miniconda3\envs\conda-orig\pkgs
                          ...\AppData\Local\conda\conda\pkgs
       envs directories : ...\AppData\Local\Continuum\miniconda3\envs\conda-orig\envs
                          ...\AppData\Local\conda\conda\envs
                          ...\.conda\envs
               platform : win-64
             user-agent : conda/4.5.3 requests/2.18.4 CPython/3.6.5 Windows/10 Windows/10.0.17134
          administrator : False
             netrc file : None
           offline mode : False
```




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
@@ -708,8 +708,11 @@ def build_info_files_json_v1(m, prefix, files, files_with_prefix):
     for fi in sorted(files):
         prefix_placeholder, file_mode = has_prefix(fi, files_with_prefix)
         path = os.path.join(prefix, fi)
+        short_path = get_short_path(m, fi)
+        if short_path:
+            short_path = short_path.replace('\\', '/').replace('\\\\', '/')
         file_info = {
-            "_path": get_short_path(m, fi),
+            "_path": short_path,
             "sha256": sha256_checksum(path),
             "size_in_bytes": os.path.getsize(path),
             "path_type": path_type(path),
diff --git a/conda_build/convert.py b/conda_build/convert.py
--- a/conda_build/convert.py
+++ b/conda_build/convert.py
@@ -380,6 +380,8 @@ def update_paths_file(temp_dir, target_platform):
                     path['sha256'] = update_executable_sha(temp_dir, path['_path'])
                     path['size_in_bytes'] = update_executable_size(temp_dir, path['_path'])
 
+                path['_path'] = path['_path'].replace('\\', '/').replace('\\\\', '/')
+
             script_directory = os.path.join(temp_dir, 'Scripts')
             if os.path.isdir(script_directory):
                 for script in os.listdir(script_directory):
@@ -396,6 +398,8 @@ def update_paths_file(temp_dir, target_platform):
                     path['sha256'] = update_executable_sha(temp_dir, path['_path'])
                     path['size_in_bytes'] = update_executable_size(temp_dir, path['_path'])
 
+                path['_path'] = path['_path'].replace('\\', '/').replace('\\\\', '/')
+
                 if path['_path'].endswith(('.bat', '.exe')):
                     paths['paths'].remove(path)
 
@@ -558,7 +562,7 @@ def update_files_file(temp_dir, verbose):
             relative_dir = os.path.relpath(dirpath, temp_dir)
             filenames = [os.path.join(relative_dir, f) for f in filenames]
             for filename in filter_info_files(filenames, ''):
-                file_paths.append(filename)
+                file_paths.append(filename.replace('\\', '/').replace('\\\\', '/'))
                 if verbose:
                     print('Updating {}' .format(filename))
 


Test patch: