conda-build icon indicating copy to clipboard operation
conda-build copied to clipboard

Error when Description in meta.yaml contains string package:

Open verdimrc opened this issue 7 years ago • 4 comments

conda build breaks when the description in meta.yaml contains string "package:". I encountered this issue when building module versionfinder with its skeleton generated from pypi.

#File meta.yaml:
...
about:
    description: "test package: test"
...

Then conda build produces error:

$ conda build --output-folder /tmp/python /tmp/versionfinder/
Adding in variants from internal_defaults
INFO:conda_build.variants:Adding in variants from internal_defaults
Attempting to finalize metadata for versionfinder
INFO:conda_build.metadata:Attempting to finalize metadata for versionfinder
Traceback (most recent call last):
  File "/home/ec2-user/miniconda3/bin/conda-build", line 11, in <module>
    sys.exit(main())
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/conda_build/cli/main_build.py", line 399, in main
    execute(sys.argv[1:])
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/conda_build/cli/main_build.py", line 390, in execute
    verify=args.verify)
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/conda_build/api.py", line 188, in build
    need_source_download=need_source_download, config=config, variants=variants)
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/conda_build/build.py", line 1916, in build_tree
    notest=notest,
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/conda_build/build.py", line 974, in build
    output_metas = expand_outputs([(m, need_source_download, need_reparse_in_env)])
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/conda_build/render.py", line 574, in expand_outputs
    for (output_dict, m) in _m.get_output_metadata_set(permit_unsatisfiable_variants=False):
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/conda_build/metadata.py", line 1808, in get_output_metadata_set
    permit_unsatisfiable_variants=permit_unsatisfiable_variants)
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/conda_build/metadata.py", line 659, in finalize_outputs_pass
    output_d = om.get_rendered_output(metadata.name()) or {'name': metadata.name()}
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/conda_build/metadata.py", line 1853, in get_rendered_output
    for output_ in self.get_rendered_outputs_section():
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/conda_build/metadata.py", line 1843, in get_rendered_outputs_section
    template_string=template_string)) or {}).get('outputs', [])
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/__init__.py", line 94, in safe_load
    return load(stream, SafeLoader)
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/__init__.py", line 72, in load
    return loader.get_single_data()
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/constructor.py", line 35, in get_single_data
    node = self.get_single_node()
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/composer.py", line 64, in compose_node
    if self.check_event(AliasEvent):
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/parser.py", line 449, in parse_block_mapping_value
    if not self.check_token(KeyToken, ValueToken, BlockEndToken):
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/scanner.py", line 248, in fetch_more_tokens
    return self.fetch_double()
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/scanner.py", line 652, in fetch_double
    self.fetch_flow_scalar(style='"')
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/scanner.py", line 663, in fetch_flow_scalar
    self.tokens.append(self.scan_flow_scalar(style))
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/scanner.py", line 1148, in scan_flow_scalar
    chunks.extend(self.scan_flow_scalar_spaces(double, start_mark))
  File "/home/ec2-user/miniconda3/lib/python3.6/site-packages/yaml/scanner.py", line 1235, in scan_flow_scalar_spaces
    "found unexpected end of stream", self.get_mark())
yaml.scanner.ScannerError: while scanning a quoted scalar
  in "<unicode string>", line 40, column 16:
      description: "test
                   ^
found unexpected end of stream
  in "<unicode string>", line 40, column 21:
      description: "test
                        ^

verdimrc avatar Jan 18 '18 05:01 verdimrc

Yep, that's a limitation of yaml. Sorry, but I don't think there's a good way for conda-build to fix this. If you change your recipe to be formatted a little differently, it might work:

#File meta.yaml:
...
about:
    description: |
        test package: test
...

msarahan avatar Jan 18 '18 14:01 msarahan

Since @verdimrc used a double quoted string, that is a valid YAML flow scalar, so no issue there. The problem is

extract_pattern = r'(.*)package:'

from https://github.com/conda/conda-build/blob/3.2.2/conda_build/metadata.py#L1835 that is used for

match = re.search(extract_pattern, text, flags=re.MULTILINE | re.DOTALL)
text = match.group(1) if match else ""

at in https://github.com/conda/conda-build/blob/3.2.2/conda_build/metadata.py#L699-L700.

@verdimrc: As a workaround you could escape any character of package:, e.g., use

about:
    description: "test package\x3a test"

mbargull avatar Jan 18 '18 22:01 mbargull

Ah, thanks for straightening me out on that @mbargull. That may actually be something I can fix by refining the regex.

msarahan avatar Jan 18 '18 22:01 msarahan

Hi there, thank you for your contribution!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further activity occurs.

If you would like this issue to remain open please:

  1. Verify that you can still reproduce the issue at hand
  2. Comment that the issue is still reproducible and include: - What OS and version you reproduced the issue on - What steps you followed to reproduce the issue

NOTE: If this issue was closed prematurely, please leave a comment.

Thanks!

github-actions[bot] avatar Sep 27 '22 04:09 github-actions[bot]