Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options for distributing without rustc? #2

Open
MatthiasKauer opened this issue Jan 25, 2016 · 13 comments
Open

Options for distributing without rustc? #2

MatthiasKauer opened this issue Jan 25, 2016 · 13 comments

Comments

@MatthiasKauer
Copy link

Hi,
I'm interested in your project because I'm looking for an alternative to C++ extensions. I'm now wondering how the odds are for distributing an extension that I would write.
In C++, I could build a wheel for Windows and Mac and then expect that Linux users would have a compiler ready.
With Rust, however, this may not work that way.
The wheel building part for Win/Mac may still work out (will it?)
I'm most worried about the Linux part since rustc will just not be available everywhere for the foreseeable future. How well does Lbinary distribution work for Linux with Rust? It's not going to be better than C, is it?

Kind regads,
Matthias

@kmike
Copy link

kmike commented Jan 25, 2016

Hey @MatthiasKauer,

It looks like binary Rust wheels are not easy either (pypa/setuptools#435).

@novocaine
Copy link
Owner

Great Idea @MatthiasKauer !

Until rust is as mainstream as C compilers, asking your users to compile rust to use your extension is likely to alienate them just a little bit. So as @kmike suggests you would really want to distribute binary wheels.

I don't see why in principle wheels can't be made to work, but I haven't tried. If you work out how to hook distutils, I'd love to incorporate it into this project as long as it's clean.

You should be aware that working out how to use rust-cpython is very daunting and it only runs on rust nightlies. While I am optimistic about its future given the obvious benefits of the approach, I don't believe it's really ready for writing production libraries just yet, which is why I haven't done much more in this space lately.

(maybe I should revise the promises I give in the README.md?)

@MatthiasKauer
Copy link
Author

Hi,
thanks for the clarification.
Simon Sapin's discussion on bitbucket is a big issue that I hadn't even foreseen.

I was more worried about this PEP: https://www.python.org/dev/peps/pep-0491/
If I read this right, wheels do not work for Linux right now since the C libraries on various distros are too different. If that's an issue for C, it's most likely going to be an issue for rust too, no?

@kmike
Copy link

kmike commented Jan 27, 2016

@MatthiasKauer yeah, almost: wheels work on Linux, but you can't safely share them and distribute them if machines are different. There is https://www.python.org/dev/peps/pep-0513/ in works to overcome it.

@MatthiasKauer
Copy link
Author

exactly, that's the one we would need @kmike

And regarding rust-cpython: I was under the impression that its goal is the other direction, i.e., calling Python from Rust. Am I mistaken there too?

@novocaine
Copy link
Owner

You would need also equivalent guarantees from the rust packager. I don't know if that's on the table for rust.

On the up side maybe linux users are more amenable to installing rustc especially if there is an appropriate version in their package manager.

rust-cpython is just a wrapper around the Python C API, meaning it is suitable wherever the Python C API is - either embedding Python in an application, or calling C libraries from python. It does contain examples of how to do either. My personal interest is in the latter.

@dholth
Copy link

dholth commented Sep 6, 2016

Hi, author of bdist_wheel here. I've been working on a different way to make wheels using SCons that I hope will be useful. IMO it is simpler and easier to understand than bdist_wheel because it does not use the setuptools/distutils architecture at all, but it also emulates setup.py to create pip-compatible sdists. Here's an example build file for Simon's cffi Rust example. https://github.com/dholth/hello-pyrust/blob/master/SConstruct

I'd be interested in hearing whether this is useful to you.

@novocaine
Copy link
Owner

cool. I guess the equivalent of rust-python-ext for your new system would be a Builder for rust libs?

How is scons going with python 3 support?

@dholth
Copy link

dholth commented Sep 7, 2016

Yes. As you can see on line 28 invoking cargo with an env.Command() is really easy too, it is not like GCC where you have to understand a ton of options and a multi-step compile - link toolchain. Or you could publish a pypi project that adds a rust builder and install it before setup on line 3 of this file https://github.com/dholth/hello-pyrust/blob/master/pyproject.toml

SCons works on Python 3 for everything I've tried to do with it. enscons automatically pulls in the correct SCons from https://pypi.python.org/pypi/import-scons

@novocaine
Copy link
Owner

oh, neat. with some sort of trunk scons? pip3 install scons for me tries to install 2.5.0 and errors because it explicitly doesn't support py3

@dholth
Copy link

dholth commented Sep 7, 2016

https://github.com/timj/scons/tree/u/timj/python3

pip install import_scons && python -m SCons

@MatthiasKauer
Copy link
Author

@dholth Just to clarify: Your scons solution does indeed build a binary wheel such that the end user doesn't need a rust compiler anymore? That would be a great step.

@dholth
Copy link

dholth commented Sep 24, 2016

That's right. It builds wheels and gives you lower level control over how the wheel is built compared to setuptools. After the wheel is built it's no different and you can distribute the wheels normally.
On Sep 24, 2016 09:48, MatthiasKauer notifications@github.com wrote:@dholth Just to clarify: Your scons solution does indeed build a binary wheel such that the end user doesn't need a rust compiler anymore? That would be a great step.

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants