httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
33.37k stars 3.67k forks source link

Windows package #58

Open mahmoudhossam opened 12 years ago

mahmoudhossam commented 12 years ago

I think someone should use py2exe or a similar tool to make an msi package for httpie.

Installing python and pip is a major hassle for anyone who just wants to use httpie on windows, which doesn't come with python installed by default.

mercury2269 commented 12 years ago

Scott Hanselman has a step by step guide on how to install it on windows

http://www.hanselman.com/blog/InstallingHTTPIEHTTPForHumansOnWindowsGreatForASPNETWebAPIAndRESTfulJSONServices.aspx

mahmoudhossam commented 12 years ago

@mercury2269 This is not the sort of thing I'm talking about here, people should get Httpie up and running without even having to install python.

Many people aren't python people and installing pip on windows is a hassle nobody should go through, not even python developers.

jkbrzt commented 12 years ago

Someone on Twitter has also mentioned Chocolatey, which looks like a decent package manager for Windows. That should allow you to install HTTPie using this simple command:

cinst httpie -source python
mahmoudhossam commented 12 years ago

But that would require the user to have it installed, wouldn't a standalone installer be better?

Edit: I'll try to make a windows installer using py2exe and Inno Setup

nchammas commented 8 years ago

Another option for packaging httpie as a standalone package that includes Python is PyInstaller. I haven't used it myself, but the project is very active.

You could probably even automate the process of generating a Windows package as part of httpie's CI using AppVeyor.

jkbrzt commented 8 years ago

https://github.com/chocolatey/choco/wiki

AdrianoCahete commented 8 years ago

I created a PowerShell script to install hpttpie and already pushed a PR, feel free to use this script to install on a windows machine.

sergeevabc commented 7 years ago

Still no stand-alone .exe for Windows like aria2c.exe, curl.exe, wget.exe?

jonaseriksson84 commented 7 years ago

Yeah, installing httpie on a Windows machine without Internet access is a real pain, would also love a package like this. Unfortunately my personal skill aren't quite enought to create it myself yet...

sergeevabc commented 7 years ago

Just noticed that issue asking for Windows package was created in 2012, whereas we are in 2017 now.

Witchilich commented 4 years ago

Would love to install it through Scoop with scoop install httpie or choco install httpie. It's okay if Python is a dependency. This is a Python script and I guess Python is a requirement.

digitalcoyote commented 4 years ago

I'd be willing to create/maintain a package for Chocolatey. Let me know if this is still desired.

jftuga commented 4 years ago

I was able to successfully build a stand-alone http.exe binary inside of the mcr.microsoft.com/windows/servercore:ltsc2019 Docker container with Python 3.7.6 and PyInstaller 3.6. Docker Desktop 2.1.0.5 was used.

These are the commands...

Outside the Docker container:

mkdir c:\temp\outside
docker run -t -i --mount type=bind,src=c:\temp\outside,dst=c:\inside -w c:\ mcr.microsoft.com/windows/servercore:ltsc2019

You are now inside the Docker container:

curl -L https://aka.ms/nugetclidl -o nuget.exe
set PATH=%PATH%;c:\python\tools;c:\python\tools\scripts;c:\GitForWindows\tools\cmd
nuget install GitForWindows -ExcludeVersion
set PYVER=3.7.6
nuget install python -ExcludeVersion -Version %PYVER% -OutputDirectory .
python -m pip install --no-warn-script-location PyInstaller
python -m pip install pywin32
git clone https://github.com/jakubroztocil/httpie.git
cd httpie
python -m pip install -r requirements-dev.txt
python setup.py build
cd build\lib\httpie
echo sys.exit(main())>> core.py
pyinstaller -F --noupx -n http.exe core.py
cd dist
copy http.exe c:\inside
exit

You are now outside of the Docker container:

dir c:\temp\outside\http.exe

The resulting http.exe has a size of 11,605,534.

Could someone please confirm this procedure? Thanks.

EDIT:

A pre-built http.exe binary can be downloaded from here:

https://github.com/jftuga/HTTPie-Windows

Please read the Warnings section before using this.

sergeevabc commented 4 years ago

@jftuga, would you care to share your http.exe with mere Windows users without compiler stuff?

jftuga commented 4 years ago

@sergeevabc

https://github.com/jftuga/HTTPie-Windows

Please read the Warnings section before using this.

sergeevabc commented 4 years ago

