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

[bug] conanbuild.sh should be produced whether or not there are environment variables #11352

Closed
datalogics-kam opened this issue May 27, 2022 · 4 comments · Fixed by #11536
Closed

Comments

@datalogics-kam
Copy link

Environment Details (include every applicable attribute)

  • Operating System+version: macOS 12.4
  • Compiler+version: apple-clang 13.0, but doesn't matter
  • Conan version: 1.48.1
  • Python version: 3.9.5

Steps to reproduce (Include if Applicable)

Given a conanfile.txt:

[generators]
VirtualBuildEnv

...and profile-without-buildenv:

include(default)

... and I install it:

$ conan install . -if without-buildenv -pr:h profile-without-buildenv -pr:b profile-without-buildenv

I expect that there will be a conanbuild.sh in the install folder.

You may argue that there are no environment variables, so conanbuild.sh is irrelevant. I would counter that the file should always be produced, so that a surrounding build script can activate the environment without having to test whether the file is there or not. This could happen using different profiles on different machines, for instance.

If conanbuild.sh is always there, a script can unconditionally do something like this to activate the environment and, say, run CMake:

$ source without-buildenv/conanbuild.sh && cmake ...

Even using the tools.env.virtualenv:auto_use config variable doesn't force the existance of conanbuild.sh:

$ conan install . -if without-buildenv -pr:h profile-without-buildenv -pr:b profile-without-buildenv --conf tools.env.virtualenv:auto_use=True

If the profile has a variable in buildenv, it works, of course. profile-with-buildenv:

include(default)
[buildenv]
SPAM=eggs

Logs (Executed commands with output) (Include/Attach if Applicable)

Failure case:

$ conan install . -if without-buildenv -pr:h profile-without-buildenv -pr:b profile-without-buildenv --conf tools.env.virtualenv:auto_use=True
Configuration (profile_host):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=13.0
os=Macos
os_build=Macos
[options]
[build_requires]
[env]
[conf]
tools.env.virtualenv:auto_use=True

Configuration (profile_build):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=13.0
os=Macos
os_build=Macos
[options]
[build_requires]
[env]

conanfile.txt: Installing package
Requirements
Packages

Installing (downloading, building) binaries...
conanfile.txt: Generator 'VirtualBuildEnv' calling 'generate()'
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: Aggregating env generators
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo
$ ls without-buildenv
conan.lock         conanbuildinfo.txt conaninfo.txt      graph_info.json

Success case:

$ conan install . -if with-buildenv -pr:h profile-with-buildenv -pr:b profile-with-buildenv
Configuration (profile_host):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=13.0
os=Macos
os_build=Macos
[options]
[build_requires]
[env]
[buildenv]
SPAM=eggs

Configuration (profile_build):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=13.0
os=Macos
os_build=Macos
[options]
[build_requires]
[env]
[buildenv]
SPAM=eggs

conanfile.txt: Installing package
Requirements
Packages

Installing (downloading, building) binaries...
conanfile.txt: Generator 'VirtualBuildEnv' calling 'generate()'
conanfile.txt: Generator txt created conanbuildinfo.txt
conanfile.txt: Aggregating env generators
conanfile.txt: Generated conaninfo.txt
conanfile.txt: Generated graphinfo
$ tree with-buildenv
with-buildenv
├── conan.lock
├── conanbuild.sh
├── conanbuildenv-release-x86_64.sh
├── conanbuildinfo.txt
├── conaninfo.txt
├── deactivate_conanbuild.sh
└── graph_info.json

0 directories, 7 files
@datalogics-kam
Copy link
Author

datalogics-kam commented May 27, 2022

The source of this bug is a new project at Datalogics where we are really trying to be Conan 2.0 compatible:

  • Only import from conan, not conans
  • Use conan.tools.cmake and conan.tools.env.
  • conan install is the last contact Conan when initiating a build.
  • Run source dir/dir/conanbuild.sh && cmake -DCONAN_TOOLCHAIN_FILE=... and source dir/dir/conanbuild.sh && cmake --build ... instead of using conan build during development.

@memsharded
Copy link
Member

Hi @datalogics-kam

So far this has been indeed a feature: Trying to be minimalistic on the user side. If a user does conan install ... and there is no special environment to activate, generating the file for them would pollute a bit more than necessary their folders, and what is worse, it would create the user the feeling that they need to activate that environment, because there might be something there that they need. Introducing more steps in their flow, which we know cause them some annoyance.

So, to be honest, I also understand your point, so I am not sure what would be the best default, if generating them always by default or not. Will ask for further feedback in the team too.

@memsharded
Copy link
Member

Lets give it a try in #11536

@memsharded
Copy link
Member

#11536 merged, this will be part of 1.50, thanks for the feedback @datalogics-kam !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants