Closed louisreg closed 2 years ago
I'll have to think how to implement that. On Linux, as opposed to Windows, there is no established mechanism to discover Comsol installations in custom locations. But we could maybe make it a config option. I think that's better than adding yet another optional argument to mph.start
and mph.Client
and mph.Server
. Another way would be via an environment variable.
Out of curiosity, you can't even create a symlink in /usr/local
on that Linux server?
(By the way, the library name is just "MPh". I went with "MPh-py" for the "organization", but only because the GitHub user name "MPh" was already taken.)
Just to summarize the current implementation…The search on Linux considers all folders in /usr/local/
named comsol*
which have a sub-folder named multiphysics
. It then queries comsol server --version
inside each folder to get the version of that installation. The reason we don't use the standard which
command is that we want to find all installations, so that users may select one in Python code (which can be useful to run tests or benchmarks with the same model across different Comsol versions).
Hi, Thanks for the response/explanations! A config option would be perfect for us! we could maybe create that symlink on the server we are currently using but we are planning to deploy our code on supercomputer were we have a very restricted access. Also, comsol is named comsol-xxx on the server for various reason, which is not helping the search I assume. Louis
Adding a config option would require rewriting quite a bit of code, as I've just noticed. Because I'd then have to support this on all platforms. Or rather, I should. But it's not needed on Windows, and probably of little use on macOS. It would also require quite a bit of documentation, as I'd have to explain a number of things so that users know how to use the option. I'd rather keep things simple if that's possible, especially in the documentation.
If this is a permission problem, we could also just search ~/.local/
on Linux, in addition to /usr/local
. Then you could create the symbolic link there, in the user's home directory, without sudo
. (Even from Python, if need be.) That folder should already exist, at least it does on Ubuntu and Manjaro. This is much easier to implement and I'd just have to add something like this at the end of the Installation chapter:
If, on Linux, you do have a Comsol installation in a custom location, create a symbolic link in
~/.local
that points to that Comsol folder and give the link a name that starts withcomsol
.
I think this is quite simple and very flexible. For example, the names of the actual Comsol folders wouldn't matter at all. Would that work for you?
Faced similar problem. Since "search_Linux()" method looking for over 'usr/local' folders it was not able to found my comsol folder at the cluster (/opt/software/comsol/comsol55/*). But after replacing in line 208 "/usr/local" for "/opt/software/comsol" it start works. Would be wonderful to create variable for this.
Again, what's wrong with symbolic links?
Symbolic links are commonly used on Linux to resolve issues just like this. For example, python
and python3
are symbolic links that point to the default Python executable. Or, on Ubuntu, /usr/local/man
points to /usr/local/share/man
, the folder that actually has all the man-pages in it.
Symbolic links would work the same on macOS, for the rare macOS user that would even consider putting Comsol in a custom location. And we don't need a solution for Windows as it's a non-issue there. So I think this should be solved the Linux way on Linux, instead of adding unnecessary complexity to library code.
Hi John,
Sorry for the late reply.
Thanks for the suggestion. I can't create symlink to /usr/local
but ~/.local/
would work for me. I just replaced
folders = [item for item in Path('/usr/local').iterdir()
with folders = [item for item in Path(os.path.expanduser('~')+'/.local/').iterdir()
and now it's working just fine. Many thanks
Louis
Okay, I'll publish a new release to support that then. We can just have it search both folders.
Added in version 1.1.1, released today.
Discussed in https://github.com/MPh-py/MPh/discussions/61