Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort output metadata prior to writing to meta.yaml #2149

Merged
merged 1 commit into from
Jul 4, 2017

Conversation

mandeep
Copy link
Contributor

@mandeep mandeep commented Jul 3, 2017

In relation to #2140:

The field values in the metadata are sorted alphabetically prior to outputting the meta.yaml file in the info/recipe directory. The build/script and test/commands values are omitted.

@mandeep mandeep force-pushed the sort-meta-package-specs branch from 0e9ea4c to 2d95b45 Compare July 3, 2017 18:52
Added comments above metadata sorting block

Fixed typo in sorting comment
@mandeep mandeep force-pushed the sort-meta-package-specs branch from 2d95b45 to ebee064 Compare July 3, 2017 20:00
@msarahan
Copy link
Contributor

msarahan commented Jul 4, 2017

Fingers crossed that those two fields are the only ones we need to omit. Merging for now, will revisit if issues crop up.

@msarahan msarahan merged commit bb9e233 into conda:master Jul 4, 2017
@mingwandroid
Copy link
Contributor

@mandeep, @msarahan, sometimes the values here are lists, e.g. multiple sources and this code falls over:

meta.yaml:

package:
  name: pixman-cos6-x86_64
  version: 0.32.8

source:
  - url: http://mirror.centos.org/centos/6.9/os/x86_64/Packages/pixman-0.32.8-1.el6.x86_64.rpm
    sha256: d5e9a2ac49bae1bff6fd806367aa0f9125eef6dee1b515a6af6576b883032e91
    folder: binary
  - url: http://vault.centos.org/6.9/os/Source/SPackages/pixman-0.32.8-1.el6.src.rpm
    folder: source

outputs:
  - name: pixman-cos6-x86_64
    noarch: generic

    about:
      home: http://cgit.freedesktop.org/pixman/
      license: MIT
      license_family: MIT
      summary: "(CDT) Pixel manipulation library"
      description: |
        Pixman is a pixel manipulation library for X and cairo.
Traceback (most recent call last):
  File "/root/mcf-x-cos6_64/mc3/bin/conda-build", line 11, in <module>
    load_entry_point('conda-build==3.0.0a3+346.gdf29838d', 'console_scripts', 'conda-build')()
  File "/root/mcf-x-cos6_64/mc3/lib/python3.6/site-packages/conda_build-3.0.0a3+346.gdf29838d-py3.6.egg/conda_build/cli/main_build.py", line 340, in main
    execute(sys.argv[1:])
  File "/root/mcf-x-cos6_64/mc3/lib/python3.6/site-packages/conda_build-3.0.0a3+346.gdf29838d-py3.6.egg/conda_build/cli/main_build.py", line 331, in execute
    noverify=args.no_verify)
  File "/root/mcf-x-cos6_64/mc3/lib/python3.6/site-packages/conda_build-3.0.0a3+346.gdf29838d-py3.6.egg/conda_build/api.py", line 183, in build
    need_source_download=need_source_download, config=config, variants=variants)
  File "/root/mcf-x-cos6_64/mc3/lib/python3.6/site-packages/conda_build-3.0.0a3+346.gdf29838d-py3.6.egg/conda_build/build.py", line 1623, in build_tree
    built_packages=built_packages,
  File "/root/mcf-x-cos6_64/mc3/lib/python3.6/site-packages/conda_build-3.0.0a3+346.gdf29838d-py3.6.egg/conda_build/build.py", line 1192, in build
    built_package = bundlers[output_d.get('type', 'conda')](output_d, m, env)
  File "/root/mcf-x-cos6_64/mc3/lib/python3.6/site-packages/conda_build-3.0.0a3+346.gdf29838d-py3.6.egg/conda_build/build.py", line 725, in bundle_conda
    output['checksums'] = create_info_files(metadata, files, prefix=metadata.config.host_prefix)
  File "/root/mcf-x-cos6_64/mc3/lib/python3.6/site-packages/conda_build-3.0.0a3+346.gdf29838d-py3.6.egg/conda_build/build.py", line 499, in create_info_files
    copy_recipe(m)
  File "/root/mcf-x-cos6_64/mc3/lib/python3.6/site-packages/conda_build-3.0.0a3+346.gdf29838d-py3.6.egg/conda_build/build.py", line 217, in copy_recipe
    for key in value.keys():
AttributeError: 'list' object has no attribute 'keys'

mingwandroid added a commit to mingwandroid/conda-build that referenced this pull request Jul 4, 2017
@mandeep
Copy link
Contributor Author

mandeep commented Jul 4, 2017

Would it be okay to move the AttributeError exception catch earlier? Maybe start the try at the beginning of the block.

@mbargull
Copy link
Member

mbargull commented Jul 7, 2017

Maybe this behavior should be documented somewhere. That might be helpful in case of errors for some exotic/peculiar use-cases. Say someone has a weird package which uses

test:
  imports:
    - weird_module_that_installs_some_other_module_on_first_import
    - some_other_module_installed_by_the_weird_one

which wouldn't work when sorted. Of course that example is very constructed/artificial (and nothing anyone should aim for). The point is, if not documented, the sorting might be unexpected behavior from the user's stand point.
Furthermore, concerning @msarahan's comment

Fingers crossed that those two fields are the only ones we need to omit. Merging for now, will revisit if issues crop up.

: if ('build/script', 'test/commands') isn't an exhaustive blacklist and this feature causes trouble in the future, maybe a whitelist-approach will be a safer bet. BTW, there are even unordered sets (null-mappings) in standard YAML (http://yaml.org/spec/1.2/spec.html#id2761758) -- but they don't seem to used that commonly and by now it wouldn't make much sense to introduce them to conda-build, I guess.

@github-actions
Copy link

github-actions bot commented May 1, 2022

Hi there, thank you for your contribution!

This pull request has been automatically locked because it has not had recent activity after being closed.

Please open a new issue or pull request if needed.

Thanks!

@github-actions github-actions bot added the locked [bot] locked due to inactivity label May 1, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants