confluent-kafka-python
confluent-kafka-python copied to clipboard
setup.py: Add /usr/local for macos brew support
brew support of what? - can you explain a bit more the purpose
Sure. This allows building with https://formulae.brew.sh/formula/librdkafka , which has headers and libs install into /usr/local
we do binary wheels for python, right. why do you want to use the brew installed librdkafka? is it for M1 support?
We do have one dev on an M1, and we had a requirement to switch to python 3.10 before the recent release which added wheels, so I had this patch so our CI (and me on a non-M1 mac) could easily build on mac before https://github.com/confluentinc/confluent-kafka-python/issues/1219 was resolved recently.
The instructions at https://github.com/confluentinc/confluent-kafka-python/blob/master/INSTALL.md#install-from-source-on-mac-os-x dont work without this patch.
i wonder if this can it be done with env variables?
[ i'm not an expert here as you can tell from my n00b questions :-), so wary of screwing something up ]
It can be done with env variables, but that then depends on whether other tools are all going to play nice. e.g. the package manager like flit/poetry/pipenv/pdm/etc, and pip.
It is also possible to create a custom site.cfg for a venv, e.g. https://github.com/numpy/numpy/blob/main/site.cfg.example
But they both require the user to know what they are doing.
A better approach is to use https://pypi.org/project/pkgconfig/ , which means it will find the correct paths to add for any platform, but then you need to add that as a setup_requires . I've done that a few times for packages using external C deps, so I don't mind doing that if you prefer it.
If include_dirs (et.al) take precedence over standard paths then this PR introduces a problem with promoting /usr/local over system installed packages, which would be unexpected and undesired. I think it would be better to instruct people how to set proper env vars for non-standard source builds instead.
What about if I adjusted this so it only adds /usr/local on macos, or explicitly adding [/usr, /usr/local] so that the precedence is clearly /usr is used first if possible.
I'd rather we didn't alter these defaults path at all, but instead provide instructions for how to build with non-default include/library paths.
Also note that we'll soon be providing m1 wheels.
@edenhill , /usr/local is the correct path on macos, based on the instructions at https://github.com/confluentinc/confluent-kafka-python/blob/master/INSTALL.md#install-from-source-on-mac-os-x . brew never installs into /usr , except for a few binary blob casks from non-OSS vendors that they can't control.
It would be really helpful if this gets merged