Skip to content

Commit

Permalink
copy data into -script.py/pyc files
Browse files Browse the repository at this point in the history
  • Loading branch information
msarahan committed Feb 3, 2017
1 parent aca963b commit eb96270
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
14 changes: 7 additions & 7 deletions conda_build/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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%" %*
"""

Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
24 changes: 7 additions & 17 deletions tests/test_api_convert.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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']}
Expand All @@ -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()

0 comments on commit eb96270

Please sign in to comment.