Debian Codegraph @

texk/texlive/linked_scripts/pythontex/pythontex.py

raw
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 '''
5 This is the PythonTeX wrapper script. It automatically detects the version
6 of Python, and then imports the correct code from pythontex2.py or
7 pythontex3.py. It is intended for use with the default Python installation
8 on your system. If you wish to use a different version of Python, you could
9 launch pythontex2.py or pythontex3.py directly. You should also consider the
10 command-line option `--interpreter`. This allows you to specify the command
11 that is actually used to execute the code from your LaTeX documents. Except
12 for Python console content, it doesn't matter which version of Python is used
13 to launch pythontex.py; pythontex.py just manages the execution of code from
14 your LaTeX document. The interpreter setting is what determines the version
15 under which your code is actually executed.
16
17 Licensed under the BSD 3-Clause License:
18
19 Copyright (c) 2012-2026, Geoffrey M. Poore
20
21 All rights reserved.
22
23 Redistribution and use in source and binary forms, with or without
24 modification, are permitted provided that the following conditions are met:
25 * Redistributions of source code must retain the above copyright
26 notice, this list of conditions and the following disclaimer.
27 * Redistributions in binary form must reproduce the above copyright
28 notice, this list of conditions and the following disclaimer in the
29 documentation and/or other materials provided with the distribution.
30 * Neither the name of the <organization> nor the
31 names of its contributors may be used to endorse or promote products
32 derived from this software without specific prior written permission.
33
34 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
35 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37 DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
38 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
40 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
41 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
43 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 '''
45
46
47 import sys
48 if sys.version_info.major == 2:
49 if sys.version_info.minor >= 7:
50 import pythontex2 as pythontex
51 else:
52 sys.exit('PythonTeX require Python 2.7; you are using 2.{0}'.format(sys.version_info.minor))
53 elif sys.version_info.major == 3:
54 if sys.version_info.minor >= 2:
55 import pythontex3 as pythontex
56 else:
57 sys.exit('PythonTeX require Python 3.2+; you are using 3.{0}'.format(sys.version_info.minor))
58
59 # The "if" statement is needed for multiprocessing under Windows; see the
60 # multiprocessing documentation.
61 if __name__ == '__main__':
62 pythontex.main()