delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/02/03/14:06:06

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 98469388E821
Authentication-Results: sourceware.org;
dmarc=pass (p=none dis=none) header.from=yandex.ru
Authentication-Results: sourceware.org;
spf=pass smtp.mailfrom=anrdaemon AT yandex DOT ru
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
t=1612379101; bh=g29ie7w1JtRz5zuan2muTVjtMLWCNh33K8soiSF2H0g=;
h=In-Reply-To:Subject:To:From:Message-ID:References:Date:Reply-To;
b=B+U+ZB6CZXTu3xBW5bFuHvuBaASZEF8QlvbwWeDoeuqpsIEeYnPNpRVTcucewvgzt
VmHkuvg+AoaB5BH8KASP/jiXW8gt73Hf+WbeHWxh0n01KUV51BeGz/W5+UdORLLJbl
mYF54jqgwlY8Tjf0lR4iG7GW/ObR1CBiBTt8fosE=
Authentication-Results: vla5-8f5c42dab783.qloud-c.yandex.net;
dkim=pass header.i=@yandex.ru
Date: Wed, 3 Feb 2021 21:55:51 +0300
From: Andrey Repin <anrdaemon AT yandex DOT ru>
X-Mailer: The Bat! (v6.8.8) Home
X-Priority: 3 (Normal)
Message-ID: <659800771.20210203215551@yandex.ru>
To: "Lemke, Michael SF/HZA-ZIC2" <lemkemch AT schaeffler DOT com>, cygwin AT cygwin DOT com
Subject: Re: python sys.executable inconsistency if called from cmd
In-Reply-To: <VI1PR03MB64465B94BA262E27B051920DBEB49@VI1PR03MB6446.eurprd03.prod.outlook.com>
References: <VI1PR03MB644670814A7A43C6934EBC93BEB49 AT VI1PR03MB6446 DOT eurprd03 DOT prod DOT outlook DOT com>
<399245376 DOT 20210203182748 AT yandex DOT ru>
<VI1PR03MB64465B94BA262E27B051920DBEB49 AT VI1PR03MB6446 DOT eurprd03 DOT prod DOT outlook DOT com>
MIME-Version: 1.0
X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_THEBAT,
NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS,
TXREP autolearn=no autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Reply-To: cygwin AT cygwin DOT com
Errors-To: cygwin-bounces AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>

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...

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019