8000 Test that Hatch environments are discovered and activated · Issue #23088 · microsoft/vscode-python · GitHub
[go: up one dir, main page]

Skip to content
Test that Hatch environments are discovered and activated #23088
Closed
@flying-sheep

Description

@flying-sheep

Refs: #22810

Complexity: 4

Authors: @flying-sheep, @karrtikr

Create Issue


  1. Install Hatch
    • using the GUI installers on macOS or windows

    • using your system package manager on Arch Linux or Fedora

    • using pipx install Hatch on other Linux distributions. Please make sure you set your PATH correctly in this case.

      Setting PATH on Linux

      If you cannot install Hatch system-wide, you might need to add $HOME/.local/bin to your PATH environment variable for your graphical session, not just your terminal. Check like this:

      $ pgrep bin/code  # or some other graphical application
      1234
      $ cat /proc/1234/environ | tr '\0' '\n' | grep -E '^PATH='
      PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

      If the the directory is not in there, you need to add it in your session startup script, in a way that depends on your desktop environment:

  2. In an empty VS Code project, add two files:
    1. testproj.py containing
      import session_info
      
      session_info.show()
    2. … and a pyproject.toml specifying dependencies:
      [project]
      name = "testproj"
      version = "0.1.0"
      dependencies = ["session-info"]
      
      [build-system]
      requires = ["hatchling"]
      build-backend = "hatchling.build"
  3. Make Hatch install the project and its dependencies to an environment using hatch run ..., e.g. hatch run python -V (there is no configuration necessary for Hatch to work in a simple case like this)
  4. Select the testproj as an interpreter using Python: Select Interpreter command
    image
  5. Run it using the play icon on top right
    image
  6. The file is successfully run and prints the session info:
    grafik
  7. Open a new terminal: If you have the python.terminal.activateEnvironment setting set to true, the environment should be activated:
    Run pip -V and compare if the path starts with the path displayed by hatch env find (pip’s contains an additional lib/pythonX.YZ/site-packages/pip)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0