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

Use Huak to manage virtual environments for projects #794

Open
Tracked by #602
cnpryer opened this issue Oct 26, 2023 · 3 comments
Open
Tracked by #602

Use Huak to manage virtual environments for projects #794

cnpryer opened this issue Oct 26, 2023 · 3 comments
Milestone

Comments

@cnpryer
Copy link
Owner

cnpryer commented Oct 26, 2023

Summary

Allow for users to use Huak to manage virtual environments for projects.

Motivation

Currently Huak will resolve a Python environment to use for each command. It does this by searching for a virutal environment to use or by creating a new one. This isn't exposed well to users. Adding features for more control over this process would help make Huak easier to use.

The goal is for Huak to manage things like project virtual environments without having to burden the user, but if the user ever needs to manage their project's virtual environment there should be a way to do it.

Requirements

  • Retain Huak's default Python environment resolution behavior
  • Allow in-project and out-of-project virutal environments
  • Allow for per-project + per-package venvs if needed
  • Allow a future without virtual environments
  • Allow for persisting multiple environments to select from
  • Help make freeing up install command easier (see Use Huak to install tools to a global *toolchain* #850)

Details

At the workspace level a project can be given a virtual environment to use .venv. Per-project users may want to change what virtual environment Huak uses. The python subcommand is meant to be reserved for managing and interacting with Python.

(WIP; see comment)

huak python use <version> # default resolution behavior
huak python use --path <path/to/python>
huak run python -m venv ../somewhere/else/venv
huak python use --path ../somewhere/else/venv
huak python env create --path ../somewhere/else/venv  # If Huak replaces current pip-managed venvs
huak python env create --requirements <requirements-file>
huak python env create --manifest <pyproject.toml/setup.py/etc.>
huak python use <version> <version>  # If Huak supports using more than one environment per-project

Entered to a environments.toml in Huak's home directory:

[scope.python]
"path/to/scope" = "path/to/py-env"
@cnpryer cnpryer mentioned this issue Oct 26, 2023
28 tasks
@cnpryer cnpryer added this to the General-use release milestone Oct 26, 2023
@cnpryer cnpryer changed the title Improved Python environment management Use Huak to manage virtual environments for projects Nov 21, 2023
@cnpryer cnpryer self-assigned this Nov 21, 2023
@cnpryer
Copy link
Owner Author

cnpryer commented Nov 21, 2023

Considering just starting with

#[derive(Subcommand)]
enum PythonEnvironment {
    /// Use a Python environment for the current project.
    Use {
        /// The path to the Python environment.
        #[arg(long)]
        path: Option<PathBuf>,
        /// The path to a project manifest file containing dependencies to install.
        #[arg(long)]
        manifest: Option<PathBuf>,
        /// Requirements files containing PEP 508 requirements to install.
        #[arg(long)]
        requirements: Option<Vec<PathBuf>>,
        /// Force the creation of the Python environment.
        #[arg(short)]
        force: bool,
    },
}

I want there to be clear need for this vs the python use command. python use provides users with a method for using a Python interpreter without regard for what kind of environment it's part of. By default Huak will prepare the selection as part of a Virtual Environment. With python env use you're explicitly interacting with an environment for Python. I'm thinking of features like:

huak py env use --manifest . -f  # Install the dependencies of a project to a Python environment for Huak to use.

Here I'm looking to replace the current huak install command with a subcommand for more options related to interfacing with an environment containing installed dependencies. huak install will be used similar to pipx install.

@cnpryer
Copy link
Owner Author

cnpryer commented Nov 22, 2023

Thought through this some more. Im hesitant to commit time to this right now since the experience I want from Huak is one where you don't even know the virtual environment is there or is being used.

I don't want to open this door until I've thought about it some more.

@cnpryer cnpryer removed their assignment Nov 22, 2023
@cnpryer
Copy link
Owner Author

cnpryer commented Feb 17, 2024

cc #890

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

No branches or pull requests

1 participant