Git Product home page Git Product logo

evcxr's Introduction

Evcxr

Binder

An evaluation context for Rust.

This project consists of several related crates.

  • evcxr_jupyter - A Jupyter Kernel

  • evcxr_repl - A Rust REPL

  • evcxr - Common library shared by the above crates, may be useful for other purposes.

  • evcxr_runtime - Functions and traits for interacting with Evcxr from libraries that users may use from Evcxr.

If you think you'd like a REPL, I'd definitely recommend checking out the Jupyter kernel. It's pretty much a REPL experience, but in a web browser.

To see what it can do, it's probably best to start with a tour of the Jupyter kernel. Github should allow you to preview this, or you can load it from Jupyter Notebook and run it yourself.

License

This software is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE for details.

evcxr's People

Contributors

aklitzke avatar aminroosta avatar anandijain avatar baiguoname avatar baughn avatar carreau avatar cinusminus avatar davidb avatar davidlattimore avatar dependabot[bot] avatar dima74 avatar ibraheemdev avatar komi1230 avatar kvieta1990 avatar lisanhu avatar luizirber avatar ma27 avatar marcono1234 avatar maurges avatar mgeier avatar mirkocovizzi avatar momori256 avatar noamraph avatar okdewit avatar thomasjm avatar thomcc avatar timclicks avatar wiseaidev avatar wseaton avatar zoeyr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

evcxr's Issues

Mac OS support

In the unlikely event that it already works on Mac OS, please let me know.

If you'd like to work on this, feel free to reach out with any questions. I'm not really sure what will be involved, since I don't know what the problems will be.

automatically make attributes pub ?

Seem like you already detect when fields of structs are not pub, with the error message:

Items currently need to be explicitly made pub along with all fields of structs.

Could it be possible with syn to rewrite the AST and add pub automatically ?

Incremental computing: Adapton?

I'm curious if you have seen the Adapton project? It could be a way to help optimize a notebook.

Apologies if this isn't the right way to provide suggestions; I didn't see a mailing list or other community information.

Puzzling use of private type in generated code

>> :dep regex = "1.0"
>> let rx = regex::Regex::new(r"(\d+)=(\w+)").unwrap();
A compilation error was found in code we generated.
Ideally this should't happen. Type :last_error_json to see details.
error[E0603]: module `re_unicode` is private
  --> src/lib.rs:14:37
   |
14 | evcxr_variable_store.put_variable::<regex::re_unicode::Regex>(stringify!(rx), rx);
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^^

Edit: the problem must come from regex::Regex being a pub re-export of this type.

Support destructuring assignment

It would be nice to support destructuring assignment, eg. unpacking a tuple. Currently, attempt to do it results in Unhandled pat kind:

# use std::sync::mpsc::channel;
# let (tx, rx) = channel::<i32>();
Unhandled pat kind: Tuple(PatTuple { paren_token: Paren, front: [Ident(PatIdent { by_ref: None, mutability: None, ident: Ident(tx), subpat: None }), Comma, Ident(PatIdent { by_ref: None, mutability: None, ident: Ident(rx), subpat: None })], dot2_token: None, comma_token: None, back: [] })

Allow customizing format output

I often want to sanity check some math or similar, and evcxr_repl works wonderfully for this for the most part (previously I had been using lldb/gdb for this which works about as well as you might imagine...).

Unfortunately, if doing bitwise math, I often want to see hex output. Doing so requires outputting something like format!("{:x}", <expression I want to check>); each time, which is tedious.

Taking a look at the source, it seems somewhat tricky since you don't know the type in advance, but one (somewhat hacky) option would be something like allowing specifying a list of formatting options to try, which would be used here, or something. e.g. if I set :fmt ["{:x}", "{:?}"] (or whatever), then the system would try {:x} followed by {:?} for things where evcxr_display doesn't apply.

That said, I'm flexible and willing to accept something that requires annotating things manually if the above solution is undesirable for some reason.

Using local dependencies

We should add external dependencies with the :dep keyword.

However, how can one run a local crate? I tried starting jupyter notebook from my crate directory, yet it wasn't able to find my crate.

Optimization (release mode) absent

With the following kernel:

Server Information:

You are using Jupyter notebook.

