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

Compile python code at Rust compile time. #5

Merged
merged 2 commits into from
Apr 24, 2019
Merged

Conversation

de-vri-es
Copy link
Contributor

@de-vri-es de-vri-es commented Apr 23, 2019

This PR compiles the python code at Rust compile time. Implements #3.

Currently this will ouput this on a syntax error:

error: proc macro panicked
  --> inline-python-example/src/main.rs:7:2
   |
7  |       python! {
   |  _____^
8  | |         import matplotlib.pyplot as plt
9  | |         plt.plot('data)
10 | |         def foo()
11 | |         plt.show()
12 | |     }
   | |_____^
   |
   = help: message: invalid syntax at inline-python-example/src/main.rs:10:10

Though we know the filename, line number and column, we can't easily turn that into a Span, so for now it just prints the information in an error message. Would be very cool though if we can get a span to point to the syntax error.

I had to manually expose the PyMarshal_* functions, but I'll send those to pyo3 in a PR too.

@de-vri-es de-vri-es force-pushed the compile-at-compile-time branch 3 times, most recently from 0f0a86a to 76b3aec Compare April 23, 2019 21:48
@de-vri-es
Copy link
Contributor Author

PR to add PyMarshal_* functions at pyo3 can be found here: PyO3/pyo3#460

@m-ou-se m-ou-se merged commit 7a4abd0 into master Apr 24, 2019
@m-ou-se m-ou-se deleted the compile-at-compile-time branch April 24, 2019 09:40
@m-ou-se m-ou-se restored the compile-at-compile-time branch April 24, 2019 09:41
@de-vri-es de-vri-es deleted the compile-at-compile-time branch April 24, 2019 10:18
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

Successfully merging this pull request may close these issues.

None yet

2 participants