who seeks will always find
Decision is to run python with arg -c; make there settings and run file
Here is mine Build System file:
{
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"shell": "true",
"windows":
{
"cmd": ["D:\\Development\\Python\\Anaconda3\\python", "-c", "import sys; sys.path.insert(0, '$project_path'); exec(open('$file_name', 'r').read());"]
}
}
p.s. probably it's dangerous solution, I will be glad to look at better ways
p.p.s. for plugin sublime Repl same settings work, but should use $folder and $file_basename:
BrowsePackages -> SublimeREPL\config\Python\Main.sublime-menu
{...
"cmd": ["D:\\Development\\Python\\Anaconda3\\python", "-i", "-c", "import sys; sys.path.insert(0, '$folder'); exec(open('$file_basename', 'r').read());"],
...
}
-----------------------------------------------------------------------------------------------------------------------------------
six months later
-----------------------------------------------------------------------------------------------------------------------------------
Found better decisions:
1) build system have option 'env'
first idea is to write "env": {"PYTHONPATH": "$project_path"},
but it don't know such variable $project_path for env opt, so this works
{
"working_dir": "$project_path",
"env": {"PYTHONPATH": "."},
"cmd": ["D:\\Development\\Python\\Anaconda3\\python", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
disadvantages: incorrect working_dir - if you create or read files - should consider it
2) better way is to use some commands in cmd:
{
"windows":
{
"shell": "true",
"cmd":"set PYTHONPATH=$project_path & D:\\Development\\Python\\Anaconda3\\python -u $file",
},
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
}
3) add PYTHONPATH to mine_proj.sublime-project with plugin
"environment settings"
use there real path or %project_path% (.sublime project stores in project, to use %project_path% turn on "set_sublime_variables")
EnvironmentSettings - User
{
"set_sublime_variables": true
}
mine_proj.sublime-project:
add only "settings" part
{
"build_systems":
[
{
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"name": "Anaconda Python Builder",
"selector": "source.python",
"shell_cmd": "\"python\" -u \"$file\""
}
],
"settings":
{
"env":
{
"Windows":
{
"PYTHONPATH": "%project_path%"
},
}
},
"folders":
[
{
"path": "."
}
]
}