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

Add CLI arg to make virtualenvs not autogenerate if needed #16935

Merged
merged 11 commits into from
Sep 24, 2024

Conversation

AbrilRBS
Copy link
Member

@AbrilRBS AbrilRBS commented Sep 4, 2024

Changelog: Feature: Add --envs-generation={false} to conan install and conan build to disable the generation of virtualenvs (conanbuildenv.sh|bat and conanrunenv.sh|bat).
Docs: conan-io/docs#3855

env = VirtualRunEnv(conanfile)
env.generate()
if envs_generation is None:
envs_generation = "auto"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this line. This might simplify chekcing when we add a new not_empty function, but maybe for now it's cleaner to have the following check also check for none instead?

I have allowed for auto to be the same as the default None so that it shows up nicely in the command help

  --envs-generation {auto,never}
                        Generation strategy for virtual environment files for the root

And it being None by default would be the same as typing "auto", as mentioned in #16935 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not very clear why a --envs-generatior=auto that is equal to doing nothing is needed, maybe the auto value can be dropped?

@AbrilRBS AbrilRBS marked this pull request as ready for review September 5, 2024 11:24
Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great, just minor question.

env = VirtualRunEnv(conanfile)
env.generate()
if envs_generation is None:
envs_generation = "auto"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not very clear why a --envs-generatior=auto that is equal to doing nothing is needed, maybe the auto value can be dropped?

Copy link
Member Author

@AbrilRBS AbrilRBS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current issue in Windows(im able to reproduce) comes because when virtualrunenv = True in the conanfile, and the CLI is None, for some reason I'm seeing Generated aggregated env files: ['conanbuild.bat', 'conanrun.sh'] instead of .bat. Trying to investigate why

conan/cli/commands/build.py Outdated Show resolved Hide resolved
with chdir(new_gen_folder):
from conan.tools.env import VirtualRunEnv
env = VirtualRunEnv(conanfile)
env.generate()

_generate_aggregated_env(conanfile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one scenario that this will still produce env-files: if the build system is for example msvc+ninja, the conanvcvars to activate the Visual prompt will be there, and conanbuild.bat will be generated. is this expected? It is true that in certain conditions like using VSCode, the IDE can also manage vcvars, so this might be included in the if envs_generation is None?

@memsharded memsharded self-assigned this Sep 19, 2024
@memsharded memsharded merged commit a9062ec into conan-io:develop2 Sep 24, 2024
2 checks passed
@memsharded memsharded added this to the 2.8.0 milestone Sep 24, 2024
@AbrilRBS AbrilRBS deleted the ar/deactivate-virtualenvs-cli branch September 26, 2024 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants