<div dir="ltr">I can't think about a potential security issue with that as long as you trust your default python interpreter...<div><br></div><div>So to sum up the workaround: </div><div>Saving the following line as c:\Python38\Scripts\gdal_calc.bat (or as the same name as any other x.py script)
<br></div><div><div>@python %~dp0\%~n0.py %*<br></div><div></div></div><div></div><div>and calling gdal_calc (apparently
.bat has higher priority then .py) would work regardless of the py file association. </div><div><br></div><div>For anyone who is not familiar with the quirks of windows batch files:<br></div><div>@ = not to echo the command<br></div><div>python = your default python interpreter</div><div>%~dp0 means the path of the current batch file (i.e. c:\Python38\Scripts)</div><div>%~n0 means the name of the batch file without extension (i.e. gdal_calc)</div><div><br></div><div>So running gdal_calc it would essentially call the following:</div><div>python c:\Python38\Scripts\gdal_calc.py</div><div><br></div><div>Idan</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 25 Feb 2021 at 12:02, Richard Duivenvoorde <<a href="mailto:rdmailings@duif.net">rdmailings@duif.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2/25/21 10:53 AM, Idan Miara wrote:<br>
> Actually, it might be a good idea to use a batch file...<br>
> <br>
> I've created the following batch file named gdal_calc.bat in the scripts folder:<br>
> @python %~dp0\gdal_calc.py %*<br>
> <br>
> Then running gdal_calc works even if *.py is associated with PyCharm.<br>
> Do you think this issue justifies creating this kind of batch files for the scripts to distribute in binary windows wheels ?<br>
<br>
Mmm, /me no windows expert, I don't know. <br>
<br>
But couldn't this be a potential security issue? But I let knowledge to Windows/Python packagers....<br>
<br>
Regards,<br>
<br>
Richard Duivenvoorde<br>
</blockquote></div>