Comments (27)
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
- Create a venv with a recent version of python and
pip install httpie nuitka
- Create a python module running the httpie cmd entry point. E.G:
from httpie.__main__ import main; main()
. Seerun_http.py
. - 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
- 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.
- Install the env var plugin, which let us manipulate the system PATH to add
http.exe
parent directory. - 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. - 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:
- Optimize the compilation phase so that you don't include the entire stdlib.
- Automate the whole thing.
- Put an icon in there.
- Sign the binary.
- More robust PATH handling.
- Entry point should be a cmd.exe call, with httpie loaded in the PATH, not httpie directly.
- Handle updates.
- Create an e2e test in your CI infra.
- Upload to windows store ?
from cli.
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
from cli.
@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.
from cli.
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.
from cli.
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.
from cli.
https://github.com/jftuga/HTTPie-Windows
Please read the Warnings section before using this.
from cli.
A Scoop alternative would be great
from cli.
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.
from cli.
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.
from cli.
Winget please: https://learn.microsoft.com/en-us/windows/package-manager/winget/
from cli.
Scott Hanselman has a step by step guide on how to install it on windows
from cli.
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
from cli.
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.
from cli.
https://github.com/chocolatey/choco/wiki
from cli.
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.
from cli.
Still no stand-alone .exe
for Windows like aria2c.exe, curl.exe, wget.exe
?
from cli.
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...
from cli.
Just noticed that issue asking for Windows package was created in 2012, whereas we are in 2017 now.
from cli.
I'd be willing to create/maintain a package for Chocolatey. Let me know if this is still desired.
from cli.
@jftuga, would you care to share your http.exe
with mere Windows users without compiler stuff?
from cli.
@jftuga, works as expected, at least basic actions. Thank you, sir.
from cli.
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).
from cli.
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.
from cli.
This is great. Thanks, @ksamuel! We’ll look into exploring this approach. 🧪
from cli.
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.
from cli.
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 :)
from cli.
@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.
from cli.
Related Issues (20)
- Add support for HTTP/2, HTTP/3, System CA, OCSP Revocation HOT 3
- Support for team collaboration/sync HOT 3
- Average speed is reported incorrectly for resumed downloads HOT 1
- How to remove DEFAULT_UA? HOT 1
- Default to localhost HOT 2
- Allow XDG_CONFIG_HOME usage also on Windows
- More statuses support HOT 1
- Unable to install httpie via Chocolatey HOT 14
- [macOS] Lag when piping stdout HOT 5
- Display a warning for using option --ignore-stdin when request fails with content present in stdin
- Request is fired to packages.httpie.io on every invocation of `http` HOT 1
- How to post an empty string as a data field? HOT 2
- werkzeug compatibility
- Docs: Ubuntu/Debian installation script gives error
- Does not work with a small easy peasy sample 'http -f requests.http' HOT 4
- Add shortcut to --verify=no
- Default headers by domain
- Add support for OAuth2 authentication
- Can't install a plugin because cannot invoke pip
- HTTPS_PROXY not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cli.