harelba / q

q - Run SQL directly on delimited files and multi-file sqlite databases
http://harelba.github.io/q/
GNU General Public License v3.0
10.21k stars 423 forks source link

q installation via brew requires a full Xcode installation? #295

Closed jthomerson closed 2 years ago

jthomerson commented 2 years ago

Is there any way around this requirement? I have the Xcode CLI tools installed, but I really don't want to have Xcode itself installed since I have no use for it. I really want to use your tool, but not at the expense of having Xcode installed.

Or is there a Docker container with q in it? I could also install it that way if needed.

Thanks for the help!

$ brew install harelba/q/q
Running `brew update --preinstall`...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
Updated 56 formulae.
==> New Casks
arctype
==> Updated Casks
Updated 58 casks.

==> Tapping harelba/q
Cloning into '/opt/homebrew/Library/Taps/harelba/homebrew-q'...
remote: Enumerating objects: 35, done.
remote: Total 35 (delta 0), reused 0 (delta 0), pack-reused 35
Receiving objects: 100% (35/35), 5.57 KiB | 1.39 MiB/s, done.
Resolving deltas: 100% (7/7), done.
Tapped 1 formula (15 files, 16KB).
q: A full installation of Xcode.app 12.4 is required to compile
this software. Installing just the Command Line Tools is not sufficient.

Xcode can be installed from the App Store.
Error: q: An unsatisfied requirement failed this build.
harelba commented 2 years ago

Hi, thanks for opening this ticket.

First, I imagined that some people might have an issue with that, so a quick way to work around this - You can manually download the macos-q executable that resides in the release assets (https://github.com/harelba/q/releases/download/v3.1.6/macos-q).

Download and rename it, chmod +x the file so it's considered an executable by osx and make sure it's in the PATH. One small thing - newer osx versions have some security feature that might require you to "approve" the new executable by running it once through Finder (double-clicking it, and saying that you are ok with it running). After this initial approval, it will run from the command-line directly without problems.

Some details -

The reason xcode is needed for actually building q is related to the fact that i'm using pyoxidizer to create a fully self-contained standalone executable (zero dependencies), and it requires it for its mac builds.

I would assume that pyoxidizer can reduce its dependencies to only xcode-cli, and not the entire xcode package. However, I'm not sure about the details, as pyoxidizer does a lot of magic (great magic, by the way, which in my view can lead to a new standard for packaging python code). I would assume that if this is not possible, then it's due to some OSX constraint and not a pyoxidizer limitation.

Really hope this helps, sorry for the inconvenience.

jthomerson commented 2 years ago

Thanks! That worked.

raylu commented 1 year ago

is it possible to have the formula/tap instead download https://github.com/harelba/q/releases/latest/download/macos-q?

(where is the formula located? I couldn't find the code)

harelba commented 1 year ago

The formula is in https://github.com/harelba/homebrew-q

From what i checked back then, homebrew doesn't allow installing the executable directly (they seem to have a lot of restrictions, some of which i can understand, but others, such as not supporting pyoxidizer itself, i can't).

I'm hardly an expert in homebrew though, so perhaps there's a good way to do that. However, I can't invest time in this currently (day job, etc...).

raylu commented 1 year ago

basically, just gotta switch from a formula to a cask https://docs.brew.sh/Cask-Cookbook. casks allow precompiled binaries. I just did it myself for the first time and packaged up my precompiled binary here: https://github.com/raylu/homebrew-formulae/blob/main/Casks/git-whence.rb

that said, does q really need to be built by pyoxidizer? it runs with just python and six, right? (rather than installing xcode, I just git cloned and ran bin/q.py.) if you published an sdist to pypi, the mac installation could also just be pip install q-csv or something

raylu commented 1 year ago

here's a formula that installs q without pyoxidizer: https://github.com/raylu/homebrew-formulae/blob/main/Formula/q.rb

brew install raylu/formulae/q

harelba commented 1 year ago

Hi thanks a lot for touching on this subject and investing the time in it, i'm really not that good in proper packaging, and to tell the truth, homebrew's decline of q through pyoxidizer kind of blew my wind in investing time in it.

The main idea of using pyoxidizer was to eliminate the need for having python itself in the machine. There are lot of people contacting me over the years regarding installations which don't have python in them.

This is why I invested time in creating the standalone binary and not in making the python installation work well (saw your other comments regarding setup.py etc.). It worked well for linux and windows. It also worked with osx, until homebrew decided that pyoxidizer is not good for them, and I agree that the current solution for osx is hardly the best. The Xcode dependency is effectively only needed for builds, and not for runtime, so the fact that it's currently needed in runtime is actually a bug on my end.

The main q runtime dependency which is not trivial is sqlite3, which actually requires a dynamic shared library. I've managed with Pyoxidizer to eliminate the need for that as well.

Would a cask installation eliminate the need for python/sqlite3 as well, or would they be a prerequisite for installation?

raylu commented 1 year ago

cask installation just downloads the binary. you can see my git-whence one as an example

for people using brew though, I think pulling in python as a dependency is pretty minor...

The Xcode dependency is effectively only needed for builds, and not for runtime, so the fact that it's currently needed in runtime is actually a bug on my end.

well, https://github.com/harelba/homebrew-q/blob/8d1b3ecd46345bf232168d8a27b07c902543355b/Formula/q.rb#L18 already sets it as a build-only dependency. but you don't have a bottle, so brew install tries to build it and pulls in the build deps. you could set up a bottle if you really wanted to continue the pyoxidizer route, but it still feels like overkill just to avoid the python dep