-
Notifications
You must be signed in to change notification settings - Fork 337
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 shebang and executable paths in gitbash #1364
Fix shebang and executable paths in gitbash #1364
Conversation
With these options, complex shell implementation can choose to use differently converted paths for different reasons. Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
With these options, complex shell implementation can choose to use differently converted paths for different reasons. Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
With these options, complex shell implementation can choose to use differently converted paths for different reasons. Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
This is for working with non-posix paths. Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Allows for working with Windows drive directories like posix root paths. Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Fixes issues with spaces in names. Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
With these options, complex shell implementation can choose to use differently converted paths for different reasons. Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
a720b69
to
bab60ce
Compare
@amorphousWaste we will be happy to get the fixes for the linter, but I think it would be more appropriate if it was done in a separate PR. |
linting fixes can be placed against this issue. |
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
bab60ce
to
d1b071d
Compare
My apologies. I misunderstood the workflow checks and thought that linting was blocking the PR. It has been removed. |
For visibility please see recent comments: #1302 |
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Add check and key conversion for shell pathed key based on arg Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
848c894
to
8aae074
Compare
@amorphousWaste can you update the PR description please to give us an overview of how all this is used, describe what has been tested, potential gray areas, areas not covered, etc please? That would be greatly appreciated! |
This update to the PR adds the functionality of choosing whether or not to modify paths and shell paths via the |
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
7d6273c
to
2883f73
Compare
Thanks @amorphousWaste for walking us through your PR during the TSC meeting. Here are the points we would like to see be implemented before we can merge this PR:
|
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
Add path conversion info into file. Signed-off-by: amorphousWaste <20346603+amorphousWaste@users.noreply.github.com>
049f1d1
to
6a4edb1
Compare
Hi @amorphousWaste , I see you pushed some new commits to the PR. What's the state of things right now? Can see start reviewing or there is still more work to do before it's ready to review? |
Signed-off-by: Jean-Christophe Morin <38703886+JeanChristopheMorinPerso@users.noreply.github.com>
Just want to write that during the last TSC meeting (january) that @amorphousWaste mentioned that the PR is ready for review and testing by interested parties. @JeanChristopheMorinPerso registered interest in reviewing, and @instinct-vfx registered willingness to try throwing it in front of a few tester individuals in a studio environment, though I imagine that is subject to the whims and priorities of the studio. |
@maxnbk I am actively reviewing this PR. I've been doing for a couple of hours now. I should be done today. |
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 for all your work on this @amorphousWaste! I did a first pass on this. There is some things to fix, but the other things are mostly questions, comments, notes, etc.
Note that I haven't tested it yet.
Apart from that, we requested to add some tests. I see some tests were added, but they are pretty light. The path normalization functions are not well covered, corner cases aren't unit tested, etc. I'd also love to see real integration tests, i.e. have packages that we build, resolve in multiple shells and verify that everything looks like it should work works as expected.
Lastly, it's missing documentation. I believe @jasoncscott volunteered to help on that? I would see a new section of our wiki dedicated to that, with example, explanations, etc.
# as a result of both the shell and the settings in "pathed_env_vars" and | ||
# "shell_pathed_env_vars". This is meant to aid in debugging and should be | ||
# False unless needed. | ||
disable_normalization = False |
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.
I would call it disable_path_normalization
, also it should be set to True so that it's disabled by default.
@@ -261,6 +261,10 @@ def as_path(self, path): | |||
Returns: | |||
(str): Transformed file path. | |||
""" | |||
# Prevent path conversion if normalization is disabled in the config. | |||
if config.disable_normalization: |
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.
Could this be done in the normalize_path
path instead?
converted_path = convert_path(path, 'windows') | ||
if path != converted_path: | ||
print_debug( | ||
'Path converted: {} -> {}'.format(path, converted_path) |
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.
How about Path normalized
? Also, both converted
and changed
are used. I think we should make sure the message is consistent. Lastly, I'd use {!r}
to automatically quote the paths. This usually helps with debugging whitespace issues, etc.
|
||
return path | ||
if path != new_path: | ||
print_debug('Path converted: {} -> {}'.format(path, new_path)) |
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.
Won't this cause duplicate logs? Should the responsibility to log be of the caller or the callee? In general the responsibility is delegated to the caller, but we could say that in this case it's the callee.
|
||
if path != converted_path: | ||
self._addline( | ||
'REM Path converted: {} -> {}'.format( |
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.
Again, converted vs changed.
""" | ||
Git Bash (for Windows) shell | ||
""" | ||
"""Git Bash (for Windows) shell.""" |
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.
Small note: Please avoid unnecessary formatting changes.
|
||
return super(GitBash, self).normalize_paths(value2) | ||
def shebang(self): | ||
self._addline('#! /usr/bin/env bash') |
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.
self._addline('#! /usr/bin/env bash') | |
self._addline('#!/usr/bin/env bash') |
config.override('disable_normalization', True) | ||
|
||
test_path = r'C:\foo\bar\spam' | ||
normalized_path = shell.normalize_path(test_path) |
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.
shell
is a string, which cause the test to fail with
AttributeError: 'str' object has no attribute 'normalize_path' (in shell 'bash')
if shell_name not in config.shell_pathed_env_vars: | ||
return False | ||
|
||
return any( |
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.
This is not covered by any tests
@@ -1359,7 +1422,7 @@ def normalize_path(self, path): | |||
Returns: | |||
str: The normalized path. | |||
""" | |||
return self.interpreter.normalize_path(path) | |||
return self.interpreter.as_path(path) |
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.
This is not covered by any tests. It could be a good occasion to add coverage here.
Hey @amorphousWaste @Jawabiscuit , would one of you be willing and have time to pick this up again? If not, please let us know so that we can see if we can find someone else that might be interested. This PR is important for our community, so we would like to get things moving. |
@JeanChristopheMorinPerso yeah, definitely trying to carve out some time in the near future to revisit this. I'm wrapping up an extended effort for Linux/Windows Deadline rendering, which also incorporates rez. I'm better positioned now to take another look and continue with the converting to rez on Windows effort soon. I've enabled gitbash on Windows for myself at least since the last meeting to verify our experience and it has been stable for me working as a developer. Beginning next week I should be able to get more than just me testing and take a look at the comments on this PR in more detail. I defer to @amorphousWaste on what his plans are, but happy to jump in and take it home if he's preoccupied. |
Great news @Jawabiscuit! Just let us know how we can help and of your plans change. |
If I may put my two cents in, i was able to build zlib library with cmake & msvc like i do on linux with a CMakeLists.txt with this PR. |
def test_path_conversion_mixed(self): | ||
"""Test the path conversion to mixed style.""" | ||
test_path = r'C:\foo\bar\spam' | ||
converted_path = convert_path(test_path, 'unix') |
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.
Isn't this the same test as the previous one? Should it be testing mixed
?
Closing in favor of #1475. |
Fixes #1302.
Originally, I thought "shebang and executable paths incorrect in gitbash" was the cause of issues when working with rez in gitbash/Windows, however after investigation and discussion, there were much deeper issues. This PR addresses issues with pathing by adding multiple options for pathing to the needed shells and executor classes.