s3tools / s3cmd

Official s3cmd repo -- Command line tool for managing S3 compatible storage services (including Amazon S3 and CloudFront).
https://s3tools.org/s3cmd
GNU General Public License v2.0
4.59k stars 905 forks source link

Windows: Install s3cmd as a direct command that does not need to be called with "python" cmd line #944

Open ecc256 opened 6 years ago

ecc256 commented 6 years ago

Looks like something is amiss with s3cmd install. It supposed to create file s3cmd.cmd in Python\Scripts folder with following content: @%~dp0..\python %~dp0s3cmd %*

As a result s3cmd is crippled on win. It won’t run same way it runs on linux for example. Instead we have to use smth. like python c:\Python27\Scripts\s3cmd which is ridicules :-/ With above file created it’ll run with s3cmd

fviard commented 6 years ago

@ecc256 Thank you for the report. Your help to fix this would be highly appreciated as I'm not an expert of pyhon on windows. the "s3cmd" command file is installed with the setup tools standard "script" directive. I'm no idea why it is badly handled on windows. Would you have an idea looking at the setup.py what we could miss for setup tools creating the needed file at installation?

fviard commented 6 years ago

Do you know any python package that does what is needed so that it works as you expect it?

ecc256 commented 6 years ago

Florent, It’ll be Locust. https://docs.locust.io/en/latest/installation.html

It does install .exe instead of .cmd file. Which is a lot better due to "funny way" of calling one .cmd file from another on windows. By default it execute goto statement - i.e. control never returns to original .cmd script.

That’s why it’s better/more convenient to use dummy .exe file instead.

fviard commented 6 years ago

Thank you for the reference. So I see, it should be handled by the "entry_points" "console_script" of setuptools. But that would fit well with s3cmd and also I don't like very much to use that. A similar case: https://github.com/python/mypy/issues/1226

I keep that on the todo list to see if something can be done with a .bat, or .cmd

ecc256 commented 6 years ago

IMO, it’ll be quite inconvenient to use with .bat, or .cmd. If possible, better go with .exe.

Namely, to call from another .cmd, we will have to use: For s3cmd.cmd/s3cmd.bat call s3cmd {params}

For s3cmd.exe s3cmd {params}

I use lots of same scripts on windows and linux and will have to change it every time I copy it...

fviard commented 6 years ago

ok, I see. The issue I guess is that if it is a .exe, it necessarily need to something binary, so that have to be built/compiled.

ecc256 commented 6 years ago

I think, it’s a dummy or generic exe. Folder "C:\Program Files\Python36\Scripts" has quite few of them, all about same size. All they do is run python and pass script as parameter, I think. I.e. xyz.exe should call python.exe xyz.py (or something like this)

Another way is to compile py into exe (Google for these words) I might be wrong completely, I’m not expert in these things...

fviard commented 6 years ago

ah like busybox for linux, the exe could use its filename to find the module to load. When i will have a little time, I would look at the source code of setuptools to see how they do that. Otherwise, it might be possible to use the entry_points feature of setuptools only on windows.

ecc256 commented 6 years ago

If you update this thread when you done, I'll test it right away! :)

fviard commented 6 years ago

Ok, thank you, will keep you updated

bputrapajakio commented 9 months ago

5 years later