Add dont_write_bytecode flag

This commit is contained in:
Aviv Palivoda committed 2019-07-24 20:28:24 +03:00
1 parent 7d2a7a54b2
commit db8de563ba
3 files changed
+17 -1

No files matched your search

+11
View File
@@ -84,6 +84,11 @@ fn parse_arguments<'a>(app: App<'a, '_>) -> ArgMatches<'a> {
.short("S")
.help("don't imply 'import site' on initialization"),
)
.arg(
Arg::with_name("dont-write-bytecode")
.short("B")
.help("don't write .pyc files on import"),
)
.arg(
Arg::with_name("ignore-environment")
.short("E")
@@ -171,6 +176,12 @@ fn create_settings(matches: &ArgMatches) -> PySettings {
settings.quiet = true;
}
if matches.is_present("dont-write-bytecode")
|| (!ignore_environment && env::var_os("PYTHONDONTWRITEBYTECODE").is_some())
{
settings.dont_write_bytecode = true;
}
settings
}
+2 -1
View File
@@ -88,6 +88,7 @@ impl SysFlags {
flags.ignore_environment = settings.ignore_environment;
flags.verbose = settings.verbose;
flags.quiet = settings.quiet;
flags.dont_write_bytecode = settings.dont_write_bytecode;
flags
}
}
@@ -322,7 +323,7 @@ settrace() -- set the global debug tracing function
"path_hooks" => ctx.new_list(vec![]),
"path_importer_cache" => ctx.new_dict(),
"pycache_prefix" => vm.get_none(),
"dont_write_bytecode" => vm.new_bool(true),
"dont_write_bytecode" => vm.new_bool(vm.settings.dont_write_bytecode),
"setprofile" => ctx.new_rustfunc(sys_setprofile),
"settrace" => ctx.new_rustfunc(sys_settrace),
"version" => vm.new_str(version::get_version()),
+4
View File
@@ -90,6 +90,9 @@ pub struct PySettings {
/// -q
pub quiet: bool,
/// -B
pub dont_write_bytecode: bool,
/// Environment PYTHONPATH and RUSTPYTHONPATH:
pub path_list: Vec<String>,
}
@@ -122,6 +125,7 @@ impl Default for PySettings {
ignore_environment: false,
verbose: 0,
quiet: false,
dont_write_bytecode: false,
path_list: vec![],
}
}