Skip to content

feat: better handling of Python packages and environments #1273

@gnikit

Description

@gnikit

Is there an existing request for this?

  • I have searched the existing issues

I have tried the Pre-Release of the extension.

  • Feature is not present in the latest Pre-Release

Feature Request

The extension uses pip in order to install third party tools like fortls or fprettify. The problem is that certain user setups are not properly configured hence the install location for pip is not in the PATH, hence the initialisation of the tools fails. Another issue is that users often rely on virtualisation venv, conda, etc. in order to install these tools, and they would prefer if the extension used the virtual environment over the user's global env.

The majority of these user pains have solutions and workarounds already in place, i.e. one can specify explicitly the location of fortls or findent. Or one can spin up VS Code from inside the venv/conda environment thus the installation infrastructure of Modern Fortran will be aware of the venv variables.

The Issue here is meant to try and ease some of those pains if possible without over-complicating the extension.

There are multiple ways forward to this problem.

1) pipx

Using pipx to isolate and run these binaries would simplify the process. One would only have to detect/install pipx in the corresponding system. There would be a small performance slow-down given that launching fortls or findent with pipx is noticeably slower.

2) Python Environment Manager

Create a Python Manager class inside the Modern Fortran extension that is aware of installation locations, potential virtualisation. Shares the terminal env variables, etc.

The main problem is the complexity of this solution. This is a Fortran extension that would end up implementing a full Python environment manager (clearly out of scope), for user pains that can already be resolved with the existing settings.

3) Ship binaries with Modern Fortran

Use some tool (there are a few out there) to either ship standalone binaries of the python packages or a lightweight Python virtual environment inside the Modern Fortran vsix.

This would raise some security concerns if done poorly, but I am relatively sure there are well-established solutions out there.

4) Integrate with the ms-python extension

If the extension is available, and if this is techinically possible we could integrate with the Python extension for VS Code and potentially avoid writing a Python Environment Manager completely.

Related Issues are #957, #773, #771

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions