tilde and rez-env interactive shell on windows

523 views
Skip to first unread message

Fabio Piparo

unread,
May 25, 2015, 4:06:37 PM5/25/15
to rez-c...@googlegroups.com
I've found a few issues with using rez on windows:
cmd.exe doesn't interpret the tilde character ('~') to be the value of the user home directory. I initially chased this around by patching everywhere with expanduser, but eventually I realized that I just needed to take care of the default paths defined in rezconfig.py and everything worked.


Second, rez-env doesn't seem to be interactive. I'm used to how "rez-env somepackage" puts you in a interactive shell, but on windows it doesn't seem to be interactive as it exits out right away.
To get the same behavior I created an empty .bat file (somefile.bat), and as long as is in the %PATH% of the  package I could do "rez-env somepackage -- somefile" to stay in the shell.


Mark Streatfield

unread,
May 25, 2015, 6:37:24 PM5/25/15
to rez-c...@googlegroups.com
Hi Fabio.

When I looked at getting rez to work on Windows I found problems with the behaviour of os.path.expanduser as it is implemented on Windows and how that worked with the configuration system in rez (where weak package references are also denoted with a ~).  This code should be doing the expansion https://github.com/nerdvegas/rez/blob/resources2/src/rez/config.py#L624 using a function defined here https://github.com/nerdvegas/rez/blob/resources2/src/rez/utils/formatting.py#L429.  I think it would be preferable to investigate why that sisn't working as expected rather than adding the os.path.expanduser calls.

I am unable to replicate the problem with rez-env.  A call to rez env puts me in a sub shell that remains interactive with the environment correctly set (including prompt) for the rez session.  Are you calling rez from a cmd shell?  I didn't test any integration with cygwin or git bash on windows.

Mark.

--
You received this message because you are subscribed to the Google Groups "rez-config" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rez-config+...@googlegroups.com.
To post to this group, send email to rez-c...@googlegroups.com.
Visit this group at http://groups.google.com/group/rez-config.
For more options, visit https://groups.google.com/d/optout.

Fabio Piparo

unread,
May 26, 2015, 5:29:52 PM5/26/15
to rez-c...@googlegroups.com
Here are the steps right after a fresh install (python setup.py install):

C:\>echo %PYTHONPATH%
%PYTHONPATH%
C:\>echo %PATH%
C:\windows\system32;C:\windows;C:\Python27;C:\Python27\Scripts;
C
:\>rez-bind
'rez-bind' is not recognized as an internal or external command,
operable program
or batch file.
C
:\>python C:\Python27\Scripts\rez-bind cmake --exe "C:\CMake\bin\cmake.exe"
rez
: PackageRepositoryError: Lockfile directory C:\~\packages does not exist - please create and try again


Then I added expanduser.
C:\>python C:\Python27\Scripts\rez-bind cmake --exe "C:\CMake\bin\cmake.exe"
...
WindowsError: [Error 1314] A required privilege is not held by the client.

..switched to an administrator shell..
C:\windows\system32>python C:\Python27\Scripts\rez-bind cmake --exe "C:\CMake\bin\cmake.exe"
created
package 'cmake-3.2.0' in C:\Users\holofermes/packages

C
:\>python C:\Python27\Scripts\rez-search cmake
cmake
-3.2.0
C
:\>python C:\Python27\Scripts\rez-env cmake

C:\>python C:\Python27\Scripts\rez-env cmake -- cmake --version
cmake version
3.2.0-rc2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

So, I have a few issues. Regarding the tilde, I didn't notice you already worked out some logic for that, and I will take a look at why is not going through the right stack of calls.
For rez-env, it can load the environment, and it works correctly, but it doesn't stay in an interactive shell, and although I initially tried on gitbash, I now moved to cmd but the results are the same. When I switched I also noticed that unlike in gitbash, the command 'rez-env' alone wouldn't work, so I had to pass 'python c:/path/to/rez/rez-env'.
How are you sourcing rez-stuff from cmd?


Fabio Piparo

unread,
May 27, 2015, 7:51:03 PM5/27/15
to rez-c...@googlegroups.com
The problem with the tilde has to do with how on windows os.path.sep is the backward slash, and rez default packages paths use the linux forward slash, and at this point it exits out.
Do you think it's reasonable to check for unix paths at this point as well?

i = path.find(os.path.sep, 1)
if i < 0:
    i = len(path)
if i != 1:
    i = path.find(posixpath.sep, 1)
    if i < 0:
        i = len(path)
    if i != 1:
        return path
