Skip to content

Commit

Permalink
Install venv unless explicitly requested (#169)
Browse files Browse the repository at this point in the history
* Do not prompt for venv install

* spelling and formatting
  • Loading branch information
thomas-bc authored Oct 5, 2023
1 parent 6611fc1 commit 29b6ef7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"project_name": "MyProject",
"install_venv": ["yes", "no"],
"__install_venv": "yes",
"__prompts__": {
"project_name": "Project name",
"install_venv": "Install F´ development tools in current virtual environment?"
"project_name": "Project name"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
sys.exit(1) # sys.exit(1) indicates failure to cookiecutter

# Install venv if requested
if "{{cookiecutter.install_venv}}" == "yes":

if "{{cookiecutter.__install_venv}}" == "yes":
if sys.prefix != sys.base_prefix:
subprocess.run(
[
Expand Down
12 changes: 9 additions & 3 deletions src/fprime/util/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ def add_special_parsers(
action="store_true",
help="Generated files will overwrite existing ones",
)
new_parser.add_argument(
"--prevent-tools-installation",
default=False,
action="store_true",
help="Prevent the installation of the tool suite in the current virtual environment",
)
new_exclusive = new_parser.add_argument_group(
"'new' targets"
).add_mutually_exclusive_group()
Expand All @@ -133,21 +139,21 @@ def add_special_parsers(
default=False,
action="store_true",
dest="new_component",
help="Tells the new command to generate a component",
help="Generate a new component",
)
new_exclusive.add_argument(
"--deployment",
default=False,
action="store_true",
dest="new_deployment",
help="Tells the new command to generate a deployment",
help="Generate a new deployment",
)
new_exclusive.add_argument(
"--project",
default=False,
action="store_true",
dest="new_project",
help="Tells the new command to generate a project",
help="Generate a new project",
)

# Code formatting with clang-format
Expand Down
5 changes: 5 additions & 0 deletions src/fprime/util/cookiecutter_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ def new_project(parsed_args):
source,
overwrite_if_exists=parsed_args.overwrite,
output_dir=parsed_args.path,
extra_context={
"__install_venv": "no"
if parsed_args.prevent_tools_installation
else "yes"
},
)
except OutputDirExistsException as out_directory_error:
print(
Expand Down

0 comments on commit 29b6ef7

Please sign in to comment.