Double quotation marks in description in package.py fail in Powershell
Issue
Whenever a description is set in a package.py that contains double quotation marks as in the example below it fails to run correctly in Powershell when also a custom_build is provided and you're trying to run rez build in command line.
A reproducable example for package.py:
name = "quote_marks"
version = "1.0"
description = \
"""
This is a lovely "recipe" for problems.
"""
build_command = "python {root}/rezbuild.py {install}"
build_requires = ['python']
def commands():
pass
With the problematic error being:
Unexpected token 'recipe" package
An example error log for one of such cases is which also required 7zip for its build, but that is unrelated to the issue itself:
rez build
Building into: 'C:\Users\Roy\packages'
--------------------------------------------------------------------------------
Building redshift-2.6.49...
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Building variant 0 (1/1)...
--------------------------------------------------------------------------------
Resolving build environment: platform-windows python 7zip
resolved by Roy@CB1, on Mon Nov 11 14:20:46 2019, using Rez v2.40.3
requested packages:
platform-windows
python
7zip
~platform==windows (implicit)
~arch==AMD64 (implicit)
~os==windows-10 (implicit)
resolved packages:
7zip-19.00 C:\Users\Roy\packages\7zip\19.00\platform-windows\arch-AMD64 (local)
arch-AMD64 C:\Users\Roy\packages\arch\AMD64 (local)
platform-windows C:\Users\Roy\packages\platform\windows (local)
python-3.7.3 C:\Users\Roy\packages\python\3.7.3\platform-windows\arch-AMD64 (local)
Invoking custom build system...
Running build command: python
At C:\users\roy\appdata\local\temp\rez_context_np68fq\context.ps1:12 char:33
+ This is separated into its own "recipe" package
+ ~~~~~~~~~~~~~~~
Unexpected token 'recipe" package
so that the common files can be distributed as
a single platform package. As opposed to having
to copy over *all* binary files each time per
Houdini or Maya variant."' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken
python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At C:\users\roy\appdata\local\temp\rez_context_np68fq\rez-shell.ps1:3 char:1
+ python
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Note that somehow when build_command = False it succeeds running rez build just fine. Or at least it seemed to do so on my end.
Workaround: Replace the "recipe" double quotation marks with 'recipe' single quotation marks and it will succeed.
References:
Thanks for the report, will try to look into this today
Hi, we hit this as well and I don't think this is an issue with quotation.
As shown here: https://ss64.com/ps/call.html
Powershell requires & "command" syntax for any command that is not on the path.
Since our abstraction of shells in rez passes the command to the shell already as single line and re-composing the list from it to check if the first part is a command in a way my suggested patch is way simpler:
In Powershell, if the command does not start with & prepend it.
I believe this should work for all the cases because we would never send PowerShell commands to a rez shell (let's say Test-Path or New-Item) directly.
I can prepare a patch that others might try. For us without this patch cmake under windows will not work.
#417