prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Set target in package section [feature request]
  ## Problem
  
  Currently the only way to change the target platform is using the built in way of handling variants. This involves including an additional file `conda_build_config.yaml`. When you try to set `target` in the package section it is completely ignored and when you try to set `target` in the outputs section it throws an error.  Something like:
  ```
  Expecting win-64 got linux-64
  ```
  
  ## Request
  
  Ideally we would like to be able to set target directly in the package section, but our needs could be met as long as that functionality is exposed and not bound to the use of `conda_build_config.yaml`. I took a look at doing this myself but I am unfamiliar with the code base and the reliance on `target_platform` seems to be entrenched in the variants logic and spread across quite a few files.
  
  Please let me know what you think!
  
  </issue>
  <code>
  [start of conda_build/tarcheck.py]
  1 from __future__ import absolute_import, division, print_function
  2 
  3 import json
  4 from os.path import basename
  5 import re
  6 import tarfile
  7 
  8 from conda_build.utils import codec
  9 
  10 
  11 def dist_fn(fn):
  12     if fn.endswith('.tar'):
  13         return fn[:-4]
  14     elif fn.endswith('.tar.bz2'):
  15         return fn[:-8]
  16     else:
  17         raise Exception('did not expect filename: %r' % fn)
  18 
  19 
  20 class TarCheck(object):
  21     def __init__(self, path, config):
  22         self.t = tarfile.open(path)
  23         self.paths = set(m.path for m in self.t.getmembers())
  24         self.dist = dist_fn(basename(path))
  25         self.name, self.version, self.build = self.dist.split('::', 1)[-1].rsplit('-', 2)
  26         self.config = config
  27 
  28     def __enter__(self):
  29         return self
  30 
  31     def __exit__(self, e_type, e_value, traceback):
  32         self.t.close()
  33 
  34     def info_files(self):
  35         if re.search('pyh[0-9a-f]{%d}_' % self.config.hash_length, self.build):
  36             return
  37         lista = [p.strip().decode('utf-8') for p in
  38                  self.t.extractfile('info/files').readlines()]
  39         seta = set(lista)
  40         if len(lista) != len(seta):
  41             raise Exception('info/files: duplicates')
  42 
  43         listb = [m.path for m in self.t.getmembers()
  44                  if not (m.path.startswith('info/') or m.isdir())]
  45         setb = set(listb)
  46         if len(listb) != len(setb):
  47             raise Exception('info_files: duplicate members')
  48 
  49         if seta == setb:
  50             return
  51         for p in sorted(seta | setb):
  52             if p not in seta:
  53                 print('%r not in info/files' % p)
  54             if p not in setb:
  55                 print('%r not in tarball' % p)
  56         raise Exception('info/files')
  57 
  58     def index_json(self):
  59         info = json.loads(self.t.extractfile('info/index.json').read().decode('utf-8'))
  60         for varname in 'name', 'version':
  61             if info[varname] != getattr(self, varname):
  62                 raise Exception('%s: %r != %r' % (varname, info[varname],
  63                                                   getattr(self, varname)))
  64         assert isinstance(info['build_number'], int)
  65 
  66     def prefix_length(self):
  67         prefix_length = None
  68         if 'info/has_prefix' in self.t.getnames():
  69             prefix_files = self.t.extractfile('info/has_prefix').readlines()
  70             for line in prefix_files:
  71                 try:
  72                     prefix, file_type, _ = line.split()
  73                 # lines not conforming to the split
  74                 except ValueError:
  75                     continue
  76                 if hasattr(file_type, 'decode'):
  77                     file_type = file_type.decode(codec)
  78                 if file_type == 'binary':
  79                     prefix_length = len(prefix)
  80                     break
  81         return prefix_length
  82 
  83     def correct_subdir(self):
  84         info = json.loads(self.t.extractfile('info/index.json').read().decode('utf-8'))
  85         assert info['subdir'] in [self.config.host_subdir, 'noarch'], \
  86             ("Inconsistent subdir in package - index.json expecting {0},"
  87              " got {1}".format(self.config.host_subdir, info['subdir']))
  88 
  89 
  90 def check_all(path, config):
  91     x = TarCheck(path, config)
  92     x.info_files()
  93     x.index_json()
  94     x.correct_subdir()
  95     x.t.close()
  96 
  97 
  98 def check_prefix_lengths(files, config):
  99     lengths = {}
  100     for f in files:
  101         length = TarCheck(f, config).prefix_length()
  102         if length and length < config.prefix_length:
  103             lengths[f] = length
  104     return lengths
  105
  [end of conda_build/tarcheck.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/conda_build/tarcheck.py b/conda_build/tarcheck.py
  --- a/conda_build/tarcheck.py
  +++ b/conda_build/tarcheck.py
  @@ -82,7 +82,7 @@
   
       def correct_subdir(self):
           info = json.loads(self.t.extractfile('info/index.json').read().decode('utf-8'))
  -        assert info['subdir'] in [self.config.host_subdir, 'noarch'], \
  +        assert info['subdir'] in [self.config.host_subdir, 'noarch', self.config.target_subdir], \
               ("Inconsistent subdir in package - index.json expecting {0},"
                " got {1}".format(self.config.host_subdir, info['subdir']))
  
verification_info: {"golden_diff": "diff --git a/conda_build/tarcheck.py b/conda_build/tarcheck.py\n--- a/conda_build/tarcheck.py\n+++ b/conda_build/tarcheck.py\n@@ -82,7 +82,7 @@\n \n     def correct_subdir(self):\n         info = json.loads(self.t.extractfile('info/index.json').read().decode('utf-8'))\n-        assert info['subdir'] in [self.config.host_subdir, 'noarch'], \\\n+        assert info['subdir'] in [self.config.host_subdir, 'noarch', self.config.target_subdir], \\\n             (\"Inconsistent subdir in package - index.json expecting {0},\"\n              \" got {1}\".format(self.config.host_subdir, info['subdir']))\n", "issue": "Set target in package section [feature request]\n## Problem\r\n\r\nCurrently the only way to change the target platform is using the built in way of handling variants. This involves including an additional file `conda_build_config.yaml`. When you try to set `target` in the package section it is completely ignored and when you try to set `target` in the outputs section it throws an error.  Something like:\r\n```\r\nExpecting win-64 got linux-64\r\n```\r\n\r\n## Request\r\n\r\nIdeally we would like to be able to set target directly in the package section, but our needs could be met as long as that functionality is exposed and not bound to the use of `conda_build_config.yaml`. I took a look at doing this myself but I am unfamiliar with the code base and the reliance on `target_platform` seems to be entrenched in the variants logic and spread across quite a few files.\r\n\r\nPlease let me know what you think!\n", "before_files": [{"content": "from __future__ import absolute_import, division, print_function\n\nimport json\nfrom os.path import basename\nimport re\nimport tarfile\n\nfrom conda_build.utils import codec\n\n\ndef dist_fn(fn):\n    if fn.endswith('.tar'):\n        return fn[:-4]\n    elif fn.endswith('.tar.bz2'):\n        return fn[:-8]\n    else:\n        raise Exception('did not expect filename: %r' % fn)\n\n\nclass TarCheck(object):\n    def __init__(self, path, config):\n        self.t = tarfile.open(path)\n        self.paths = set(m.path for m in self.t.getmembers())\n        self.dist = dist_fn(basename(path))\n        self.name, self.version, self.build = self.dist.split('::', 1)[-1].rsplit('-', 2)\n        self.config = config\n\n    def __enter__(self):\n        return self\n\n    def __exit__(self, e_type, e_value, traceback):\n        self.t.close()\n\n    def info_files(self):\n        if re.search('pyh[0-9a-f]{%d}_' % self.config.hash_length, self.build):\n            return\n        lista = [p.strip().decode('utf-8') for p in\n                 self.t.extractfile('info/files').readlines()]\n        seta = set(lista)\n        if len(lista) != len(seta):\n            raise Exception('info/files: duplicates')\n\n        listb = [m.path for m in self.t.getmembers()\n                 if not (m.path.startswith('info/') or m.isdir())]\n        setb = set(listb)\n        if len(listb) != len(setb):\n            raise Exception('info_files: duplicate members')\n\n        if seta == setb:\n            return\n        for p in sorted(seta | setb):\n            if p not in seta:\n                print('%r not in info/files' % p)\n            if p not in setb:\n                print('%r not in tarball' % p)\n        raise Exception('info/files')\n\n    def index_json(self):\n        info = json.loads(self.t.extractfile('info/index.json').read().decode('utf-8'))\n        for varname in 'name', 'version':\n            if info[varname] != getattr(self, varname):\n                raise Exception('%s: %r != %r' % (varname, info[varname],\n                                                  getattr(self, varname)))\n        assert isinstance(info['build_number'], int)\n\n    def prefix_length(self):\n        prefix_length = None\n        if 'info/has_prefix' in self.t.getnames():\n            prefix_files = self.t.extractfile('info/has_prefix').readlines()\n            for line in prefix_files:\n                try:\n                    prefix, file_type, _ = line.split()\n                # lines not conforming to the split\n                except ValueError:\n                    continue\n                if hasattr(file_type, 'decode'):\n                    file_type = file_type.decode(codec)\n                if file_type == 'binary':\n                    prefix_length = len(prefix)\n                    break\n        return prefix_length\n\n    def correct_subdir(self):\n        info = json.loads(self.t.extractfile('info/index.json').read().decode('utf-8'))\n        assert info['subdir'] in [self.config.host_subdir, 'noarch'], \\\n            (\"Inconsistent subdir in package - index.json expecting {0},\"\n             \" got {1}\".format(self.config.host_subdir, info['subdir']))\n\n\ndef check_all(path, config):\n    x = TarCheck(path, config)\n    x.info_files()\n    x.index_json()\n    x.correct_subdir()\n    x.t.close()\n\n\ndef check_prefix_lengths(files, config):\n    lengths = {}\n    for f in files:\n        length = TarCheck(f, config).prefix_length()\n        if length and length < config.prefix_length:\n            lengths[f] = length\n    return lengths\n", "path": "conda_build/tarcheck.py"}]}