The version of the notebook server is: 5.7.0
The server is running on this version of Python:

Python 3.6.6 |Anaconda, Inc.| (default, Oct  9 2018, 12:34:16) 
[GCC 7.3.0]

both in SoS and running bare, I cannot replicate the performance of optimized Rust code outside of the notebook. In particular, I've been running the following in a Jupyter cell:

:opt
:dep zip = "0.5.0"

#[derive(Debug, Clone, Copy)]
pub struct CompressionResult {
    pub dt: f64,
    pub MBps: f64,
    pub shrink: f64
}

impl CompressionResult {
    pub fn new(dt: f64, MBps: f64, shrink: f64) -> CompressionResult {
        CompressionResult { dt, MBps, shrink }
    } 
    pub fn from(dt: f64, old_size: u64, new_size: u64) -> CompressionResult {
        let MBps = ((old_size as f64)/(1024.0*1024.0))/dt;
        let shrink = (new_size as f64)/(old_size as f64);
        CompressionResult {
            dt: (dt*1000.).round()/1000.,
            MBps: (MBps*100.).round()/100.,
            shrink: (shrink*1000.).round()/1000.
        }
    }
}

let compression_source = "speed.log";
let compression_target = "speed-rust.zip";

pub fn compress_the_target(cs: &str, ct: &str) -> CompressionResult {
    use std::*;
    use std::io::Write;
    let source_p = path::Path::new(cs);
    let target_p = path::Path::new(ct);
    if target_p.exists() { fs::remove_file(target_p); }
    let data = fs::read(source_p).unwrap();
    let t0 = time::Instant::now();
    {
        let target = fs::File::create(target_p).unwrap();
        let mut zw = zip::ZipWriter::new(io::BufWriter::with_capacity(65536, target));
        zw.start_file(
            source_p.file_name().unwrap().to_str().unwrap(),
            zip::write::FileOptions::default().compression_method(
                zip::CompressionMethod::Deflated
            )
        );
        zw.write(data.as_ref());
        zw.finish();
    }
    let elapsed = {
        let d = t0.elapsed();
        (d.as_secs() as f64) + (d.subsec_nanos() as f64)/1e9
    };
    let old_size = fs::metadata(source_p).unwrap().len();
    let new_size = fs::metadata(target_p).unwrap().len();
    CompressionResult::from(elapsed, old_size, new_size)
}

println!("{:?}", compress_the_target(compression_source, compression_target));

and getting 20x worse results than the equivalent code run externally with cargo run --release, and roughly equivalent to cargo run.

It makes no difference whether or not I leave off :opt.

