FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow stdlib freeze by palaviv · Pull Request #1159 · RustPython/RustPython · GitHub

Repository navigation

Allow stdlib freeze - #1159

Merged
palaviv merged 7 commits into
RustPython:masterfrom
palaviv:freeze-stdlib
Jul 24, 2019
Merged

palaviv merged 7 commits into
RustPython:masterfrom
palaviv:freeze-stdlib

Conversation

palaviv commented Jul 20, 2019

Copy link
Copy Markdown
Contributor

As discussed in #1142.
Adding the current Lib folder increase the executable by 5MB. I would like to add this to the demo so it will support python stdlib.
I wanted to allow specifying the location of the stdlib dir with a compilation flag but could not find out how to do that. @coolreader18 any suggestions?

palaviv requested a review from coolreader18 July 20, 2019 15:25

coolreader18 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM. An idea for allowing specifying the stdlib dir, you could maybe allow a DirFromEnv CompilationSourceKind?

Comment thread derive/src/compile_bytecode.rs Outdated

fn compile_dir(
&self,
path: &PathBuf,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
path: &PathBuf,
path: &Path,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why is this better?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

PathBuf vs Path is akin to String vs str - an owned, allocated buffer vs a slice. Like you should (almost) always prefer &str over &String, so should you for &Path over &PathBuf.

Comment thread derive/src/compile_bytecode.rs Outdated
use ::rustpython_vm::__exports::bincode;
bincode::deserialize::<::rustpython_vm::bytecode::CodeObject>(#bytes)
.expect("Deserializing CodeObject failed")
hashmap! {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You should probably add hashmap to __exports and use it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What is the purpose of the __exports? This is my first time using procedural macro

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think I understand what __exports do. Added hashmap

Copy link
Copy Markdown
Contributor

Btw, I opened this issue in pyckitup: pickitup247/pyckitup#4 they might be interested in this.

palaviv commented Jul 20, 2019

Copy link
Copy Markdown
Contributor Author

Btw, I opened this issue in pyckitup: pickitup247/pyckitup#4 they might be interested in this.

We should probably add the ability to freeze any directory.

LGTM. An idea for allowing specifying the stdlib dir, you could maybe allow a DirFromEnv CompilationSourceKind?

I can get the directory from an environment variable but I hoped for something easier.

Copy link
Copy Markdown
Member

Ah yeah, I think that's the best way to go for configuration, as Rust doesn't have anything like that built in. We've done similar configuration in env variables before, e.g. BUILDTIME_RUSTPYTHONPATH

Copy link
Copy Markdown
Member

I sorta glazed over this when I reviewed earlier, but I don't think that it should always return a HashMap, it should only do that when the source is Dir.

palaviv commented Jul 22, 2019

Copy link
Copy Markdown
Contributor Author

I sorta glazed over this when I reviewed earlier, but I don't think that it should always return a HashMap, it should only do that when the source is Dir.

I am not sure about that... I prefer that py_compile_bytecode will return the same type on all cases. I think it will be confusing otherwise.

palaviv merged commit 6ca979e into RustPython:master Jul 24, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL