0k / shyaml

YAML for command line
BSD 2-Clause "Simplified" License
767 stars 57 forks source link

access to executable entrypoint on Window is failing #38

Closed waytoharish closed 3 years ago

waytoharish commented 7 years ago

Hi, Is there any way to support in window OS.I am trying to use shyaml with Jenkins job in window

vaab commented 7 years ago

Hmm, didn't try. What error are you facing ?

waytoharish commented 7 years ago

even though it showing installed but shyaml not found only.

thorstenkampe commented 7 years ago

The installation routine neither creates an executable (.exe) nor a Python (.py) file - which is needed in order to be directly executable in Windows

szepeviktor commented 6 years ago

pip creates a .bat file on Windows.

vaab commented 6 years ago

I checked with a VM, I have no trouble to use shyaml on windows. At least to call it and access some basic values. Here is the transcript:

T:\>python -V
Python 2.7.13

T:\>pip install shyaml
Collecting shyaml
...
Installing collected packages: pyyaml, shyaml
Successfully installed pyyaml-3.12 shyaml-0.5.0

T:\>shyaml
Error: Bad number of arguments.
Usage:

    shyaml.py (-h|--help)
    shyaml.py [-y|--yaml] ACTION KEY [DEFAULT]

T:\>which shyaml
/cygdrive/c/Python27/Scripts/shyaml

T:\>type test.yaml | shyaml get-value subvalue.maintainer
Valentin Lab

I have probably a different environment than yours.

Please feel free to re-open if you have more information on how I could reproduce your issue. Thanks for your feedback !

vaab commented 6 years ago

Ok, my bad, I found a possible issue related to your report. The installer don't really install the shyaml script somewhere that make sense for windows. I'll re-open this because it needs to be addressed. It worked in the previous example only because shyaml was in the current directory as well, AND the which command did not fetch in the current directory.

Meanwhile, you can use (correct depending on your Python installation):

python c:\Python27\Scripts\shyaml ARGUMENTS

in place of shyaml.

Please also remember that shyaml is only only script... you can download it and install it wherever you want. This doesn't solve your problem, but might give you some ideas to move towards an acceptable solution in your current setup.

thorstenkampe commented 6 years ago

Windows doesn't have a which command. Your're obviously using Cygwin's which. Cygwin is a Linux like virtualization layer which brings its own Python.

On Windows (pre PowerShell) the current directory is always first in path. On Cygwin it's not included at all in path.

szepeviktor commented 6 years ago

But there is where in modern Windows:

C:\>where where.exe
C:\Windows\System32\where.exe
szepeviktor commented 6 years ago

As Windows has no 1 package manager, there is no equivalent for /usr/bin Actually I've created C:\usr\bin on my PC and added it to %PATH%

vaab commented 6 years ago

my bad, I'm far from being in my element with Windows, and indeed, where would have told me about the fact that it was the shyaml.py in the current directory that was launched. (this is a security flaw for unix/linux people, and is discouraged as such)

T:\>where shyaml
T:\shyaml.py
T:\shyaml
C:\Python27\Scripts\shyaml

Which leads me to a conclusion that it is actually T:\shyaml.py that gets executed. It seems that what is required for the script to work is only the extension .py. After a quick test, I can confirm this fact.

So you can do a rename of shyaml to shyaml.py to make it work in the path (I'm talking of the one that got installed in C:\Python27\Scripts\shyaml).

vaab commented 6 years ago

The final solution would be to use python setuptools entrypoints of course. If you know how to do this with a one-file package like shyaml, that would be a great and easy contribution. I had a quick try, but it seem that we need to have a full fledged package, and honestly I didn't really dig that up enough to be sure on that point.

vaab commented 6 years ago

Ok, found a convincing way to make this work as it should on windows. Currently under test. In a nutshell: use modules instead of packages in setup.cfg (and not py_modules as it would be expected in setup.py) to make sure that the shyaml.py file gets bundled and installed correctly somewhere it can be imported on all system as any python module. The second part is quite classical with an entrypoint that can reference shyaml module.

vaab commented 5 years ago

Ok, just to say that #38 is included in version 0.6.0. I didn't have time to do as much test I wanted on this. Feel free to confirm me if this is working as expected.

vaab commented 3 years ago

Seems good to me on my last tests.