@jftuga, works as expected, at least basic actions. Thank you, sir.

Witchilich commented 4 years ago

Anyone checked the Scoop-Python bucket ? Its by the maintainer of nonportable bucket.

scoop bucket add python https://github.com/TheRandomLabs/Scoop-Python.git
scoop install httpie-py

There is a migrate-python-packages script that has to be run after every Python version update(every update for global install, major version update for user install).

NathanSweet commented 3 years ago

FWIW, I came here looking for a Windows executable, don't want to install pip. Used the one linked above even though it isn't latest.

ksamuel commented 3 years ago

Hello @jakubroztocil,

As we discussed weeks ago, here is a PoC for a Windows installer attached and the procedure I used to generate it: https://drop.chapril.org/download/889aae1e4ee17fe9/#BBLdWchiazXCxNkma9lqQQ

The link will expire in 5 days, or 20 DL. I can't attach it on Github as it's bigger than 20Mo.

Dependencies

Generate the standalone executable

1) Create a venv with a recent version of python and pip install httpie nuitka 1) Create a python module running the httpie cmd entry point. E.G: from httpie.__main__ import main; main(). See run_http.py. 1) In the venv, ask nuikta to compile it: nuitka run_http.py --standalone.

In the last step, nuitka will prompt you for downloading dependencies (an import resolver and a compiler), say yes, and wait for some time while it does its magic.

This will result in a run_http.dist directory containing compiled dependencies and an executable named run_http.exe. This directory can be copied on any modern Windows setup and used without the need to install anything, not even the Python VM, which is provided. Running run_http.exe will run the http command from httpie.

To make sure we won't confuse the users, I advice for renaming run_http.exe into http.exe after the fact. run_http.exe is named this way because we compiled run_http.py, but we can't call the script http.py, this would result in import errors since this module exists in the stdlib.

You can zip and provide this directory as a portable version of httpie, which is very useful to have on a USB stick.

Generate an installer

1) Install the large string build of NSIS, it will allow a maximum string length of 8192 bytes which is better when you deal with potentially long file system paths. 1) Install the env var plugin, which let us manipulate the system PATH to add http.exe parent directory. 1) Write a NSI script. I provided the one I used as an example, named httpie.nsi. You will find some comments, but for a better understanding, you can use NSIS Quick Setup which is a UI generating scripts. 1) Use either NSIS UI or cmd to run the .nsi file and get the installer as a result. VSCode also has a nice plugin to do that for you. Careful, any utf8 file you manipulate (E.G: the licence file) must have a BOM to be used as such.

The result is an installer that will serve a piece of httpie to your happy Windows machine. You'll find it as install_httpie.exe in the zip too. You can try it on an official pristine Windows dev VM to see that it does provide the http command, and a way to uninstall it.

Where to go from there:

jkbrzt commented 3 years ago

This is great. Thanks, @ksamuel! We’ll look into exploring this approach. 🧪

Almad commented 3 years ago

Note: there is also an unofficial choco build of HTTPie that we could automate and also use in this build.

I wonder what's the usage of choco vs windows store for CLI tools on Win. Research needed.

ksamuel commented 3 years ago

Updated the zip link, the last one expired but @jakubroztocil needed it: https://drop.chapril.org/download/3519a0235828b6d2/#Mwzt7QE4O1FnlDDIrUXjjg

It's still gonna expire in 5 days :)

lucasteles commented 1 year ago

A Scoop alternative would be great

bambooCZ commented 1 year ago

This is major problem for me as well. I am looking for an app like HTTPie, but portable exe. I need to debug reachability in clients LAN, but in production. Corporate environment. I definitelly won't install choco or python or pip ... you name it. I could use a single EXE, test it out and delete the EXE.

I guess I will have to build my own using Electron: unizp, test, delete - that's it. No system-wide hassle.

cprivitere commented 1 year ago

A Scoop alternative would be great

choco is kind of dead at this point, so winget (or scoop if winget is not palatable for some reason) would be nice for both cli and desktop.

andraaspar commented 11 months ago

Winget please: https://learn.microsoft.com/en-us/windows/package-manager/winget/

sschneider commented 10 months ago

@jkbrzt is there anything new regarding the approach of @ksamuel? I am really interested to use the tool, but I prefer a portable approach without footprint of other things.

ok-mei commented 1 week ago

is there any update for the installation via winget?