public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* python sys.executable inconsistency if called from cmd
@ 2021-02-03 14:35 Lemke, Michael  SF/HZA-ZIC2
  2021-02-03 15:27 ` Andrey Repin
  0 siblings, 1 reply; 5+ messages in thread
From: Lemke, Michael  SF/HZA-ZIC2 @ 2021-02-03 14:35 UTC (permalink / raw)
  To: cygwin

I don't know anything about python but want to use cygwin's
python from nodejs with npm-gyp. The npm-gyp module is trying to
find the python executable path from sys.executable and fails.
While investigating this I found this to me quite inconsistent
behavior:

cygwin> /bin/python3.6m.exe -c 'import sys; print(sys.executable);'
/bin/python3.6m

cygwin> python3.6m -c 'import sys; print(sys.executable);'
/usr/bin/python3.6m

cygwin> python3.6 -c 'import sys; print(sys.executable);'
/usr/bin/python3.6

cygwin> python3.6m.exe -c 'import sys; print(sys.executable);'
/usr/bin/python3.6m


cmd> c:/MyStuff/NCygwin64/bin/python3.6m.exe -c 'import sys; print(sys.executable);'
/usr/bin/python3.6m

cmd> rem add cygwin path to Windows:
cmd> path %PATH%;c:\MYSTUFF\ncygwin64\bin

cmd> python3.6m.exe -c 'import sys; print(sys.executable);'
/c/MYSTUFF/ncygwin64/bin/python3.6m

With CMD I'll never get an executable that actually works from cmd.
Is this expected? Is there a way around to make this work?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: python sys.executable inconsistency if called from cmd
  2021-02-03 14:35 python sys.executable inconsistency if called from cmd Lemke, Michael  SF/HZA-ZIC2
@ 2021-02-03 15:27 ` Andrey Repin
  2021-02-03 16:17   ` Lemke, Michael  SF/HZA-ZIC2
  0 siblings, 1 reply; 5+ messages in thread
From: Andrey Repin @ 2021-02-03 15:27 UTC (permalink / raw)
  To: Lemke, Michael  SF/HZA-ZIC2, cygwin

Greetings, Lemke, Michael  SF/HZA-ZIC2!

> I don't know anything about python but want to use cygwin's
> python from nodejs with npm-gyp. The npm-gyp module is trying to
> find the python executable path from sys.executable and fails.

If that's true, then it should be fixed upstream.

> While investigating this I found this to me quite inconsistent
> behavior:

> cygwin> /bin/python3.6m.exe -c 'import sys; print(sys.executable);'
> /bin/python3.6m

> cygwin> python3.6m -c 'import sys; print(sys.executable);'
> /usr/bin/python3.6m

> cygwin> python3.6 -c 'import sys; print(sys.executable);'
> /usr/bin/python3.6

> cygwin> python3.6m.exe -c 'import sys; print(sys.executable);'
> /usr/bin/python3.6m


> cmd> c:/MyStuff/NCygwin64/bin/python3.6m.exe -c 'import sys; print(sys.executable);'
> /usr/bin/python3.6m

> cmd> rem add cygwin path to Windows:
> cmd> path %PATH%;c:\MYSTUFF\ncygwin64\bin

> cmd> python3.6m.exe -c 'import sys; print(sys.executable);'
> /c/MYSTUFF/ncygwin64/bin/python3.6m

> With CMD I'll never get an executable that actually works from cmd.
> Is this expected?

Yes. This is Cygwin, not Windows CMD.

> Is there a way around to make this work?

Yes, write scripts correctly, correctly translate paths.

See:
> FAQ:                  https://cygwin.com/faq/
> Documentation:        https://cygwin.com/docs.html

Specifically see `man cygpath`.

-- 
With best regards,
Andrey Repin
Wednesday, February 3, 2021 18:25:18

Sorry for my terrible english...


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: python sys.executable inconsistency if called from cmd
  2021-02-03 15:27 ` Andrey Repin
