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

empty host section is discarded, host and build envs merged #2887

Closed
mbargull opened this issue May 16, 2018 · 8 comments · Fixed by #2896
Closed

empty host section is discarded, host and build envs merged #2887

mbargull opened this issue May 16, 2018 · 8 comments · Fixed by #2896
Labels
locked [bot] locked due to inactivity

Comments

@mbargull
Copy link
Member

Actual Behavior

host and build environments are merged if requirements/host is present but empty, i.e., an empty list or None.

Expected Behavior

build and host should not be merged for all cases were host is present, as described in the docs:

The only time that build and host are merged is when the host section is absent, and no {{ compiler() }} jinja2 functions are used in meta.yaml.

Steps to Reproduce

(base) $ conda --version
conda 4.5.4
(base) $ conda-build --version
conda-build 3.10.2
(base) $ cat meta.yaml
package:
  name: pkg
requirements:
  build:
    - bzip2
  host:
(base) $ conda render .
package:
    name: pkg
requirements:
    build:
        - libgcc-ng 7.2.0 hdf63c60_3
        - bzip2 1.0.6 h9a117a8_4
    run:
        - bzip2 >=1.0.6,<2.0a0
extra:
    copy_test_source_files: true
    final: true

(base) $ echo '    - unzip' >> meta.yaml 
(base) $ cat meta.yaml 
package:
  name: pkg
requirements:
  build:
    - bzip2
  host:
    - unzip
(base) $ conda render .
package:
    name: pkg
requirements:
    build:
        - libgcc-ng 7.2.0 hdf63c60_3
        - bzip2 1.0.6 h9a117a8_4
    host:
        - libgcc-ng 7.2.0 hdf63c60_3
        - unzip 6.0 h611a1e1_0
extra:
    copy_test_source_files: true
    final: true

Expected behavior: No run: ['bzip2 >=1.0.6,<2.0a0'] in both cases.

Output of conda info
     active environment : base
    active env location : /opt/conda
            shell level : 1
       user config file : /root/.condarc
 populated config files : 
          conda version : 4.5.4
    conda-build version : 3.10.2
         python version : 3.6.5.final.0
       base environment : /opt/conda  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/linux-64
                          https://repo.anaconda.com/pkgs/pro/noarch
          package cache : /opt/conda/pkgs
                          /root/.conda/pkgs
       envs directories : /opt/conda/envs
                          /root/.conda/envs
               platform : linux-64
             user-agent : conda/4.5.4 requests/2.18.4 CPython/3.6.5 Linux/4.14.39-1-MANJARO debian/9 glibc/2.24
                UID:GID : 0:0
             netrc file : None
           offline mode : False
@msarahan
Copy link
Contributor

I think #2882 should fix this. Can you try it?

@mbargull
Copy link
Member Author

Same result with latest master:

(base) $ conda-build --version                                                                                                                                                                                                                                                   
conda-build 3.10.2+8.g44821450
(base) $ cat meta.yaml                                                                                                                                                                                                                                                           
package:
  name: pkg
requirements:
  build:
    - bzip2
  host:
(base) $ conda-render .                                                                                                                                                                                                                                                          
package:
    name: pkg
requirements:
    build:
        - libgcc-ng 7.2.0 hdf63c60_3
        - bzip2 1.0.6 h9a117a8_4
    run:
        - bzip2 >=1.0.6,<2.0a0
extra:
    copy_test_source_files: true
    final: true

(base) $ echo '    - unzip' >> meta.yaml                                                                                                                                                                                                                                         
(base) $ cat meta.yaml                                                                                                                                                                                                                                                           
package:
  name: pkg
requirements:
  build:
    - bzip2
  host:
    - unzip
(base) $ conda render .                                                                                                                                                                                                                                                          
package:
    name: pkg
requirements:
    build:
        - libgcc-ng 7.2.0 hdf63c60_3
        - bzip2 1.0.6 h9a117a8_4
    host:
        - libgcc-ng 7.2.0 hdf63c60_3
        - unzip 6.0 h611a1e1_0
extra:
    copy_test_source_files: true
    final: true

@msarahan
Copy link
Contributor

OK, thanks. I'll take another look.

@msarahan
Copy link
Contributor

Sorry, this is not going to be fixed. Empty keys are stripped from recipes. I can't keep an empty host section. If you need to specify that the build and host envs should not be merged, and you're not using the new {{compiler()}} functions, you should use the (currently undocumented) build/merge_build_host key in meta.yaml.

@mbargull
Copy link
Member Author

Sorry, this is not going to be fixed. Empty keys are stripped from recipes. I can't keep an empty host section.

Hm... Not the answer I was hoping for.


But regardless of that decision, I'll have to ask you to reopen the issue (or open another one) since build/merge_build_host doesn't seem to work for the False case:

(base) $ cat > meta.yaml <<'EOF'
> package:
>   name: pkg
> build:
>   merge_build_host: False
> requirements:
>   build:
>     - bzip2
>   host:
> EOF
(base) $ conda-build --version
conda-build 3.10.2
(base) $ conda-render .
package:
    name: pkg
build:
    merge_build_host: 'False'
requirements:
    build:
        - libgcc-ng 7.2.0 hdf63c60_3
        - bzip2 1.0.6 h9a117a8_4
    run:
        - bzip2 >=1.0.6,<2.0a0
extra:
    copy_test_source_files: true
    final: true

(base) $ cat > meta.yaml <<'EOF'
package:
  name: pkg
build:
  merge_build_host: False
requirements:
  build:
    - bzip2
  host:
EOF
(base) $ conda-build --version
conda-build 3.10.2+15.g7d407c5f
(base) $ conda-render .
--------------
Hash contents:
--------------
{}
----------
meta.yaml:
----------
package:
    name: pkg
build:
    merge_build_host: 'False'
requirements:
    build:
        - libgcc-ng 7.2.0 hdf63c60_3
        - bzip2 1.0.6 h9a117a8_4
    run:
        - bzip2 >=1.0.6,<2.0a0
extra:
    copy_test_source_files: true
    final: true

Given that its value is being rendered as 'False', I assume it's not parsed correctly.
(I even tried merge_build_host: '' to get another "falsy" value, but that one got completely stripped from the output, too.)

@msarahan
Copy link
Contributor

It is parsed correctly, it's a bug elsewhere. The build section is still being treated as the host section (this is why you're getting the run_exports). I think you might need to use

build:
  ignore_run_exports:
    - bzip2

The problem is that your use case runs head-long into the use case of maintaining backwards compatibility with old recipes that have not yet split build and host. I might be able to add more checks for merge_build_host, but I'd also really like to understand why this edge case is necessary.

@mbargull
Copy link
Member Author

but I'd also really like to understand why this edge case is necessary.

It offers consistency in the build process (e.g., always having those two envs active, weak run_exports not from build) and also consistency in the recipes. That way we can tell the users, for non-legacy recipes, to always use/add requirements/host instead of requirements/build and use build really ever only for compilers/build tools and get consistent behavior if they add host unconditionally.


I really appreciate that you added that change in gh-2896!
I think the changes to discern empty from non-existent values are very helpful going forward -- though I feel a bit sorry it was my request that made you make those profound changes, i.e., caused extended work :-O . But again, really appreciated! 👍

@github-actions
Copy link

Hi there, thank you for your contribution!

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

Please open a new issue if needed.

Thanks!

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Mar 17, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 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 a pull request may close this issue.

2 participants