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

Add a Distribution.editable property #510

Open
FFY00 opened this issue Jan 26, 2025 · 0 comments
Open

Add a Distribution.editable property #510

FFY00 opened this issue Jan 26, 2025 · 0 comments
Labels
enhancement New feature or request feature

Comments

@FFY00
Copy link
Member

FFY00 commented Jan 26, 2025

Recently, when trying to check if a distribution is editable, I noticed doing so using the current API is very un-ergonomic. This information is available via the direct_url.json file of PEP 610, which is exposed in Distribution.origin.

When url refers to a local directory, the dir_info key MUST be present as a dictionary with the following key:

editable (type: boolean): true if the distribution was installed in editable mode, false otherwise. If absent, default to false.

So, to check if the distribution is editable, we can check Distribution.origin.dir_info.editable, however, Distribution.origin might be None (no direct_url.json), and Distribution.origin.dir_info might not be set (url in direct_url.json in not a local directory), which.

is_editable = distribution.origin and distribution.origin.dir_info and distribution.origin.dir_info.editable
try:
    is_editable = distribution.origin.dir_info.editable
except AttributeError:
    is_editable = False

It would be helpful to have this information available via a more ergonomic API.

@FFY00 FFY00 changed the title Add default values to Distribution.editable property Add a Distribution.editable property Jan 26, 2025
@FFY00 FFY00 added enhancement New feature or request feature labels Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature
Projects
None yet
Development

No branches or pull requests

1 participant