| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #!C:\Users\admin\source\repos\Snips_SmallTalk2\Snips_SmallTalk2\env\Scripts\python.exe
- """Mypyc command-line tool.
- Usage:
- $ mypyc foo.py [...]
- $ python3 -c 'import foo' # Uses compiled 'foo'
- This is just a thin wrapper that generates a setup.py file that uses
- mypycify, suitable for prototyping and testing.
- """
- import os
- import os.path
- import subprocess
- import sys
- import tempfile
- import time
- base_path = os.path.join(os.path.dirname(__file__), '..')
- setup_format = """\
- from distutils.core import setup
- from mypyc.build import mypycify
- setup(name='mypyc_output',
- ext_modules=mypycify([], {}, {}),
- )
- """
- def main() -> None:
- build_dir = 'build' # can this be overridden??
- try:
- os.mkdir(build_dir)
- except FileExistsError:
- pass
- opt_level = os.getenv("MYPYC_OPT_LEVEL", '')
- setup_file = os.path.join(build_dir, 'setup.py')
- with open(setup_file, 'w') as f:
- f.write(setup_format.format(sys.argv[1:], opt_level))
- # We don't use run_setup (like we do in the test suite) because it throws
- # away the error code from distutils, and we don't care about the slight
- # performance loss here.
- env = os.environ.copy()
- base_path = os.path.join(os.path.dirname(__file__), '..')
- env['PYTHONPATH'] = base_path + os.pathsep + env.get('PYTHONPATH', '')
- cmd = subprocess.run([sys.executable, setup_file, 'build_ext', '--inplace'], env=env)
- sys.exit(cmd.returncode)
- if __name__ == '__main__':
- main()
|