Skip to content

Single venv creation is not exposed in the CLI

The venvctl's single virtual environment creation is not implemented in the CLI:

The current implementation: Since the venvctl has a mandatory config_path argument in the constructor, create_venv is exposed as classmethod that returns the class itself and calls its run method.

@classmethod
    def create_venv(cls, name: str,
                    packages: List[str],
                    output_dir: Optional[Path] = None,) -> None:
        """Create a virtual environment."""
        config_file = configutils.generate_config(name, packages)

        cls(config_file=config_file, output_dir=output_dir).run()

The logic behind generates a config file by deserializing a (Venv type)[https://gitlab.com/hyperd/venvctl/-/blob/development/module/main/venv.py], instanciated with a package list and a name. This way the creation process doesn't need to be modified, and even a single venv can benefit of all the reporting and checks.

The method can be called as follows: VenvCtl.create_venv(name=name, packages=packages) where name is a string and packages is a list of strings.