Running OL3 dev environment under win32 #427

kalbermattenm opened this Issue Mar 24, 2013 · 10 comments


None yet

3 participants


I just tried to run the OL3 environment under Windows 32 and followed the instructions of

All my requirements are installed at non-standard places (not in C:\Program Files), but all the necessary PATH variables are set correctly.

In the file, you define everything with absolute paths if the system is win32, but I don't get why...

If win32 users follow the wiki instructions, everything is working like a charm without having to define all these absolute paths. For the test, I just did get rid of two if conditions in (see lines and

I am now able to run serve and check without any errors.

I am not an expert, so maybe did I miss something, but is there a reason for having all these absolute paths defined in if sys.platform == 'win32'?

twpayne commented Mar 24, 2013

The reasons for defining absolute paths on Windows are:

  • the required binaries (python.exe, git.exe, etc.) are not always in the user's PATH; it sounds like you've configured your PATH correctly, but not everybody does
  • the paths vary a lot according to the Windows version and native language

That said, although I wrote this part of, I've haven't really used Windows for over a decade. It might well be possible to trim down the logic. However, I think it's important that build continues to work even if PATH is not configured correctly.


I know that I might be the only weirdo trying that on Windows ;-)

I agree with you regarding your last sentence, but on Windows, you can install stuff in about all folders / devices (like installing stuff in My Documents, which is really bad, but...)

What's more, the version of Phantomjs you defined in can not be downloaded anymore (see

I don't know if it's of any interest, but I added these lines at the top of my file and, in the same file I suppressed lines to The which() function can be found here:

It looks like this is working (not intensively tested...).

Sorry to annoy you with my Ballmer issues ;-)

def which(program):
    import os
    def is_exe(fpath):
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath, fname = os.path.split(program)
    if fpath:
        if is_exe(program):
            return program
        for path in os.environ["PATH"].split(os.pathsep):
            path = path.strip('"')
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file
    return None

if sys.platform == 'win32':

    windows_defaults = {
    'ProgramFiles': os.environ['PROGRAMFILES'],
    'Python27': os.environ.get('SystemDrive', 'C:') + '\\Python27',
    'jsdoc': os.environ.get('SystemDrive', 'C:') + '\\jsdoc3',
    'phantomjs': os.environ.get('SystemDrive', 'C:') + '\\phantomjs-1.9.0-windows'

    if which('git.exe'):
        variables.GIT = 'git'
        variables.GIT = os.path.join(windows_defaults['ProgramFiles'],
                                     'Git', 'bin', 'git.exe')

    if which('gjslint.exe'):
        variables.GJSLINT = 'gjslint'
        variables.GJSLINT = os.path.join(windows_defaults['Python27'],
                                         'Scripts', 'gjslint.exe')

    if which('java.exe'):
        variables.JAVA = 'java'
        variables.JAVA = os.path.join(windows_defaults['ProgramFiles'],
                                      'Java', 'jre7', 'bin', 'java.exe')

    if which('jsdoc.cmd'):
        variables.JSDOC = 'jsdoc.cmd'
        variables.JSDOC = os.path.join(windows_defaults['jsdoc'],

    if which('python.exe'):
        variables.PYTHON = 'python'
        variables.PYTHON = os.path.join(windows_defaults['Python27'],

    if which('phantomjs.exe'):
        variables.PHANTOMJS = 'phantomjs'
        variables.PHANTOMJS =  os.path.join(windows_defaults['phantomjs'],
twpayne commented Mar 24, 2013

Many thanks for this @kalbermattenm ! This is a much better solution than the existing code.

Windows support is important - for example, all the Cesium developers use Windows, so Windows support is critical for good Cesium/ol3 integration.

Would you like to turn this into a pull request? The which function should go in, the rest of the code should modify of course.


Maybe it would be good to improve Windows support. I'll be happy to help and submit a PR.

Two last questions:

  • Seems have to fill in the CLA form, right?
  • I currently tested serve and check. Are there other commands I should / could test?

I would also like to test the whole thing on Windows 7 64-bits (currently I tested this stuff on Windows XP 32-bits), so it might take a few days before I submit anything...

twpayne commented Mar 24, 2013


Yes, please submit a CLA. You can do it online, and it takes less than a minute.

As an extra check, you can try running integration-test, but go grab a coffee while it runs!


Just out of curiosity, would 858574b (included in #335) detect that your setup is fine? That particular commit also includes the which from SO.


Thanks @marcjansen for spotting that! I did not see that one. I'll check if 858574b is helping in any way before spending too much time in a brand new solution...


@marcjansen, this actually detects the setup really quite well.

As some of these are defined using absolute paths in the current file, your checker tells me that there are some problems (see result hereunder). On purpose, I didn't install Phantomjs and gjslint (jsdoc is installed elsewhere, but that is the absolute path issue)...

But I find your checker really good, nice job!

Would it be coherent to put the which() function into as @twpayne suggested, to improve the if sys.platform == win32 section and to integrate our checker ?

I think that with such tools, anyone should be able to run correctly...

C:\travail\git_openlayers3>python checkdeps
Program "C:\Program Files (x86)\Git\bin\git.exe" seems to be present.
Program "C:\Python27\Scripts\gjslint.exe" seems to be MISSING.
Program "C:\Program Files (x86)\Java\jre7\bin\java.exe" seems to be present.
Program "jsdoc" seems to be present.
Program "C:\Python27\python.exe" seems to be present.
Program "build/phantomjs-1.8.1-windows/phantomjs.exe" seems to be MISSING.
For certain targets all above programs need to be present.

Yes, please go ahead and do as @twpayne suggested:

  • which into
  • using it in the win32 section

Thanks for this. If eventually #335 becomes obsolete, I wouldn't mind.

twpayne commented Apr 4, 2013

This is being addressed in #448.

@twpayne twpayne closed this Apr 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment