Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing jq onto Windows #20

Closed
lbrader opened this issue Mar 16, 2016 · 26 comments · Fixed by #109
Closed

Installing jq onto Windows #20

lbrader opened this issue Mar 16, 2016 · 26 comments · Fixed by #109

Comments

@lbrader
Copy link

lbrader commented Mar 16, 2016

The library looks great. I'm doing development in Python on windows. And not sure how to install this on Windows as a python library. I took at the setting up on the Linux side. And didn't figure out how to deploy this to Windows. Any links to help? Thanks

@mwilliamson
Copy link
Owner

I'm afraid I don't have much experience with Python on Windows, and none with installing C extensions on Windows, so can't offer any useful advice.

@lbrader
Copy link
Author

lbrader commented Mar 16, 2016

Thanks for fast turn around. Let me ask around various folks. If I get an answer I'll post it back here.

@mewalig
Copy link

mewalig commented Aug 3, 2016

someone's hiring to solve this: https://www.upwork.com/jobs/~0147f3bb893b8bb615

@BurnoHoffmann
Copy link

http://www.dowdandassociates.com/blog/content/howto-install-jq/
This url will help you.

@BurnoHoffmann
Copy link

I installed jq on windows using following method.
At first, I installed Chocolatey.
Using "choco install jq -version 1.5", I installed jq on windows.
Thanks,
Burno

@philpep
Copy link

philpep commented May 18, 2018

Any news on this ? I tried to dig into this issue and it seems that oniguruma 6.8.2 can compile on windows (with make_win64.bat & visual cpp) but jq seems to compile only with mingw so I guess this will be an issue. Maybe compile all with mingw is the best choice here ?

@mrjcleaver
Copy link

A wheel for Windows would be wonderful.

It's a bit warful to wequire a workaround.

@Jiehong
Copy link

Jiehong commented Apr 8, 2021

I've installed jq by downloading the jq binary from the jq website, and put it somewhere in the windows PATH.

This works, as I can use jq in any terminal now.

However, if I try to do pip install jq, it will still try to build a wheel for it (and fail in my case). Why would it need to build wheels if jq is already installed on the system?

@Avinash-Bhat
Copy link

@Jiehong jq.py needs to link to the underlying library of jq. A simple downloading and install doesn't do that.

PS: if you want to, you can just use subprocess to invoke the command from python. Not the cleanest way to do things, but will get things done on Windows

@idobleicher
Copy link

How to install in windows when working with python, pip install jq is giving errors still couldn't solve it :(

@idobleicher
Copy link

ERROR: Failed building wheel for jq
ERROR: Could not build wheels for jq, which is required to install pyproject.toml-based projects
some magic that can solve this, that I am unaware of ?

@MatrixManAtYrService
Copy link

MatrixManAtYrService commented Feb 6, 2022

Ugh. I really don't want to remove jq as a dependency, it's really nice to let users just pass jq strings in to express "where is the thing", but I'm not about to go tell my new users that they have to use a different OS, nor do I want to add an external dependency and engage in if windows: nonsense.

@jknockel
Copy link

I have built some wheels using mingw/msys against both python 3.10 and 3.11 here:

https://www.cs.unm.edu/~jeffk/jq/

These have had very little testing, so please use at your own risk.

To get jq.py to build I had to apply a number of hacks against the jq and jq.py source code. While I could probably go back and turn these into patches by guarding the changes with "if windows then XXX" sorts of conditions, perhaps more problematic was that in the process of building these I also came across a number of issues with python itself [1, 2], which ultimately led me to discover that mingw/msys is not supported by python [3]. While I was in turn able to work around these issues with additional hacks, the existence of these issues with python itself would seem to disfavor mingw/msys ever being an official build target of jq.py, although it clearly is not impossible to build jq.py using mingw/msys with enough effort.

[1] https://bugs.python.org/issue28267
[2] https://stackoverflow.com/a/57109148
[3] https://bugs.python.org/issue45538

@reivaxy
Copy link

reivaxy commented Jun 1, 2023

I have built some wheels using mingw/msys against both python 3.10 and 3.11 here:

Thank you so much for that, you rock (at my own risk is much better than not at all)

@baterflyrity
Copy link

@jknockel , can you please share building instructions for windows or maybe build jq for python 3.12?

@jknockel
Copy link

jknockel commented Oct 29, 2023

@jknockel , can you please share building instructions for windows or maybe build jq for python 3.12?

Sure. In fact, I don't know if it's due to changes in python 3.12 or due to improvements to mingw64 (edit: it appears to be due to improvements in python 3.12), but the number of changes I had to make were much fewer this time:

https://github.com/jknockel/jq.py/tree/mingw-build

To build the wheel from an msys bash shell:

cython3 jq.pyx
python setup.py build --compiler=mingw32
python setup.py bdist_wheel

I've also uploaded the 3.12 wheel here:

https://www.cs.unm.edu/~jeffk/jq/

Again, this build has had very little testing, so please use at your own risk.

@baterflyrity
Copy link

@jknockel , thanks. You really helped me to solve it with 3.11 and 3.12.
Seems like I will some time rollout my own python binding that "just works".

@du33169
Copy link
Contributor

du33169 commented May 18, 2024

@jknockel Sorry to bother after so long.
Thanks to your instructions, I finally built a wheel under MSYS2 UCRT64.
It worked well in the same MSYS2 environment and even passed all the tests after some adjustments.
However, when I tried to pip install it to a native windows python environment, it reported:

ERROR: jq-1.7.0-cp311-cp311-mingw_x86_64_ucrt.whl is not a supported wheel on this platform.

I suppose renaming it is not a proper solution.
I've noticed that the wheel you provide on https://www.cs.unm.edu/~jeffk/jq/ has the correct platform identifier win_amd64 and can be properly installed/imported, but you did mention that it was built under msys bash as well.

Please tell me if I've missed something, thanks!


edit: Nevermind, I found the solution here:

# ./_virtualenv/bin/pip install wheel
./_virtualenv/bin/wheel.exe unpack dist/jq-1.7.0-cp311-cp311-mingw_x86_64_ucrt.whl -d dist
mv dist/jq-1.7.0/jq.cp311-mingw_x86_64_ucrt.pyd dist/jq-1.7.0/jq.cp311-win_amd64.pyd
perl -i  -pe 's/cp311-cp311-mingw_x86_64_ucrt/cp311-cp311-win_amd64/' dist/jq-1.7.0/jq-1.7.0.dist-info/WHEEL
./_virtualenv/bin/wheel.exe pack dist/jq-1.7.0 -d dist

@jknockel
Copy link

Looks like you may have already found a solution, but to clarify a few details that may be relevant, in my procedure I used the MSVCRT version of mingw not the UCRT version, and I used python as provided by the standard python installer on python.org, not an msys-packaged version of python.

@du33169
Copy link
Contributor

du33169 commented May 23, 2024

Looks like you may have already found a solution, but to clarify a few details that may be relevant, in my procedure I used the MSVCRT version of mingw not the UCRT version, and I used python as provided by the standard python installer on python.org, not an msys-packaged version of python.

Thanks! Actually I turned to standard python shortly after that as well.
MSYS2 follows the convention of prefixing libraries with lib(see msys2 wiki).
Consequently, any .pyd binary built under MSYS2 will link to libpython3.xx.dll, leading to DLL load failed when trying to install and import jq.py to a standard python environment, which provides python3xx.dll.
These two files are actually identical, and one can eliminate the error by manually editing the dll(pyd) dependency name using tools like CEF Explorer. This is some kind of "hacky" so these details are recorded just for future reference.

These days I'm trying to turn the whole process into github action flows, possibly opening a PR once everything's working fine.

@mwilliamson mwilliamson reopened this Jun 14, 2024
@mwilliamson
Copy link
Owner

I've just published 1.8.0a2, which includes Windows wheels. Reports of success or failure using those wheels are gratefully received!

@dracozombie19
Copy link

I just installed on Windows 11 successfully. I also ran a script with all of the asserts from the README and they all passed.

@baterflyrity
Copy link

I've just published 1.8.0a2, which includes Windows wheels. Reports of success or failure using those wheels are gratefully received!

Windows 10 x64 Python 3.12 - still installation error.

@mwilliamson
Copy link
Owner

I've just published 1.8.0a2, which includes Windows wheels. Reports of success or failure using those wheels are gratefully received!

Windows 10 x64 Python 3.12 - still installation error.

Just to check: you're trying to install the prerelease version? If so, could you post what the error you're getting?

@baterflyrity
Copy link

I've just published 1.8.0a2, which includes Windows wheels. Reports of success or failure using those wheels are gratefully received!

Windows 10 x64 Python 3.12 - still installation error.

Just to check: you're trying to install the prerelease version? If so, could you post what the error you're getting?

sry, prerelease is installed successfully

@mwilliamson
Copy link
Owner

Thanks for the reports, 1.8.0 is now out with Windows wheels. Thanks again to all who helped put this together!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.