jq.py icon indicating copy to clipboard operation
jq.py copied to clipboard

Installing jq onto Windows

Open lbrader opened this issue 10 years ago • 21 comments

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

lbrader avatar Mar 16 '16 18:03 lbrader

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.

mwilliamson avatar Mar 16 '16 18:03 mwilliamson

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

lbrader avatar Mar 16 '16 19:03 lbrader

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

mewalig avatar Aug 03 '16 17:08 mewalig

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

BurnoHoffmann avatar Aug 05 '16 05:08 BurnoHoffmann

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

BurnoHoffmann avatar Aug 05 '16 05:08 BurnoHoffmann

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 ?

philpep avatar May 18 '18 09:05 philpep

A wheel for Windows would be wonderful.

It's a bit warful to wequire a workaround.

mrjcleaver avatar Jan 03 '21 12:01 mrjcleaver

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?

Jiehong avatar Apr 08 '21 10:04 Jiehong

@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

Avinash-Bhat avatar Jun 17 '21 14:06 Avinash-Bhat

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

idobleicher avatar Nov 21 '21 16:11 idobleicher

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 ?

idobleicher avatar Nov 21 '21 16:11 idobleicher

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.

MatrixManAtYrService avatar Feb 06 '22 03:02 MatrixManAtYrService

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

jknockel avatar Jan 31 '23 22:01 jknockel

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)

reivaxy avatar Jun 01 '23 13:06 reivaxy

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

baterflyrity avatar Oct 25 '23 10:10 baterflyrity

@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.

jknockel avatar Oct 29 '23 22:10 jknockel

@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".

baterflyrity avatar Oct 31 '23 13:10 baterflyrity

@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

du33169 avatar May 18 '24 07:05 du33169

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.

jknockel avatar May 21 '24 14:05 jknockel

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.

du33169 avatar May 23 '24 13:05 du33169

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

mwilliamson avatar Jun 14 '24 10:06 mwilliamson

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

dracozombie19 avatar Aug 12 '24 20:08 dracozombie19

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.

baterflyrity avatar Aug 13 '24 12:08 baterflyrity

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?

mwilliamson avatar Aug 13 '24 15:08 mwilliamson

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

baterflyrity avatar Aug 13 '24 16:08 baterflyrity

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

mwilliamson avatar Aug 21 '24 08:08 mwilliamson