@ 2021-02-03 16:17   ` Lemke, Michael  SF/HZA-ZIC2
  2021-02-03 18:01     ` Marco Atzeri
  2021-02-03 18:55     ` Andrey Repin
  0 siblings, 2 replies; 5+ messages in thread
From: Lemke, Michael  SF/HZA-ZIC2 @ 2021-02-03 16:17 UTC (permalink / raw)
  To: cygwin

On Wednesday, February 3, 2021 4:28 PM Andrey Repin wrote:
>Greetings, Lemke, Michael  SF/HZA-ZIC2!
>
>> I don't know anything about python but want to use cygwin's
>> python from nodejs npm with node-gyp. The node-gyp module is trying to
>> find the python executable path from sys.executable and fails.
>
>If that's true, then it should be fixed upstream.

Good to know but I doubt that they will. For those who need this -
here is a workaround for node-gyp v5.1.0 I just found:

cygwin> mkdir /c/Python37
cygwin> ln `which python3.6m` /c/Python37/python.exe

I aware of the version clash here but c:\Python37 is one of a
few explicit locations this node-gyp looks at. Doesn't seem
confused if the versions don't match. The file you link to 
must be the actual Cygwin executable not any of the python 
links in /bin.

>
>> While investigating this I found this to me quite inconsistent
>> behavior:
>
>> cygwin> /bin/python3.6m.exe -c 'import sys; print(sys.executable);'
>> /bin/python3.6m
>
>> cygwin> python3.6m -c 'import sys; print(sys.executable);'
>> /usr/bin/python3.6m
>
>> cygwin> python3.6 -c 'import sys; print(sys.executable);'
>> /usr/bin/python3.6
>
>> cygwin> python3.6m.exe -c 'import sys; print(sys.executable);'
>> /usr/bin/python3.6m
>
>
>> cmd> c:/MyStuff/NCygwin64/bin/python3.6m.exe -c 'import sys; print(sys.executable);'
>> /usr/bin/python3.6m
>
>> cmd> rem add cygwin path to Windows:
>> cmd> path %PATH%;c:\MYSTUFF\ncygwin64\bin
>
>> cmd> python3.6m.exe -c 'import sys; print(sys.executable);'
>> /c/MYSTUFF/ncygwin64/bin/python3.6m
>
>> With CMD I'll never get an executable that actually works from cmd.
>> Is this expected?
>
>Yes. This is Cygwin, not Windows CMD.

Sure but python seems to start just fine under cmd and it does do
some gyrations with sys.executable dependent on calling environment.
So this looks somewhat fishy to me.

>
>> Is there a way around to make this work?
>
>Yes, write scripts correctly, correctly translate paths.

See above.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: python sys.executable inconsistency if called from cmd
  2021-02-03 16:17   ` Lemke, Michael  SF/HZA-ZIC2
@ 2021-02-03 18:01     ` Marco Atzeri
  2021-02-03 18:55     ` Andrey Repin
  1 sibling, 0 replies; 5+ messages in thread
From: Marco Atzeri @ 2021-02-03 18:01 UTC (permalink / raw)
  To: cygwin

On 03.02.2021 17:17, Lemke, Michael SF/HZA-ZIC2 wrote:
> On Wednesday, February 3, 2021 4:28 PM Andrey Repin wrote:
>> Greetings, Lemke, Michael  SF/HZA-ZIC2!
>>
>>> I don't know anything about python but want to use cygwin's
>>> python from nodejs npm with node-gyp. The node-gyp module is trying to
>>> find the python executable path from sys.executable and fails.
>>
>> If that's true, then it should be fixed upstream.
> 
> Good to know but I doubt that they will. For those who need this -
> here is a workaround for node-gyp v5.1.0 I just found:
> 
> cygwin> mkdir /c/Python37
> cygwin> ln `which python3.6m` /c/Python37/python.exe
> 
> I aware of the version clash here but c:\Python37 is one of a
> few explicit locations this node-gyp looks at. Doesn't seem
> confused if the versions don't match. The file you link to
> must be the actual Cygwin executable not any of the python
> links in /bin.
> 

Hi Michael,

do you know that python3.7 is also available in Cygwin ?
All versions availabe are:

$ ls  /usr/bin/python3* | grep -v config
/usr/bin/python3
/usr/bin/python3.6
/usr/bin/python3.6m.exe
/usr/bin/python3.7
/usr/bin/python3.7m.exe
/usr/bin/python3.8.exe


