1 ################################################################################
3 # pypy.cygclass - functions for installing PyPy modules
5 # Part of cygport - Cygwin packaging application
6 # Copyright (C) 2006-2020 Cygport authors
7 # Provided by the Cygwin project <https://cygwin.com/>
9 # cygport is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # cygport is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with cygport. If not, see <https://www.gnu.org/licenses/>.
22 ################################################################################
24 #****ih* Cygclasses/pypy.cygclass
28 # PyPy is an alternative implementation of the Python general-purpose
29 # interpreted programming language which includes a Just-In-Time compiler.
30 # It is mostly compatible with Python 2.7 and most pure Python programs and
31 # libraries; support for C extensions is experimental.
33 # This cygclass provides definitions and some install helpers which can be used
34 # by any PyPy-based package. PyPy modules and programs are built in a number
35 # of ways, so this cygclass does not provide any build functions. The two
36 # most common build systems for PyPy packages are Distutils and autotools.
38 # pypy-distutils.cygclass
43 # cross-compiling is not (yet?) supported
44 __cross_compiling_error
48 #****id* pypy.cygclass/PYPY
50 # Absolute path to the PyPy interpreter.
54 #****id* pypy.cygclass/PYPY_VERSION
56 # The major.minor version of the current PyPy interpreter.
58 PYPY_VERSION=$(${PYPY} -c 'from distutils.sysconfig import * ; print get_python_version();')
60 #****id* pypy.cygclass/PYPY_INCLUDEDIR
62 # Path containing the PyPy C library headers.
64 PYPY_INCLUDEDIR=$(${PYPY} -c 'from distutils.sysconfig import * ; print get_python_inc();')
66 #****id* pypy.cygclass/PYPY_SITELIB
68 # Installation path for all PyPy extension modules.
70 PYPY_SITELIB=$(${PYPY} -c 'from distutils.sysconfig import * ; print get_python_lib(0,0);')
72 #****id* pypy.cygclass/LIBPYPY
74 # Link flags for the PyPy import library. This definition must be properly quoted.
76 LIBPYPY="-L${PYPY_SITELIB%/*}/lib/python${PYPY_VERSION}/config -lpython${PYPY_VERSION}"
78 DEPS_PATH+=":${PYPY_SITELIB%/*}/bin"
80 #****iI* pypy.cygclass/pypyinto
82 # pypyinto SUBDIRECTORY
84 # Subdirectory of PYPY_SITELIB into which dopypy should install. This is
85 # usually unnecessary.
90 error "pypyinto accepts exactly one argument";
94 /*) error "pypyinto argument should be only a subdirectory" ;;
100 #****iI* pypy.cygclass/dopypy
102 # [pypyinto SUBDIRECTORY]
103 # dopypy MODULE1 [MODULE2] ...
105 # Installs the given PyPy module(s) (.py or .dll) into PYPY_SITELIB under $D,
106 # or a subdirectory thereof if pypyinto was previously called.
113 if defined _pypyinto_dir
115 pydir=${PYPY_SITELIB}/${_pypyinto_dir}
117 pydir=${PYPY_SITELIB}
126 error "dopypy: ${i}: file not found"
130 *.la|*.so) mode=0755 ;;
134 __doinstall ${mode} ${i} ${pydir} || error "dopypy ${i} failed"
138 #****iI* pypy.cygclass/pypy_optimize
140 # pypy_optimize [DIRECTORY1] [DIRECTORY2] ...
142 # Bytecode-compile all PyPy modules found in the given directories under $D.
143 # If no directories are specified, PYPY_SITELIB under $D is assumed.
145 # PyPy modules installed with distutils_install are automatically compiled,
146 # as are those installed by automake-based packages *if* they have been declared
147 # as _PYTHON files (in which case a py-compile script will be present in $S).
148 # Some automake-based packages mistakenly declare these as _DATA instead, in
149 # which case either the Makefile.am must be patched or this function called
155 for pyd in "${@:-${PYPY_SITELIB}}"
157 if [ ! -d ${D}${pyd} ]
159 error "directory ${pyd} does not exist"
162 inform "Compiling ${pyd}..."
163 ${PYPY} -m compileall -f -q -d ${pyd} ${D}${pyd}
167 #****iI* pypy.cygclass/pypy_fix_shebang
169 # pypy_fix_shebang SCRIPT [SCRIPT ...]
171 # Fixes the designated interpreter of SCRIPT to PYPY. This would be necessary
172 # if the original uses an incorrect path (e.g. /usr/local/bin) or defaults
173 # to the CPython interpreter. SCRIPT need not be prefixed by $D.
178 __fix_shebang ${PYPY} ${D}/${f#${D}}
182 readonly -f pypyinto dopypy pypy_optimize pypy_fix_shebang