summaryrefslogtreecommitdiffstats
path: root/flit/_get_dirs.py
blob: 9a80e63a78f00ff82fc8d5ac0e0b2efb54ba63b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""get_dirs() is pulled out as a separate file so we can run it in a target Python.
"""
import os
import sys
import sysconfig

def get_dirs(user=True):
    """Get the 'scripts' and 'purelib' directories we'll install into.

    This is now a thin wrapper around sysconfig.get_paths(). It's not inlined,
    because some tests mock it out to install to a different location.
    """
    if user:
        if (sys.platform == "darwin") and sysconfig.get_config_var('PYTHONFRAMEWORK'):
            return sysconfig.get_paths('osx_framework_user')
        return sysconfig.get_paths(os.name + '_user')
    else:
        # The default scheme is 'posix_prefix' or 'nt', and should work for e.g.
        # installing into a virtualenv
        return sysconfig.get_paths()


if __name__ == '__main__':
    import json
    user = '--user'in sys.argv
    dirs = get_dirs(user)
    json.dump(dirs, sys.stdout)