source: trip-planner-front/node_modules/node-gyp/gyp/gyp_main.py@ 6fe77af

Last change on this file since 6fe77af was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1#!/usr/bin/env python
2
3# Copyright (c) 2009 Google Inc. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7import os
8import sys
9import subprocess
10
11PY3 = bytes != str
12
13
14def IsCygwin():
15 # Function copied from pylib/gyp/common.py
16 try:
17 out = subprocess.Popen(
18 "uname", stdout=subprocess.PIPE, stderr=subprocess.STDOUT
19 )
20 stdout, stderr = out.communicate()
21 if PY3:
22 stdout = stdout.decode("utf-8")
23 return "CYGWIN" in str(stdout)
24 except Exception:
25 return False
26
27
28def UnixifyPath(path):
29 try:
30 if not IsCygwin():
31 return path
32 out = subprocess.Popen(
33 ["cygpath", "-u", path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
34 )
35 stdout, _ = out.communicate()
36 if PY3:
37 stdout = stdout.decode("utf-8")
38 return str(stdout)
39 except Exception:
40 return path
41
42
43# Make sure we're using the version of pylib in this repo, not one installed
44# elsewhere on the system. Also convert to Unix style path on Cygwin systems,
45# else the 'gyp' library will not be found
46path = UnixifyPath(sys.argv[0])
47sys.path.insert(0, os.path.join(os.path.dirname(path), "pylib"))
48import gyp # noqa: E402
49
50if __name__ == "__main__":
51 sys.exit(gyp.script_main())
Note: See TracBrowser for help on using the repository browser.