Skip to content

Convert relative to absolute paths in link resolving #3

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

Merged
merged 1 commit into from
Nov 20, 2020

Conversation

bneumann
Copy link
Contributor

Was just checking put the code under linux to see how it works. Didn't find dotnet_root under '../share/dotnet' so I added a little converter.

if os.path.isabs(dotnet_tmp_path):
dotnet_path = dotnet_tmp_path
else:
dotnet_path = os.path.abspath(os.path.join(os.path.dirname(dotnet_path), dotnet_tmp_path))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't simply doing os.path.abspath(os.readlink(dotnet_path)) be enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about that. I'll try it later. Wasn't sure where abspath will base on. So I wanted to be sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I tried that now and it didn't work. Because:

os.path.abspath(path)

Return a normalized absolutized version of the pathname path. On most platforms, this is equivalent to calling the function normpath() as follows: normpath(join(os.getcwd(), path))

So what abspath does is to take the current working directy (where you started the script) and apply normpath(join(os.getcwd(), path)) .

That's why you would need all the fancy if else stuff. So in my case:
dotnet_root was /usr/bin/dotnet which was a symlink to ../share/dotnet/dotnet that was being taken by the abspath and concatenated onto my user directory /home/bneumann/pythonnet/clr-loader/share/dotnet/dotnet

@filmor filmor merged commit 44edf6a into pythonnet:master Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants