babakks / vscode-juju-charmcraft-ide

VS Code extension for Juju Charm development
MIT License
4 stars 1 forks source link

Configure venv #15

Closed dashmage closed 8 months ago

dashmage commented 9 months ago

Hi, thanks for creating this super useful extension!

Is it possible to set up the python virtual environment at .venv instead of venv?

babakks commented 9 months ago

Hey,

I'm glad you found it useful.

Actually, as I remember, venv is the Charmcraft's preferred directory for virtual environment (for example, it's listed in .gitignore).

However, it's totally possible to keep the default behavior as is, but add some configuration parameter that allows overriding the virtual environment directory.

Actually, I had this plan to provide some overrides via configuration, like this (in .vscode/settings.json):

{
    "charmcraft-ide.overrides": {
        "*": {
             // New default for all charms
        },
        "path/to/charm": {
             // Charm-specific overrides
        }
    }
}

When that is implemented, which will be soon, we can also add a parameter to override the default venv directory.

How's that sound?

dashmage commented 9 months ago

An override for the default venv directory would be exactly what I was looking for!

babakks commented 8 months ago

@dashmage I just published the new version of the extension. It now supports some basic configurations and, of course, charm-specific overrides. You can find more details in the README.md (or the extension details page in VS Code).

In your case, if all charms in the workspace should use the same directory name (i.e., .venv) for the virtual environments, you can set it as a default in .vscode/settings.json, like this:

{
    "charmcraft-ide.defaultVirtualEnvDirectory": ".venv"
}

But, if you need to override the directory name just for a specific charm, then you'd need overrides:

{
   "charmcraft-ide.override": {
       "path/to/charm": {
            "virtualEnvDirectory": ".venv"
       }
   }
}

Hope this works for you. Thanks again for your good suggestion. :pray:

I close this issue now. If you found bugs in the new version, please comment here.