From eb9627004d9e9166b5555340040294f5991d78dc Mon Sep 17 00:00:00 2001 From: Michael Sarahan Date: Fri, 3 Feb 2017 17:00:51 -0600 Subject: [PATCH] copy data into -script.py/pyc files --- conda_build/convert.py | 14 +++++++------- tests/test_api_convert.py | 24 +++++++----------------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/conda_build/convert.py b/conda_build/convert.py index 130eb241cc..f5453bb6c0 100644 --- a/conda_build/convert.py +++ b/conda_build/convert.py @@ -32,7 +32,6 @@ @echo off set PYFILE=%~f0 set PYFILE=%PYFILE:~0,-4%-script.py -@SET "CONDA_EXE=%~dp0\..\Scripts\conda.exe" "%~dp0\..\python.exe" "%PYFILE%" %* """ @@ -257,6 +256,7 @@ def get_pure_py_file_map(t, platform): file_map = {} paths_mapping_dict = {} # keep track of what we change in files pathmember = None + for member in members: # Update metadata if member.path == 'info/index.json': @@ -284,9 +284,6 @@ def get_pure_py_file_map(t, platform): oldpath = member.path for old, new in mapping: newpath = old.sub(new, oldpath) - if oldpath in file_map: - # Already been handled - break if newpath != oldpath: newmember = deepcopy(member) newmember.path = newpath @@ -314,10 +311,13 @@ def get_pure_py_file_map(t, platform): newpath = newpath + '.py' if newpath != oldpath: newmember = tarfile.TarInfo(newpath) - if PY3: - data = bytes(BAT_PROXY.replace('\n', '\r\n'), 'ascii') + if newpath.endswith('.bat'): + if PY3: + data = bytes(BAT_PROXY.replace('\n', '\r\n'), 'ascii') + else: + data = BAT_PROXY.replace('\n', '\r\n') else: - data = BAT_PROXY.replace('\n', '\r\n') + data = t.extractfile(member).read() newmember.size = len(data) file_map[newpath] = newmember, bytes_io(data) files.append(newpath) diff --git a/tests/test_api_convert.py b/tests/test_api_convert.py index d41ce7be5d..bd1d73ffea 100644 --- a/tests/test_api_convert.py +++ b/tests/test_api_convert.py @@ -1,14 +1,12 @@ import os import json -import subprocess import tarfile import pytest from conda_build.conda_interface import download from conda_build import api -from conda_build.build import create_env -from conda_build.utils import package_has_file, on_win, conda_43 +from conda_build.utils import package_has_file, on_win from .utils import metadata_dir, assert_package_consistency @@ -73,8 +71,12 @@ def test_convert_from_unix_to_win_creates_entry_points(test_config, testing_work converted_fn = os.path.join(platform, os.path.basename(fn)) assert package_has_file(converted_fn, "Scripts/test-script-manual-script.py") assert package_has_file(converted_fn, "Scripts/test-script-manual.bat") - assert package_has_file(converted_fn, "Scripts/test-script-setup-script.py") - assert package_has_file(converted_fn, "Scripts/test-script-setup.bat") + script_contents = package_has_file(converted_fn, "Scripts/test-script-setup-script.py") + assert script_contents + assert "Test script setup" in script_contents + bat_contents = package_has_file(converted_fn, "Scripts/test-script-setup.bat") + assert bat_contents + assert "set PYFILE" in bat_contents assert_package_consistency(converted_fn) paths_content = json.loads(package_has_file(converted_fn, 'info/paths.json').decode()) paths_list = {f['_path'] for f in paths_content['paths']} @@ -83,15 +85,3 @@ def test_convert_from_unix_to_win_creates_entry_points(test_config, testing_work index = json.loads(package_has_file(converted_fn, 'info/index.json').decode()) assert index['subdir'] == platform - - # conda 4.3 uses paths.json. This test makes sure that the converted package is - # installable with conda 4.3 - with open('.condarc', 'w') as f: - f.write("subdir: {}".format(platform)) - if conda_43(): - install_dir = platform + '-env' - os.environ["CONDA_SUBDIR"] = platform - p = subprocess.Popen('conda create -yp {} {}'.format(os.path.join(testing_workdir, install_dir), - converted_fn).split(), env=os.environ) - out, err = p.communicate() - import ipdb; ipdb.set_trace()