bytecodealliance / wasmtime-py

Python WebAssembly runtime powered by Wasmtime
https://bytecodealliance.github.io/wasmtime-py/
Apache License 2.0
381 stars 52 forks source link

add source distribution to pypi - to create conda package #231

Open rxm7706 opened 2 months ago

rxm7706 commented 2 months ago

Pypi distribution is missing source files - https://pypi.org/project/wasmtime/#files Adding the source will help create a conda package, and make wasmtime available for conda users.

alexcrichton commented 2 months ago

Thanks for the report! I don't have a ton of experience with this myself, so if you're knowledgeable of how to do this a PR would be greatly appreciated! Wheels are produced in CI so it's in theory probably just a few edits to those files.

whitequark commented 1 month ago

@alexcrichton You probably want to add one more of these blocks:

https://github.com/bytecodealliance/wasmtime-py/blob/3ac42c444bc1cc316e9d7409c48fade99e48d92f/.github/workflows/main.yml#L90

but with python setup.py sdist instead of python setup.py bdist_wheel. This will produce a tarball which you publish in the same way as a wheel.

alexcrichton commented 1 month ago

Ah ok! That's easy enough to add, but I should probably ask a bit more about this. I've got no experience with Conda myself, but is the idea that this package is buildable from source? If so that's not currently possible with scripts in this repository because it requires a build of the Wasmtime C API which this repository downloads from the Wasmtime repository when packages are uploaded. How would Conda know about this dependency relationship?

whitequark commented 1 month ago

I (somewhat regretfully) have experience with Conda, so I can answer that.

How would Conda know about this dependency relationship?

Conda recipes are YAML files that include build scripts. They can do anything, including e.g. downloading and repackaging wheels. I think you could make an sdist useful in this regard (and also to non-Conda users) by making it so that setup.py bdist_wheel (which is the command that will get run eventually) downloads and installs the Wasmtime C API through any means necessary; this usually involves setuptools crimes.

With Conda specifically this isn't strictly a requirement as the scripts contain arbitrary shell scripts. I'm too out of date to say if having an sdist would help packagers much or not at all. But I do agree with you (I think) that an sdist should be actually useful on its own, i.e. contain commands to download the Wasmtime C API, otherwise there is no point in publishing it.

If that's not desired (it's somewhat annoying to get setuptools to do this) then you could lean on Conda packagers to use a git checkout instead, which is very much supported by Conda as well.