Where have you installed the node-gyp v5.1.0 and how ?

Regards
Marco


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: python sys.executable inconsistency if called from cmd
  2021-02-03 16:17   ` Lemke, Michael  SF/HZA-ZIC2
  2021-02-03 18:01     ` Marco Atzeri
@ 2021-02-03 18:55     ` Andrey Repin
  1 sibling, 0 replies; 5+ messages in thread
From: Andrey Repin @ 2021-02-03 18:55 UTC (permalink / raw)
  To: Lemke, Michael  SF/HZA-ZIC2, cygwin

Greetings, Lemke, Michael  SF/HZA-ZIC2!

> On Wednesday, February 3, 2021 4:28 PM Andrey Repin wrote:
>>Greetings, Lemke, Michael  SF/HZA-ZIC2!
>>
>>> I don't know anything about python but want to use cygwin's
>>> python from nodejs npm with node-gyp. The node-gyp module is trying to
>>> find the python executable path from sys.executable and fails.
>>
>>If that's true, then it should be fixed upstream.

> Good to know but I doubt that they will. For those who need this -
> here is a workaround for node-gyp v5.1.0 I just found:

Precedently, MS Visual Studio Code comes with a wrapper, that deals with
Cygwin just fine so far.

> cygwin> mkdir /c/Python37
> cygwin> ln `which python3.6m` /c/Python37/python.exe

> I aware of the version clash here but c:\Python37 is one of a
> few explicit locations this node-gyp looks at. Doesn't seem
> confused if the versions don't match. The file you link to 
> must be the actual Cygwin executable not any of the python 
> links in /bin.

>>
>>> While investigating this I found this to me quite inconsistent
>>> behavior:
>>
>>> cygwin> /bin/python3.6m.exe -c 'import sys; print(sys.executable);'
>>> /bin/python3.6m
>>
>>> cygwin> python3.6m -c 'import sys; print(sys.executable);'
>>> /usr/bin/python3.6m
>>
>>> cygwin> python3.6 -c 'import sys; print(sys.executable);'
>>> /usr/bin/python3.6
>>
>>> cygwin> python3.6m.exe -c 'import sys; print(sys.executable);'
>>> /usr/bin/python3.6m
>>
>>
>>> cmd> c:/MyStuff/NCygwin64/bin/python3.6m.exe -c 'import sys; print(sys.executable);'
>>> /usr/bin/python3.6m
>>
>>> cmd> rem add cygwin path to Windows:
>>> cmd> path %PATH%;c:\MYSTUFF\ncygwin64\bin
>>
>>> cmd> python3.6m.exe -c 'import sys; print(sys.executable);'
>>> /c/MYSTUFF/ncygwin64/bin/python3.6m
>>
>>> With CMD I'll never get an executable that actually works from cmd.
>>> Is this expected?
>>
>>Yes. This is Cygwin, not Windows CMD.

> Sure but python seems to start just fine under cmd and it does do
> some gyrations with sys.executable dependent on calling environment.
> So this looks somewhat fishy to me.

Nothing "phishy".
Cygwin programs work in POSIX environment, this is no surprise that paths you
see in Cygwin are POSIX, unless specifically converted to Windows paths.
At the same time, Cygwin programs are Windows executables. Would be surprising
if they would NOT start by themselves.
Said that, it is generally not expected that Cygwin programs would accept
native Windows paths, although in many cases, they do just fine.
The reverse also applies. Windows programs don't understand Cygwin paths and
there's no simple way to convert them outside the given Cygwin environment.
Use cygpath.

>>> Is there a way around to make this work?
>>
>>Yes, write scripts correctly, correctly translate paths.

> See above.


-- 
With best regards,
Andrey Repin
Wednesday, February 3, 2021 20:03:43

Sorry for my terrible english...


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-03 19:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 14:35 python sys.executable inconsistency if called from cmd Lemke, Michael  SF/HZA-ZIC2
2021-02-03 15:27 ` Andrey Repin
2021-02-03 16:17   ` Lemke, Michael  SF/HZA-ZIC2
2021-02-03 18:01     ` Marco Atzeri
2021-02-03 18:55     ` Andrey Repin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).