(The file speed.log can be any ~10 MB file that isn't just noise. Note also that the zip crate has mediocre performance even when optimized compared to e.g. zip on the command-line, but the slowdown here is far more.)

Support interruption

As far as I can see, the actual code is run in a subprocess, so it could be killed and reinitialised when an interrupt_request is received.

Add tab completion

Probably by integrating with RLS, although I'm open to other ideas if anyone has any.

Failed to build

error: failed to run custom build command for `zmq-sys v0.8.3`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installo751eq/release/build/zmq-sys-38aba20ccedde92d/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'Unable to locate libzmq:
Failed to run `"pkg-config" "--libs" "--cflags" "libzmq >= 3.2"`: No such file or directory (os error 2)', /home/omar/.cargo/registry/src/github.com-1ecc6299db9ec823/zmq-sys-0.8.3/build.rs:31:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: failed to compile `evcxr_jupyter v0.3.4`, intermediate artifacts can be found at `/tmp/cargo-installo751eq`

However

libzmq3-dev it's already installed (4.3.1-4).

Any thoughts on this?

Document how to make evcxr a rust jupyter kernel on Mac OS X

I confirm evcxr_jupyter works on my mac box. But I spent more time than expected to make it work because I couldn't find any relevant documentation.

Below is what should be added to the docs.

$ brew install zmq
$ evcxr_jupyter --install
Writing /Users/CC/Library/Application Support/jupyter/kernels/rust/kernel.json
Installation complete
$ jupyter  kernelspec install ~/Library/Application\ Support/jupyter/kernels/rust
[InstallKernelSpec] Removing existing kernelspec in /usr/local/share/jupyter/kernels/rust
[InstallKernelSpec] Installed kernelspec rust in /usr/local/share/jupyter/kernels/rust

Windows support

In the unlikely event that it already works on Windows, please let me know.

If you'd like to work on this, feel free to reach out with any questions. I'm not really sure what will be involved, since I don't know what the problems will be.

thread '<unnamed>' panicked at 'Variable 'v' has gone missing'

Test case to reproduce:

#[test]
fn variable_assignment_compile_fail_then_use_statement() {
let mut e = new_context();
assert!(e.eval(stringify!(let v = foo();)).is_err());
eval!(e, use std::collections::HashMap;);
assert_eq!(eval!(e, 42), text_plain("42"));
}

Bad code generation after an integer overflow

Hi.

It seems this particular overflow causes the repl to always generate wrong code on subsequent expression:

$ evcxr
Welcome to evcxr. For help, type :help
>> 10u8.pow(5)
thread '<unnamed>' panicked at 'attempt to multiply with overflow', /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libcore/num/mod.rs:3686:24
stack backtrace:
⋮
Child process terminated with status: exit code: 101
>> 1
A compilation error was found in code we generated.
Ideally this should't happen. Type :last_error_json to see details.
error: linking with `cc` failed: exit code: 1
⋮

Jupyter - Kernel not starting / connecting

I am on Debian Stretch (on a server) and running jupyterhub.
The kernel is detected and I can create rust notebooks, but the kernel won't start.

The debug log is not very helpful for me and I dont get the purpose of the random ports:

[D 2019-04-16 20:27:51.406 SingleUserNotebookApp manager:257] Starting kernel: ['/home/joshua/.cargo/bin/evcxr_jupyter', '--control_file', '/home/joshua/.local/share/jupyter/runtime/kernel-4efeab69-259f-4a47-b2e2-791c485dea1a.json']
[D 2019-04-16 20:27:51.420 SingleUserNotebookApp connect:542] Connecting to: tcp://127.0.0.1:38513
[D 2019-04-16 20:27:51.423 SingleUserNotebookApp connect:542] Connecting to: tcp://127.0.0.1:60423
[I 2019-04-16 20:27:51.426 SingleUserNotebookApp kernelmanager:164] Kernel started: 4efeab69-259f-4a47-b2e2-791c485dea1a
[D 2019-04-16 20:27:51.427 SingleUserNotebookApp kernelmanager:165] Kernel args: {'kernel_name': 'rust', 'cwd': '/home/joshua'}
Error: JustMessage("No such file or directory (os error 2)")
[D 2019-04-16 20:27:51.544 SingleUserNotebookApp zmqhandlers:300] Initializing websocket connection /user/joshua/api/kernels/4efeab69-259f-4a47-b2e2-791c485dea1a/channels
[D 2019-04-16 20:27:51.549 SingleUserNotebookApp handlers:141] Requesting kernel info from 4efeab69-259f-4a47-b2e2-791c485dea1a
[D 2019-04-16 20:27:51.550 SingleUserNotebookApp connect:542] Connecting to: tcp://127.0.0.1:60475
[I 2019-04-16 20:27:54.423 SingleUserNotebookApp restarter:110] KernelRestarter: restarting kernel (1/5), new random ports
[D 2019-04-16 20:27:54.425 SingleUserNotebookApp manager:257] Starting kernel: ['/home/joshua/.cargo/bin/evcxr_jupyter', '--control_file', '/home/joshua/.local/share/jupyter/runtime/kernel-4efeab69-259f-4a47-b2e2-791c485dea1a.json']
[D 2019-04-16 20:27:54.435 SingleUserNotebookApp connect:542] Connecting to: tcp://127.0.0.1:58567
Error: JustMessage("No such file or directory (os error 2)")
...

and the control file:

{
  "key": "5ec08ec1-91b7d026239a28cf264b8a34",
  "shell_port": 35521,
  "hb_port": 39183,
  "signature_scheme": "hmac-sha256",
  "iopub_port": 52037,
  "control_port": 57881,
  "stdin_port": 49191,
  "ip": "127.0.0.1",
  "kernel_name": "rust",
  "transport": "tcp"
}

When I run /home/joshua/.cargo/bin/evcxr_jupyter --control_file /home/joshua/.local/share/jupyter/runtime/kernel-4efeab69-259f-4a47-b2e2-791c485dea1a.json manually I don't get the Error and evcxr_jupyter seems to be running fine:

TCP localhost:39183 (LISTEN)
TCP localhost:35521 (LISTEN)
TCP localhost:57881 (LISTEN)
TCP localhost:49191 (LISTEN)
TCP localhost:52037 (LISTEN)

What am I doing wrong? Is this a timing issue (evcxr_jupyter execs before control file exists)?
Thanks in advance!
Love your project and trying hard to get it working 👍

Macros support

It seems that something is going wrong with the macros. Here is what I put in a single Jupyter cell:

#[macro_use]
extern crate serde_derive;

extern crate serde;
extern crate serde_json;

#[derive(Serialize, Deserialize, Debug)]
pub struct Point {
    pub x: i32,
    pub y: i32,
}

Output:

#[derive(Serialize, Deserialize, Debug)]
                    ^^^^^^^^^^^ 
cannot find derive macro `Deserialize` in this scope

#[derive(Serialize, Deserialize, Debug)]
         ^^^^^^^^^ 
cannot find derive macro `Serialize` in this scope

Add multiline support in the REPL

Can possibly use syn to parse what's been written and keep asking for more lines of input until syn reports that there's a complete token tree.

Alternatively, perhaps we can use a key modifier - e.g. shift+enter to execute. Perhaps need to first see what other REPLs do. Jupyter notebook uses shift+enter to execute, but then it's not a command line REPL (although jupyter-console is)

Support for crates with different library name

I tried to use the crate prettytable-rs in evcxr_jupyter, however I cannot get it to work. I think the problem is that even though the crate name is prettytable-rs, the library is only called prettytable (you use extern crate prettytable;).

Writing :dep prettytable-rs = "0.7" prints

can't find crate for `prettytable_rs`

on the terminal. Trying extern crate prettytable; results in the error

error: no matching package named `prettytable` found

being shown in the Jupyter notebook.

More idiomatic jupyter interaction

This project looks great! Two elements don’t feel Jupyter-like though:

  1. :command isn’t how things are usually done there. Instead, there’s %line-magic and %%cell-magic

  2. EVCXR_BEGIN_CONTENT is hacky. There should rather be a module that can be used to construct and publish mimebundles, and that contains a trait one can implement to have a struct displayable.

    We could introduce a standard name for a feature that %dep automatically activates in installed crates. With that feature active, crates would depend on aforementioned module and implement its trait for their most important structs.

:dep names with dashes should be replaced with underscores

Looks like there was a fix for dependencies in 38a9485

but I think Im still having trouble with top level :dep that have hyphens

:dep generic_array = { git = "https://github.com/fizyk20/generic-array"}
extern crate generic_array;
error: no matching package named `generic_array` found

Prompt Characters

Currently adding support for evcxr within emacs,
I wanted to request that a prompt is added in the repl.
>> || evcxr > || ~~
This will simplify the prompt-regex parsing in order to provide a more
full experience from within emacs.
Thanks!

I keep getting libctx error every expression

When I start evcxr i get this error
Error renaming '"/tmp/.tmpv1xw2x/target/debug/deps/libctx.so"' to '"/tmp/.tmpv1xw2x/target/debug/deps/libcode_1.so"': No such file or directory (os error 2)

But it also happens after every expression put in the repl

How to load crate by path?

In Cargo.toml, one can specify dependencies by path:
hello_utils = { path = "hello_utils" }

But this seems not working in repl.

:dep hello_utils = { path = "hello_utils" }

will cause an error.

How does one take interactive input?

let mut a = String::new();
use std::io;
io::stdin().read_line(&mut a)
        .expect("Failed to read line");

This code never finishes compilation.
Ideal behaviour: A text field must pop open for user input.

Relative path dependency on Windows not working

I'm having trouble loading a relative path dependency on Windows. The cell looks like this:

:dep num = "^0.2.0"
:dep num-complex = "^0.2.3"
:dep organic-snout = { path = ".." }
:dep plotters = { git = "https://github.com/38/plotters", default_features = false, features = ["evcxr"] }

And the output is:

Compilation failed, but no parsable errors were found. STDERR:
error: failed to parse manifest at `C:\Users\ANDREW~1\AppData\Local\Temp\.tmpxYNfAx\Cargo.toml`

Caused by:
  could not parse input as TOML

Caused by:
  invalid escape character in string: `C` at line 25

STDOUT:

I've verified that the organic-snout dependency is the one causing the problem. If I comment it out, the cell evaluates cleanly.

If I go and look at the Cargo.toml that the error message refers to, it looks like this:

[package]
name = "ctx"
version = "1.0.0"
edition = "2018"

[lib]
crate-type = ["cdylib"]

[profile.dev]
opt-level = 2
debug = false
rpath = true
lto = false
debug-assertions = true
codegen-units = 16
panic = 'unwind'
incremental = true
overflow-checks = true

[dependencies]
num = "^0.2.0"
num-complex = "^0.2.3"
plotters = { git = "https://github.com/38/plotters", default_features = false, features = ["evcxr"] }
organic-snout = { path = "\\?\C:\Users\Andrew Watts\Projects\organic-snout" }

I'm not sure what that goofiness is at the beginning of the path, but clearly Cargo is confused by it, too.

Broken on recently nightly compiler versions

Looks like it's been broken for at least 10 days, but I didn't have build failure notifications set up so didn't notice. Will be adding a notification to the Travis config.

Seems that the formatting of type errors has changed in rustc. Still assessing what needs to change to cover everything.

Something is wrong with the globals

I'm new to Rust, but it looks as if something is not right with the globals:
image
I understand that globals do not exist in rust per se, but mut statics behave the same way:
image

evcxr_repl install fails

When I run

cargo install evcxr_repl

on my Mac running High Sierra version 10.13.6, the build fails with

error[E0046]: not all trait items implemented, missing: `description`
   --> /Users/alan/.cargo/registry/src/github.com-1ecc6299db9ec823/evcxr-0.1.2/src/errors.rs:314:1
    |
314 | impl std::error::Error for Error {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `description` in implementation
    |
    = note: `description` from trait: `fn(&Self) -> &str`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0046`.
error: failed to compile `evcxr_repl v0.1.2`, intermediate artifacts can be found at `/var/folders/9t/_qss6y9544v29s4y30lkz5jr0000gn/T/cargo-install5FRvBt`

Caused by:
  Could not compile `evcxr`.

To learn more, run the command again with --verbose.

I am running

cargo 1.26.0-nightly (008c36908 2018-04-13)

One clue to the problem is that I am using the Failure crate, which has its own Error trait.

Support relative paths for `:dep` command

It would be nice if the :dep command would handle relative path dependencies. The problem is that cargo is not invoked in the same directory as evcxr, thus a command like :dep foo = { path = "../foo" } will fail.
Maybe also a support for paths starting with ~/ could be added.

Support of Jupyter Lab

Hi,

The kernel doesn't seems to work with Jupyter Lab (0.34.12): I mean sometimes I have response for printlnl!("..."); but often no response.

I started to investigate (I open the ticket to inform about the issue, and my progress).

After reading jupyterlab/jupyterlab#470 I noticed some similarities. I try to add status: idle after every shell request, and that seems to fix the issue about println! and lot of kernel_info_request. But not with the support of evcxr_display. I plan to check the protocol 5.x implementation and to make PR asap.

PS: It's my first day with Jupyter Lab and the kernel / client api.

How do I handle crate and package name mismatches in REPL?

Example: prettytable-rs.

$ evcxr 
Welcome to evcxr. For help, type :help
>> extern crate prettytable;
error: no matching package named `prettytable` found
>> extern crate prettytable_rs;
error: no matching package named `prettytable_rs` found
>> :dep prettytable-rs = "*"
(waiting)
can't find crate for `prettytable_rs`
>> extern crate prettytable;
error: no matching package named `prettytable` found

Changing Rust version/channel

How can I run the jupyter kernel on nightly?

I tried installing it using a different channel, but it won't stick to the one I used.

Also tried downloading locally the repository and installing from there, no success either.

Closure problems and 'pub' needed

When the expression is not started with pub, then it will just show the warning. How about we default make it as 'pub' visibility?

When the expression is closure function, it will show the error "unknown start of token: " and any expression later will be the same error.

tim 20190305115358

Build broken due to upstream change in backtrace

Compiling backtrace-sys v0.1.26
....
Compiling backtrace v0.3.9

error[E0308]: mismatched types
--> .../.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.9/src/symbolize/libbacktrace.rs:154:60
|
154 | STATE = bt::backtrace_create_state(ptr::null(), 0, error_cb,
| ^^^^^^^^ expected enum libc::c_void, found enum std::ffi::c_void
|
= note: expected type extern "C" fn(*mut libc::c_void, *const i8, i32)
found type extern "C" fn(*mut std::ffi::c_void, *const i8, i32) {symbolize::libbacktrace::error_cb}

Looks like depending on a old version of backtrace no longer compiles.

Fix coming soon...

Speed feels slow

Compared to a Python Notebook, the speed feels slow. Running :timing, each block execution even for simple code is 5 to 10 seconds, and extern crate is really slow.
I was hoping for something like notebook driven development like you can do in Python, but the speed doesn't seem to allow me to do so.

Implementing evcxr_display fails on nightly

See: plotters-rs/plotters#6

The example given in the readme fails with the following error:

error[E0308]: mismatched types
  --> src/lib.rs:21:60
   |
21 | evcxr_variable_store.put_variable::<String>(stringify!(m), m);
   |                                                            ^ expected struct `std::string::String`, found struct `user_code_0::Matrix`
   |
   = note: expected type `std::string::String`
              found type `user_code_0::Matrix<{integer}>`

error[E0277]: the trait bound `user_code_0::Matrix<{integer}>: std::marker::Copy` is not satisfied
  --> src/lib.rs:22:22
   |
22 | evcxr_variable_store.assert_copy_type(m);
   |                      ^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `user_code_0::Matrix<{integer}>`

error: aborting due to 2 previous errors
$ rustc --version
rustc 1.37.0-nightly (37d001e4d 2019-05-29)

Evcxr has a problem with raw identifiers which are also keywords, e.g., `async`

With the Rust Edition 2018 new keywords were added and the raw identifier syntax was added to allow using keywords as identifiers.
One of the new keywords is async which is also used in real code, for example reqwest::async::Client.

This small example

pub mod q {
    pub mod r#async {
        pub struct X;
    }
}
let abc = q::r#async::X;

results in this error message:

expected identifier, found reserved keyword `async`

In the error json it can be seen that evcxr emits the path to the type X but without using any raw identifiers thus the error message about the keyword.
evcxr_variable_store.put_variable::<q::async::X>(stringify!(abc), abc);

One solution might be to always use the raw identifiers when emitting types even if not strictly necessary.

last_error_json
{
  "rendered": "error: expected identifier, found reserved keyword `async`\n  --> src/lib.rs:93:40\n   |\n93 | evcxr_variable_store.put_variable::<q::async::X>(stringify!(abc), abc);\n   |                                        ^^^^^ expected identifier, found reserved keyword\nhelp: you can escape reserved keywords to use them as identifiers\n   |\n93 | evcxr_variable_store.put_variable::<q::r#async::X>(stringify!(abc), abc);\n   |                                        ^^^^^^^\n\n",
  "children": [
    {
      "children": [],
      "code": null,
      "level": "help",
      "message": "you can escape reserved keywords to use them as identifiers",
      "rendered": null,
      "spans": [
        {
          "byte_end": 3140,
          "byte_start": 3135,
          "column_end": 45,
          "column_start": 40,
          "expansion": null,
          "file_name": "src/lib.rs",
          "is_primary": true,
          "label": null,
          "line_end": 93,
          "line_start": 93,
          "suggested_replacement": "r#async",
          "suggestion_applicability": "MaybeIncorrect",
          "text": [
            {
              "highlight_end": 45,
              "highlight_start": 40,
              "text": "evcxr_variable_store.put_variable::<q::async::X>(stringify!(abc), abc);"
            }
          ]
        }
      ]
    }
  ],
  "code": null,
  "level": "error",
  "message": "expected identifier, found reserved keyword `async`",
  "spans": [
    {
      "byte_end": 3140,
      "byte_start": 3135,
      "column_end": 45,
      "column_start": 40,
      "expansion": null,
      "file_name": "src/lib.rs",
      "is_primary": true,
      "label": "expected identifier, found reserved keyword",
      "line_end": 93,
      "line_start": 93,
      "suggested_replacement": null,
      "suggestion_applicability": null,
      "text": [
        {
          "highlight_end": 45,
          "highlight_start": 40,
          "text": "evcxr_variable_store.put_variable::<q::async::X>(stringify!(abc), abc);"
        }
      ]
    }
  ]
}

[feature request] sccache compatibility

Hello, first I'd like to thank you for this project!


This issue is a feature request that would make the usages of cargo commands compatible with the sccache (caching for compilation).

I'm using your rust integration for jupyter labs, and I have confirmed that after installing https://github.com/mozilla/sccache (via cargo install sccache) and setting export RUSTC_WRAPPER=sccache before starting jupyter, the compilation calls indeed are sent to sccache - but for some reason they can't be cached - observed via watch sccache --show-stats.

I think the kernel restarting should not be a problem for sccache, since cargo clean on normal projects still benefit from sccache, and also regarding normal projects, different projects (different name on different paths) also benefit from the caching of external libraries from other projects.

I also tried manually running cargo rustc -- -C prefer-dynamic --error-format json on /tmp/.tmpza75ej/evcxr_meta_module and also on other user_code_x directories and they appear to use scchache correctly.

But somehow, when jupyter asks for it's execution, they fall as "Non-cacheable calls" on the sccache stats and thus are never cached. I don't know what is causing this behaviour.

Here's a rust-specific info from sccache: https://github.com/mozilla/sccache/blob/master/docs/Rust.md
If you'd like more info, please let me know!

I think compilation caching could be very welcome for the rust+jupyter use-case, since the initial compilation duration is quite apparent whenever a couple of crates are used.
Since the same target directory is being used for every cell from the same notebook, there is already some standard caching. But if evcxr were compatible with scchache, I think it'd be a boost for first-runs and also for the multi-notebook case.

Access denied on windows

I'm using v.0.4.1 on Windows 10. Here's what I get:
image
I tried deleting this file manually - also "access denied", used by evcxr_jupyter.exe. Also it has 2 hardlinks, if it matters.
cargo build in C:\Users\ASUS\AppData\Local\Temp\.tmpRMignQ works ok.

Windows build error

  = note: libzmq-50f4a406b22aace0.rlib(zmq-50f4a406b22aace0.zmq.adwk1sko-cg
u.4.rcgu.o) : error LNK2019: unresolved external symbol __imp_zmq_msg_gets
referenced in function _ZN3zmq7message7Message4gets17h7fa806d7747a2351E
          libzmq-50f4a406b22aace0.rlib(zmq-50f4a406b22aace0.zmq.adwk1sko-cg
u.0.rcgu.o) : error LNK2019: unresolved external symbol __imp_zmq_proxy_ste
erable referenced in function _ZN3zmq15proxy_steerable17h28199adb82db8604E
          libzmq-50f4a406b22aace0.rlib(zmq-50f4a406b22aace0.zmq.adwk1sko-cg
u.0.rcgu.o) : error LNK2019: unresolved external symbol __imp_zmq_has refer
enced in function _ZN3zmq3has17h8a1799c5696eeb89E
          C:\Documents\rust\evcxr\target\debug\deps\evcxr_jupyter-04a8e2112
da4bb74.exe : fatal error LNK1120: 3 unresolved externals

I'm on Windows 10, first tried to cargo install evcxr-jupyter, got an error described here, then cloned the master branch and trying to build it.
I've installed ZeroMQ 4.0.4 via installer, renamed lib and dll files as recommended and added .dll dir to PATH.

Expose special `:` commands to Jupyter

I love this project and it already works surprisingly well.

So far only :vars is documented to be used in a Jupyter notebook. However, all the other special :-commands also work and are quite useful. But :vars is the only command shown in the Jupyter notebook, all the others only print to the terminal.
It would be great if the other commands would also show their output in the Jupyter notebook, e.g., to see the output of :help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.