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()

@@ -139,66 +139,287 @@
     
-target = os.path.dirname(sysconfig.get_config_h_filename()
+venv = os.environ.get(%22VIRTUAL_ENV%22, None)%0A    if not venv:%0A        print(%22VIRTUAL_ENV is not set.%22)%0A        sys.exit(1)%0A%0A    for dn in os.listdir(os.path.join(venv, %22include%22)):%0A        if dn.startswith(%22python%22):%0A            break%0A%0A    target = os.path.join(venv, %22include%22, dn
 )%0A%0A 

Change how fix_virtualenv detects its environment.