Home Download Buy Blog Forum Support

Build system variables not working at all

Build system variables not working at all

Postby codemonkey on Mon Aug 06, 2012 8:07 pm

I have defined a project file that looks like this:

Code: Select all
{
    "folders":
    [
        {
            "path": "./"
        }
    ],
    "build_systems": [
        {
            "name": "Custom build system",
            "path": "./virtualenv/Scripts",
            "cmd": ["where", "python"],
            "env": {
                "PYTHONPATH": "./"
            }
        }
    ]
}


This works perfectly as long as I'm on a file in the top level directory. As soon as I descend into a child directory, the "./" paths break and I get "not found" errors. Therefore I'm trying to use the "$project_path" variable that's shown here: http://docs.sublimetext.info/en/latest/reference/build_systems.html#build-system-variables. The problem is: it doesn't work at all. I get the same "not found" errors as before.

I have tried:

Code: Select all
"path": "$project_path/virtualenv/Scripts"

Code: Select all
"path": "${project_path}/virtualenv/Scripts"

Code: Select all
"path": "${project_path}\\virtualenv\\Scripts"


and nothing works. Python.exe is still not found. I have also tried to leave "path" at the relative path and set PYTHONPATH to "$project_path", then set "cmd" to

Code: Select all
["python", "-c", "import sys;print sys.path"]


The output contains:

'C:\\Users\\Codemonkey\\Dropbox\\Astrups\\astrups.js\\$project_path'


So it's clear that in this case, "$project_path" isn't even being replaced. It probably isn't in the rest of the build system either. Why not? What am I doing wrong?
codemonkey
 
Posts: 2
Joined: Wed May 09, 2012 11:08 am

Re: Build system variables not working at all

Postby jonatascd on Wed Aug 15, 2012 1:30 am

A litlle late, but here is a solution that I used - I`ve set as build_systems inside sublime project configs.
The example.sublime-project looks like:

Code: Select all
{
"folders":
[
{
"path": "/path/to/your/project"
}
],
    "build_systems":
    [
        {
            "name": "Run Tests",
            // activate the specific virtualenv for the project
            "cmd": ["source", "/path/to/your/virtualenv/bin/activate"],
            // now indicates a different folder to run the next cmd
            "working_dir": "/path/to/to/you/django_project",
            // runs the test
            "cmd": ["python", "manage.py", "test"]
        }
    ]
}


;)
cheers
jonatascd
 
Posts: 2
Joined: Tue Aug 14, 2012 7:47 pm


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot], Yahoo [Bot] and 36 guests