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

Workspace Conda, Poetry, Virtual Envs #22

Closed
karthiknadig opened this issue Jun 6, 2024 · 4 comments
Closed

Workspace Conda, Poetry, Virtual Envs #22

karthiknadig opened this issue Jun 6, 2024 · 4 comments
Assignees
Labels
feature-request Request for new features or functionality
Milestone

Comments

@karthiknadig
Copy link
Member

karthiknadig commented Jun 6, 2024

Note: Ignore hatch for now

@karthiknadig karthiknadig added the feature-request Request for new features or functionality label Jun 6, 2024
@karthiknadig karthiknadig added this to the June 2024 milestone Jun 6, 2024
@DonJayamanne DonJayamanne changed the title Workspace Conda, Poetry, Virtual Envs, Hatch Workspace Conda, Poetry, Virtual Envs Jun 13, 2024
@DonJayamanne
Copy link
Collaborator

Done

@ofek
Copy link

ofek commented Jul 3, 2024

what needs to be done to support Hatch? (I'm the maintainer)

@karthiknadig
Copy link
Member Author

@ofek You can add hatch support here, Don can provide the details. When the extension API for this becomes available, you will likely want to use that as it will allow you to do more than just discovery.

FYI, this is an intermediate bridging tool, with the intent that this will allow us to break out the tightly coupled environment code in the python extension. On the python extension side I will be opening up a set of APIs that allow environment managers to ship support in their own extensions.

For env types supported here like pyenv, poetry, conda, etc, we expect those to be removed (from here) as and when extension for those env managers will ship. The reason we made this tool was to set a baseline expectation for discovery in python extension. So when env managers ship their own extensions there is some benchmark for expected performance. The TS discovery code was outdated and overdue a refresh, hence this re-write.

@DonJayamanne
Copy link
Collaborator

DonJayamanne commented Jul 4, 2024

@ofek
You can have a look at the pet-poetry crate (please ignore the file environment_locations_spawn.rs
I am yet to document the code and API (actually will be working on that today/tomorrow).
The file lib.rs has the implementation for the trait Locator

  • try_from needs to return a PythonEnvironment if it is a hatch environment.
  • find will return all of the known hatch environments.

Next update the crates/pet/src/locators.rs file to add an entry to the hatch locator just above or below the Poetry locator (this line locators.push(Arc::new(Poetry::from(&environment)));.

Bulk of the code in Poetry is used to locate the directory where Poetry environments are located.
I had to get that from the Poetry code, with Hatch you will know very well where they are located, and then for each environment you will need to determine the project it belongs to, thats where the project field needs to be populated.

E.g. for hatch once you find environments, (I think), you will then go through the file ..lib/python3.9/site-packages/_hatch_demo.pth and find the project this belongs to and use that as the value for project field (from what I can tell, i think it needs to be the parent of src folder).

Hope this helps.
Will update the docs with contribution guides this week.

Oh yes, please do not spaw hatch or other processes, the goal of this tool is to avoid spawning and favour file I/O to discover Python environments along with the version/prefix information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

3 participants