stan-dev / httpstan

HTTP interface to Stan, a package for Bayesian inference.
ISC License
40 stars 15 forks source link

Source release of httpstan on pypi #583

Closed tillahoffmann closed 2 years ago

tillahoffmann commented 2 years ago

Would it be possible to publish a source release on pypi for httpstan? I'm currently using an Apple M1 processor for which wheels do not yet exist, but building from source works fine. However, it would be nice to not have to install httpstan manually in every virtual environment but instead have it build from source via pip install.

riddell-stan commented 2 years ago

This isn't currently possible because setuptools cannot build httpstan from source.

There may (eventually) be some sort of solution to this issue. For example, I think https://github.com/scikit-build/scikit-build is trying to develop a solution.

I might look into making an M1 release in December once all the Python 3.10 dust has settled. Currently it's a little difficult because nobody I know has an M1 and GitHub Actions does not make M1s available.

tillahoffmann commented 2 years ago

I've made a minor adjustment in https://github.com/tillahoffmann/httpstan/commit/7c2720576a4316e77955bcb2027bca305e504fee, and I seem to be able to install from source using

# Need to set CPATH because homebrew's include isn't searched by default.
export CPATH=/opt/homebrew/include 
pip install git+https://github.com/tillahoffmann/httpstan.git@pip

This also seems to work in a docker container using the following Dockerfile.

FROM python:3.8
WORKDIR /workspace
RUN apt-get update \
    && apt-get install -y python-pybind11 \
    && pip install git+https://github.com/tillahoffmann/httpstan.git@pip \
    && python -c "import httpstan; print(httpstan.__version__)"

Running docker build --platform=linux/amd64 -t httpstan . spits out the desired 4.6.1.

Does that also work for you? If yes, worth integrating this change?

Update: I should of course have tested whether it actually worked (rather than just compiled). Looks like the stanc compiler is missing when installing from pip.

tillahoffmann commented 2 years ago

Alright, I've now got a version of httpstan that is pip-installable by running the make step as part of the standard build process. Diff is here.

riddell-stan commented 2 years ago

Thanks for looking into this. Maybe post a link to your version on the forums so other ARM users can pip install it?

Minor notes:

As for incorporating this, I think we should probably go the route described by scikit-build, since it handles everything elegantly. In particular, it will work even if the user doesn't have curl or make installed.