On Monday, May 25, 2015 at 11:37:24 PM UTC+1, Mark Streatfield wrote:
Hi Fabio.
When I looked at getting rez to work on Windows I found problems with the behaviour of os.path.expanduser as it is implemented on Windows and how that worked with the configuration system in rez (where weak package references are also denoted with a ~).  This code should be doing the expansion https://github.com/nerdvegas/rez/blob/resources2/src/rez/config.py#L624 using a function defined here https://github.com/nerdvegas/rez/blob/resources2/src/rez/utils/formatting.py#L429.  I think it would be preferable to investigate why that sisn't working as expected rather than adding the os.path.expanduser calls.
I am unable to replicate the problem with rez-env.  A call to rez env puts me in a sub shell that remains interactive with the environment correctly set (including prompt) for the rez session.  Are you calling rez from a cmd shell?  I didn't test any integration with cygwin or git bash on windows.
Mark.
On 26 May 2015 at 06:06, Fabio Piparo <holof...@gmail.com> wrote:
I've found a few issues with using rez on windows:
cmd.exe doesn't interpret the tilde character ('~') to be the value of the user home directory. I initially chased this around by patching everywhere with expanduser, but eventually I realized that I just needed to take care of the default paths defined in rezconfig.py and everything worked.


Second, rez-env doesn't seem to be interactive. I'm used to how "rez-env somepackage" puts you in a interactive shell, but on windows it doesn't seem to be interactive as it exits out right away.
To get the same behavior I created an empty .bat file (somefile.bat), and as long as is in the %PATH% of the  package I could do "rez-env somepackage -- somefile" to stay in the shell.


-- 
You received this message because you are subscribed to the Google Groups "rez-config" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rez-config+...@googlegroups.com.
To post to this group, send email to rez-c...@googlegroups.com.
Visit this group at http://groups.google.com/group/rez-config.
For more options, visit https://groups.google.com/d/optout.

Mark Streatfield

unread,
Jul 6, 2015, 12:24:41 AM7/6/15
to rez-c...@googlegroups.com
Hi Fabio,

Sorry, I lost this email thread.

Do you think it's reasonable to check for unix paths at this point as well?

I guess so, especially as Windows does seem happy with / or \.  That said, I think rezconfig.py needs updating.  In our configuration I've added branches based on the platform, so:

if os.name == "nt":
    local_packages_path = "~\packages"
else:
    local_packages_path = "~/packages"

(In some cases, mainly release_packages_path there is a greater difference in the path values).  Or you could construct it using os.sep directly in rezconfig.py.  Then you wouldn't need to modify the expanduser code.

Regarding the other issue - the non-interactive shell - have you added rez to %PATH% before you start rez-env?  I can't see that in your steps above (or maybe I missed it) but that's the only difference I can see.  I'll try and replicate your steps a bit more this week if I have time.

I didn't look at getting rez-bind to work.  Mainly because we don't use it.  However iirc there is a problem in the way rez-bind dynamically writes some scripts (I think it's assuming #! works on Windows, which I don't think it does).  I'll try and look a bit more and get back to you.

Again, sorry for the late reply.

Mark.

Fabio Piparo

unread,
Oct 18, 2015, 10:55:43 PM10/18/15
to rez-config
Hey Mark,

Now It's my turn to be late

I picked up from where we left and started a new branch. Regarding this post, I don't have any more problems with the tilde, as long as fomatting.py has the posixpath check. However I still have problems with running any of the rez-* family of executable. The only way I can get them to work is if I add a .bat next to them. I'm not sure if maybe my version of windows 8 home edition just doesn't run files without extension? The bat files are all the same, and it's actually more or less a copy of the SCons.bat.
Part of the latest commit, there is a rez-bind msvc which will setup msvc for any version installed on the target machine, and naively inject the result of sourcing vcvarsall.bat into the msvc context. With that, I can run rez-build (and provided the cmake files have windows steps) it just works :)

Mark Streatfield

unread,
Nov 17, 2015, 6:12:48 PM11/17/15
to rez-config
Hi Fabio,

I just updated another thread where this came up, but essentially this is what we do:

When I install rez on windows, the executables in the Scripts/rez folder are all .exe files. .exe is then set as part of the list in the PATHEXT variable. I also then make sure that Scripts/rez (and not the Scripts folder) is in PATH. I believe this combination is what allows us to run the executables without .bat files.

That's all I can see that we are doing - nothing else special happening.

Mark.

Fabio Piparo

unread,
Nov 18, 2015, 12:23:51 AM11/18/15
to rez-c...@googlegroups.com
Replied back. Thx for following up.
(and for posterity:
When I first run into this issue back I installed rez in with "python setup.py install" and it didn't create .exe files, only when rez is installed with "python ./install.py -v DEST_DIR" they are executed. Despite that both way works just fine, no need for bats!
)

--
You received this message because you are subscribed to a topic in the Google Groups "rez-config" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rez-config/HdlAQWQ9bEA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rez-config+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages