Hi all,
I’m just curious on if I can make my .sublime-project files a bit cleaner and generic.
I’m using Windows 11 Pro and Sublime Text 4 Build 4169
I’m developing in Python 3.12.1 and am using pipenv to manage my virtual environments.
I have set the environment variable WORKON_HOME to S:/.virtualenvs
Currently, I have my files arranged as such:
S:/
- .virtualenvs/
--- test1-abcdefg/
--- test2-hijklmno/
- Projects/
--- test1/
----- test1.sublime-project
----- ...
--- test2/
----- test2.sublime-project
----- ...
I currently have S:/Projects syncing to a cloud storage location. This folder will contain other folders with simple project names (ex “test1”).
The .virtualenvs directory is for holding the virtual environment information and will have folders named as <project>-<hash> (ex “test1-abcdefg”) which is generated by pipenv automatically upon environment creation. A key note is the base project name (ex “test1”) is in the directory names of the folders found in both S:/Projects and S:/.virtualenvs.
My .sublime-project consequently currently looks like this:
{
"build_systems":
[
{
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"name": "Virtual Environment",
"selector": "source.python",
"shell_cmd": "S:/.virtualenvs/test1-abcdefg/Scripts/python.exe -u \"$file\"",
},
],
"folders":
[
{
"path": "."
},
],
"settings":
{
"SublimeLinter.linters.mypy.args":
[
"--config-file=S:/Projects/pyproject.toml",
"--python-executable=S:/.virtualenvs/test1-abcdefg/Scripts/python.exe",
],
}
}
I’d like to make the .sublime-project file a bit more generic so I don’t have to always go into each project and change the <project>-<hash> in the paths containing a virtual environment folder name. Frankly, it might let me remove the “settings” section all together by relocating that information over to the SublimeLinter settings file, but we’ll ignore that for now.
I’ll quickly mention this CLI option regarding pipenv:
S:\Projects\test1>pipenv --venv
S:\.virtualenvs\test1-abcdefg
To my knowledge - this can’t be used in a .sublime-project file, but if it could this would then be the ideal .sublime-project file for me in my opinion:
{
"build_systems":
[
{
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"name": "Virtual Environment",
"selector": "source.python",
"shell_cmd": "$(pipenv --venv)/Scripts/python.exe -u \"$file\"",
},
],
"folders":
[
{
"path": "."
},
],
"settings":
{
"SublimeLinter.linters.mypy.args":
[
"--config-file=S:/Projects/pyproject.toml",
"--python-executable=$(pipenv --venv)/Scripts/python.exe",
],
}
}
Given I’m fairly sure this is not possible I have come here to ask for advice on whatever else can be done to make something like this work to minimize the overall management of my .sublime-project files.
Any advice would be greatly appreciated!