-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
fix lookup and automatic installation of fortls on Windows #772
base: main
Are you sure you want to change the base?
Conversation
pip installs fortls in the %appdata%\Roaming\Python\Python311\Scripts\ folder, which is typically not in PATH, so the extension wouldn't find fortls after installing it. Now it also looks for fortls in this folder. Other changes: - The user configured path to fortls must now be absolute. This simplified a lot of things and it doesn't make sense to me to have multiple versions of fortls on the system, per workspace. Please let me know if this is not OK. - The fortls.disabled config value now gets stored in the USER settings instead of workspace. Similar reasons as above, it seems easier to find.
fixes pre-commit hook failing with the following message: ``` npm run format: [error] No files matching the pattern were found: "'src/**/*.{ts,json}'". [error] No files matching the pattern were found: "'test/**/*.ts'". [error] No files matching the pattern were found: "'syntaxes/**/*.json'". [error] No files matching the pattern were found: "'snippets/**/*.json'". [error] No files matching the pattern were found: "'./**/*.{md,json,yaml,yml}'". ```
This is the right way of installing packages and inheriting variables from the default terminal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @michaelkonecny for the interest in contributing but I think this is not as straight forward as it looks. We have to think about it a bit before we spring to action. Also, please try and do one feature change per PR. As it is there is a lot of work to review for what should be a minor fix.
I would we scrape this PR and address one issue at a time.
- The user configured path to fortls must now be absolute.
This simplified a lot of things and it doesn't make sense to me to
have multiple versions of fortls on the system, per workspace.
Please let me know if this is not OK.
We cannot force people to use absolute paths. A lot of people work with workspace local virtual environments, some companies use weird project configurations that require them to use relative paths or it's more convenient for them to use relative paths.
- The fortls.disabled config value now gets stored in the USER settings
instead of workspace. Similar reasons as above, it seems easier to
find.
I like this idea but there is a reason why I chose not implement it this way. It was for the people that truly wanted an editor for Fortran without any bells and whistles. I suspect that it might be time to re-evaluate this or offer the option to do both.
On another note, I think the proposed solution for spawning fortls will break in some edge cases because of the asynchronicity in the initialiser. The other part is that by moving the this.path
into the activation function removes the ability of users being able to change the path to fortls without restarting vsocde. There is a reason why the fortls initialisation is written that way.
In the client.ts
there are a lot of changes that are not clear to me why they are necessary and what they are addressing. This seems more like a code refactoring which should not be part of this PR.
- A check for python presence is performed before running pip.
Not sure if this is worth it. Almost any OS or Fortran development environment comes with Python (Linux, FreeBSD, MacOS, WSL, MinGW, Cygwin, Intel OneAPI). If the user doesn't have Python in their system and reachable, it is a safe bet that they will also have troubles compiling any code. The way that we plan to guide new users through the installation bit is via Walkthroughs, which I have yet to write see #472
- On Windows, python is used instead of python3 as this is the standard command name on the platform.
This is also incorrect (which I just learned myself), it should be py
not python
, see https://packaging.python.org/en/latest/tutorials/installing-packages/#installing-from-pypi (Windows option). I have no idea why Windows has these nuances, but I guess we will have to work around it.
Added --end-of-line auto argument to prettier to keep me sane.
(Otherwise prettier would convert everything to LF, which results in hundreds of modified files in git, because git checks out files with CRLF by default on Windows. They're still commited with LF, don't worry.).
I don't think I understand what the issue is. All files should be formatted and committed with LF
in all OSs. Does prettier
format something that it shouldn't on Windows hence the large diffs? Setting this to auto
can lead to mixed line endings which we can't permit. Using WSL is the safest solution IMO. BTW VS Code should be able to account for LF or CRLF on any OS.
The greater question with this PR I guess is how do people configure their Python environments on Windows? How do they reach binaries installed via pip? On Linux and MacOS the user install location for pip is not in the PATH either. There is just the assumption, potentially erroneously, that the user has done some minimal setup for their development environment. It might be worth doing a try-except if binary X is not found in default vscode settings try the "default" pip location first, which might be outside of PATH.
Thanks for a quick review!
Understood. I will fix this.
I'm not sure you understood what I meant. The extension still allows all settings to be set in both user and the workspace settings.
I'm new to the async await concept (this was my first time doing anything in TypeScript), but I thought I thought about it sufficiently. I will look into it again, though, to be sure.
Understood. Will fix this.
The refactoring made sense for the changes I made. But I guess there's no point going into detail now, before I make the changes you requested...
I would argue so. Also, expecting Python to be installed alongside a Fortran compiler is not such a safe bet as you say it is, in my opinion. Intel OneAPI does come with their distribution of Python, but nothing forces you to install it. You don't need it to compile Fortran code. I've compiled several open-source libraries (arpack being one of them, off the top of my head) without needing Python. Also, if we keep the Python check, it could be improved by also checking the python version, as fortls only supports >= 3.7 (however this is probably not critical...).
I'm sure a bad enough reason exists. OK, will fix this to
Don't worry, everything still gets commited with LF. Another option would be to configure git to "checkout LF, convert CRLF to LF, commit LF" (this can be done per repo), but I would strongly recommend we stick to the default behaviour, otherwise things get messy (i.e. when copying stuff between projects with different settings)...
As I said, I think the ideal scenario is that the extension installs fortls itself using Looking forward for your thoughts. |
Hey there, gnikit,
-- personal message ;) --
first off, let me say what a tremendous job you have done with fortls!
The extension is leaps ahead from what it was two years ago. I only managed to update a couple of months ago after you posted to Discourse and I was amazed.
-- end personal message --
I hopefully made the extension a bit more usable on Windows, where pip installs fortls in the
%appdata%\Roaming\Python\Python311\Scripts\
folder, which is typically not in PATH, so the extension wouldn't find fortls after installing it.So the only way to use it would be to enter the path to the above folder to the config or to install fortls with admin privileges.
In any case, automatic installation by the extension or updates weren't possible.
Now the extension also looks for fortls in this folder, so all of that is gone.
Other changes:
This simplified a lot of things and it doesn't make sense to me to
have multiple versions of fortls on the system, per workspace.
Please let me know if this is not OK.
instead of workspace. Similar reasons as above, it seems easier to
find.
python
is used instead ofpython3
as this is the standard command name on the platform.(Otherwise prettier would convert everything to LF, which results in hundreds of modified files in git, because git checks out files with CRLF by default on Windows. They're still commited with LF, don't worry.).