Repository: conda/conda-build

Issue:
Extraction of zip files with long filename fail on 3.0.3
The extraction of zip files now takes place on windows in `C:\User\username\AppData\Local\tmpxxxxxxx\....`. In 2.* it was extracted directly into the croot...

A problem occurs, when filenames get over the length limit of windows, for example in qt. A workaround in 2.* was to set the croot to something short, `C:\tmp`. But that doesnt work anymore with 3.0.3 - what can be done?


```
Source cache directory is: C:\tmp\src_cache

Downloading source to cache: qt-everywhere-opensource-src-5.9.0.zip

Downloading http://download.qt.io/official_releases/qt/5.9/5.9.0/single/qt-everywhere-opensource-src-5.9.0.zip

Success

Extracting download

Traceback (most recent call last):

File "C:\Dev\Miniconda3\Scripts\conda-build-script.py", line 5, in 
    sys.exit(conda_build.cli.main_build.main())
  File "C:\Dev\Miniconda3\lib\site-packages\conda_build\cli\main_build.py", line 340, in main
    execute(sys.argv[1:])
  File "C:\Dev\Miniconda3\lib\site-packages\conda_build\cli\main_build.py", line 331, in execute
    noverify=args.no_verify)
  File "C:\Dev\Miniconda3\lib\site-packages\conda_build\api.py", line 183, in build
    need_source_download=need_source_download, config=config, variants=variants)
  File "C:\Dev\Miniconda3\lib\site-packages\conda_build\build.py", line 1615, in build_tree
    built_packages=built_packages,
  File "C:\Dev\Miniconda3\lib\site-packages\conda_build\build.py", line 965, in build
    try_download(m, no_download_source=False)
  File "C:\Dev\Miniconda3\lib\site-packages\conda_build\render.py", line 346, in try_download
    source.provide(metadata)
  File "C:\Dev\Miniconda3\lib\site-packages\conda_build\source.py", line 594, in provide
    locking=metadata.config.locking)
  File "C:\Dev\Miniconda3\lib\site-packages\conda_build\source.py", line 118, in unpack
    unzip(src_path, tmpdir)
  File "C:\Dev\Miniconda3\lib\site-packages\conda_build\utils.py", line 395, in unzip
    with open(path, 'wb') as fo:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\morit\AppData\Local\Temp\tmpcbwom0vr\qt-everywhere-opensource-src-5.9.0\qtwebengine\src\3rdparty\chromium\third_party\swiftshader\third_party\PowerVR_SDK\Examples\Intermediate\ColourGrading\OGLES3\Build\WindowsVC2010\OGLES3ColourGrading.vcxproj.filters'
```


Discussion:
Sorry about this.  I don't think there's a workaround.  I'll fix this ASAP.

Resolving patch:
diff --git a/conda_build/source.py b/conda_build/source.py
--- a/conda_build/source.py
+++ b/conda_build/source.py
@@ -101,7 +101,7 @@ def hoist_single_extracted_folder(nested_folder):
     rm_rf(nested_folder)
 
 
-def unpack(source_dict, src_dir, cache_folder, recipe_path, verbose=False,
+def unpack(source_dict, src_dir, cache_folder, recipe_path, croot, verbose=False,
            timeout=90, locking=True):
     ''' Uncompress a downloaded source. '''
     src_path = download_to_cache(cache_folder, recipe_path, source_dict)
@@ -110,7 +110,7 @@ def unpack(source_dict, src_dir, cache_folder, recipe_path, verbose=False,
         os.makedirs(src_dir)
     if verbose:
         print("Extracting download")
-    with TemporaryDirectory() as tmpdir:
+    with TemporaryDirectory(dir=croot) as tmpdir:
         if src_path.lower().endswith(('.tar.gz', '.tar.bz2', '.tgz', '.tar.xz',
                 '.tar', 'tar.z')):
             tar_xf(src_path, tmpdir)
@@ -590,8 +590,8 @@ def provide(metadata, patch=True):
                    metadata.config.work_dir)
         if any(k in source_dict for k in ('fn', 'url')):
             unpack(source_dict, src_dir, metadata.config.src_cache, recipe_path=metadata.path,
-                   verbose=metadata.config.verbose, timeout=metadata.config.timeout,
-                   locking=metadata.config.locking)
+                   croot=metadata.config.croot, verbose=metadata.config.verbose,
+                   timeout=metadata.config.timeout, locking=metadata.config.locking)
         elif 'git_url' in source_dict:
             git = git_source(source_dict, metadata.config.git_cache, src_dir, metadata.path,
                              verbose=metadata.config.verbose)


Test patch: