Magellan Linux

Annotation of /smage/trunk/include/python.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 13778 - (hide annotations) (download)
Wed Oct 30 12:46:56 2019 UTC (4 years, 6 months ago) by niro
File size: 4595 byte(s)
-sync with upstream
1 niro 3578 # $Id$
2 niro 1661
3 niro 11533 # simulate the old behavior
4     if [[ -z ${MAGE_PYTHON_EXEC} ]]
5     then
6     MAGE_PYTHON_EXEC="python"
7 niro 5216
8 niro 11533 SDEPEND="${SDEPEND}
9     >= dev-lang/python-2.7"
10     fi
11    
12 niro 13778 # call meson include in the smage2, to prevent unnecessary dependencies
13     #sminclude meson
14    
15 niro 1661 # get the major.minor current installed python version
16     # -> ex 2.4
17 niro 5863 mget-python-version()
18 niro 1661 {
19 niro 5216 local pyver
20 niro 11533 # pyver="$(${MAGE_PYTHON_EXEC} -V 2>&1 | cut -d' ' -f2 | cut -d. -f1-2)"
21     pyver=$(${MAGE_PYTHON_EXEC} -c "import sys ; print (sys.version[:3])")
22 niro 5216 [[ -z ${pyver} ]] && return 1
23     echo "${pyver}"
24 niro 1661 return 0
25     }
26 niro 1664
27 niro 5863 mget-python-libdir()
28 niro 1664 {
29     local pylib
30 niro 11533 pylib=$(${MAGE_PYTHON_EXEC} -c 'from distutils import sysconfig; print (sysconfig.get_python_lib())')
31 niro 5216 [[ -z ${pylib} ]] && return 1
32 niro 1664 echo "${pylib}"
33     return 0
34     }
35    
36 niro 5863 mget-python-includedir()
37 niro 3578 {
38     local pyinc
39 niro 11533 pyinc=$(${MAGE_PYTHON_EXEC} -c 'from distutils import sysconfig; print (sysconfig.get_python_inc())')
40 niro 5216 [[ -z ${pyinc} ]] && return 1
41 niro 3578 echo "${pyinc}"
42     return 0
43     }
44    
45 niro 5863 # fallback functions to support old smage scripts, dropped in near future
46     get_python_version()
47     {
48     echo -e "${COLYELLOW}Warning: get_python_version() is depcrecated, please use mget-python-version() instead${COLDEFAULT}" >&2
49     mget-python-version
50     }
51     get_python_libdir()
52     {
53     echo -e "${COLYELLOW}Warning: get_python_libdir() is depcrecated, please use mget-python-libdir() instead${COLDEFAULT}" >&2
54     mget-python-libdir
55     }
56     get_python_includedir()
57     {
58     echo -e "${COLYELLOW}Warning: get_python_includedir() is depcrecated, please use mget-python-includedir() instead${COLDEFAULT}" >&2
59     mget-python-includedir
60     }
61    
62 niro 1664 python_src_prepare()
63     {
64     munpack ${SRCFILE} || die
65     }
66    
67 niro 3578 python_docompile()
68 niro 1664 {
69     if [[ -e setup.py ]]
70     then
71 niro 11533 ${MAGE_PYTHON_EXEC} setup.py build $@ || die
72 niro 3578 elif [[ -e waf ]]
73     then
74 niro 11533 ${MAGE_PYTHON_EXEC} waf configure --prefix=/usr --libdir=/usr/$(mlibdir) $@ || die
75     ${MAGE_PYTHON_EXEC} waf build $@ || die
76 niro 13778 elif [[ -e meson.build ]]
77     then
78     # never run multilib builds here, multilib will be enabled by python_multilib_src_compile
79     # this honors the logic of other build methods (python, waf, autotools)
80     MULTILIB_BUILD=false meson_configure -D python=${MAGE_PYTHON_EXEC} || die
81     MULTILIB_BUILD=false mninja || die
82 niro 1664 elif [[ -e configure ]]
83     then
84 niro 11533 if [[ ${MULTILIB_BUILD} = true ]] && [[ ! -z $(typeset -f oldmconfigure) ]] && [[ ! -z $(typeset -f oldmmake) ]]
85     then
86     oldmconfigure $@ || die
87     oldmmake || die
88     else
89     mconfigure $@ || die
90     mmake || die
91     fi
92 niro 3578 elif [[ -e install.py ]]
93     then
94     echo "install.py found - nothing to compile here."
95 niro 1664 else
96     mmake || die
97     fi
98     }
99    
100 niro 3578 python_doinstall()
101 niro 1664 {
102     if [[ -e setup.py ]]
103     then
104 niro 11533 ${MAGE_PYTHON_EXEC} setup.py install --no-compile --root ${BINDIR} $@ || die
105 niro 3578 elif [[ -e waf ]]
106     then
107 niro 11533 ${MAGE_PYTHON_EXEC} waf install --destdir=${BINDIR} $@ || die
108 niro 13778 elif [[ -e meson.build ]]
109     then
110     # never run multilib builds here, multilib will be enabled by python_multilib_src_compile
111     # this honors the logic of other build methods (python, waf, autotools)
112     MULTILIB=false DESTDIR=${BINDIR} mninja install || die
113 niro 3578 elif [[ -e install.py ]]
114     then
115 niro 11533 ${MAGE_PYTHON_EXEC} install.py --prefix=/usr --files-only --destdir=${BINDIR} $@ || die
116 niro 1664 else
117 niro 11533 if [[ ${MULTILIB_BUILD} = true ]] && [[ ! -z $(typeset -f oldmconfigure) ]] && [[ ! -z $(typeset -f oldmmake) ]]
118     then
119     oldmmake DESTDIR=${BINDIR} install || die
120     else
121     mmake DESTDIR=${BINDIR} install || die
122     fi
123 niro 1664 fi
124 niro 3578 }
125 niro 1664
126 niro 3578 python_src_compile()
127     {
128     cd ${SRCDIR}
129 niro 11533 python_docompile $@ || die
130 niro 3578 }
131    
132 niro 5459 python_multilib_src_compile()
133     {
134     local abi
135     local saved_SRCDIR="${SRCDIR}"
136    
137     for abi in ${MULTILIB_ABIS}
138     do
139     SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}"
140     cd ${SRCDIR}
141 niro 11533 abi-${abi} python_docompile $@ || die
142 niro 5459 done
143     SRCDIR="${saved_SRCDIR}"
144     }
145    
146     python_src_check()
147     {
148     return 0
149     }
150    
151 niro 3578 python_src_install()
152     {
153     cd ${SRCDIR}
154 niro 11533 python_doinstall $@ || die
155 niro 3578
156 niro 1664 local i
157     for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
158     FAQ LICENSE NEWS README TODO
159     do
160     if [ -f ${SRCDIR}/${i} ]
161     then
162     minstalldocs ${i} || die
163     fi
164     done
165     }
166    
167 niro 5459 python_multilib_src_install()
168     {
169     local abi
170     local saved_SRCDIR="${SRCDIR}"
171    
172     for abi in ${MULTILIB_ABIS}
173     do
174     SRCDIR="${saved_SRCDIR}-${abi}/${SRCSUBDIR}"
175     cd ${SRCDIR}
176 niro 11533 abi-${abi} python_doinstall $@ || die
177 niro 5459
178     local i
179     for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
180     FAQ LICENSE NEWS README TODO
181     do
182     if [ -f ${SRCDIR}/${i} ]
183     then
184     oldminstalldocs ${i} || die
185     fi
186     done
187     done
188     SRCDIR="${saved_SRCDIR}"
189     }
190    
191     export_inherits python src_prepare src_check
192     if [[ ${MULTILIB_BUILD} = true ]]
193     then
194     export_inherits python_multilib src_compile src_install
195     else
196     export_inherits python src_compile src_install
197     fi