File: fix_virtualenv.py

package info (click to toggle)
pygame-sdl2 7.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 19,408 kB
  • sloc: ansic: 9,655; python: 1,900; makefile: 10
file content (35 lines) | stat: -rw-r--r-- 710 bytes parent folder | download | duplicates (3)
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
28
29
30
31
32
33
34
35
from __future__ import unicode_literals, print_function

import os
import argparse
import sys
import shutil
import sysconfig

def main():
    target = os.path.dirname(sysconfig.get_config_h_filename())

    try:
        source = os.readlink(target)
    except:
        print(target, "is not a symlink. Perhaps this script has already been run.")
        sys.exit(1)

    tmp = target + ".tmp"

    if os.path.exists(tmp):
        shutil.rmtree(tmp)

    os.mkdir(tmp)

    for i in os.listdir(source):
        if i == "pygame_sdl2":
            continue

        os.symlink(os.path.join(source, i), os.path.join(tmp, i))

    os.unlink(target)
    os.rename(tmp, target)

if __name__ == "__main__":
    main()