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

Add "with-axum" feature to allow compilation when other dependencies use axum #181

Merged
merged 4 commits into from
May 10, 2024

Conversation

dureuill
Copy link
Contributor

Hello,

thanks for developing plotly ❤️

I'm currently trying to use it for a server backend based on axum that also uses askama for templates, and unfortunately that combination results in a compilation error as we run afoul of https://github.com/djc/askama/issues/810:

Compiler errors
error[E0433]: failed to resolve: could not find `askama_axum` in the list of imported crates
  --> /Users/dureuill/.cargo/git/checkouts/plotly-2d2da452b8500b54/0351510/plotly/src/plot.rs:14:10
   |
[package]
14 | #[derive(Template)]
   |          ^^^^^^^^ could not find `askama_axum` in the list of imported crates
   |
   = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: could not find `askama_axum` in the list of imported crates
  --> /Users/dureuill/.cargo/git/checkouts/plotly-2d2da452b8500b54/0351510/plotly/src/plot.rs:21:10
   |
21 | #[derive(Template)]
   |          ^^^^^^^^ could not find `askama_axum` in the list of imported crates
   |
   = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: could not find `askama_axum` in the list of imported crates
  --> /Users/dureuill/.cargo/git/checkouts/plotly-2d2da452b8500b54/0351510/plotly/src/plot.rs:31:10
   |
31 | #[derive(Template)]
   |          ^^^^^^^^ could not find `askama_axum` in the list of imported crates
   |
   = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0433]: failed to resolve: could not find `askama_axum` in the list of imported crates
  --> /Users/dureuill/.cargo/git/checkouts/plotly-2d2da452b8500b54/0351510/plotly/src/plot.rs:38:10
   |
38 | #[derive(Template)]
   |          ^^^^^^^^ could not find `askama_axum` in the list of imported crates
   |
   = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0433`.
error: could not compile `plotly` (lib) due to 4 previous errors

To fix these issues, I added the with-axum feature that adds the askama_axum additional dependency when enabled (as well as the with-axum of the askama crate).

Users encountering the compilation errors above need to enable the with-axum feature of plotly to fix the errors. I tested locally and it enables compilation again 👍

Thanks for reading 🚀

@andrei-ng
Copy link
Collaborator

@dureuill , thanks for your PR. Looks good. Will try to get this merged in the next weeks.

@andrei-ng andrei-ng force-pushed the feature_with_axum branch from 2d2a06e to 3ea3d31 Compare May 10, 2024 10:39
@@ -18,9 +18,11 @@ kaleido = ["plotly_kaleido"]
plotly_ndarray = ["ndarray"]
plotly_image = ["image"]
wasm = ["getrandom", "js-sys", "wasm-bindgen", "wasm-bindgen-futures"]
with-axum = ["askama/with-axum", "askama_axum"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the feature name could be a bit better, but naming is always hard 😁
Will merge it like this for now.

@andrei-ng andrei-ng merged commit ba867e0 into plotly:main May 10, 2024
17 of 18 checks passed
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.

2 participants