1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
3 NAMEBASE= autoselect-python
7 SDESC[standard]= Dynamic links to the latest installed python
12 SPKGS[standard]= single
14 OPTIONS_AVAILABLE= none
15 OPTIONS_STANDARD= none
18 LICENSE_FILE= ISCL:{{FILESDIR}}/LICENSE_ISC
21 SUB_FILES= autoselect.c
29 ${CP} ${WRKDIR}/*.c ${WRKSRC}
32 (cd ${WRKSRC} && ${CC} ${CFLAGS} ${LDFLAGS} -o generic autoselect.c)
33 (cd ${WRKSRC} && ${CC} ${CFLAGS} ${LDFLAGS} -o only3 only3.c)
36 .for prog in 2to3 idle pydoc python python-config
37 ${INSTALL_PROGRAM} ${WRKSRC}/generic ${STAGEDIR}${PREFIX}/bin/${prog}
39 .for prog in python3 python-config3
40 ${INSTALL_PROGRAM} ${WRKSRC}/only3 ${STAGEDIR}${PREFIX}/bin/${prog}
43 [FILE:570:descriptions/desc.single]
44 This package provides:
51 It automatically selects the latest version of python available.
52 For example, if python 2.7, 3.5, and 3.6 are all installed,
53 bin/python executes bin/python3.6 with the same arguments. If
54 python 3.6 is then deinstalled, the linkage will automatically
55 adjust to python 3.5. The python 2.7 binaries will only be
56 executed if no python 3.x packages are installed.
58 The priority check can be overridden by setting AUTOPYTHON=<python version>
59 in the environment, e.g. AUTOPYTHON=2.7.
62 [FILE:72:manifests/plist.single]
73 [FILE:742:files/LICENSE_ISC]
74 Copyright (c) 2018, The Ravenports Project.
76 Permission to use, copy, modify, and/or distribute this software for any
77 purpose with or without fee is hereby granted, provided that the above
78 copyright notice and this permission notice appear in all copies.
80 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
81 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
82 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
83 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
84 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
85 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
86 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
89 [FILE:2282:files/autoselect.c.in]
91 * This program will determine the latest version of python
92 * installed by checking %%PREFIX%%/bin/python-<x> where <x> checks
93 * all possible versions.
95 * If no version is present, an error message will be displayed,
96 * otherwise the versioned counterpart of the python command
97 * requested will be will be executed with the same arguments
98 * provided to this one. If the versioned command isn't present, an
99 * error message will be provided as a fallback.
109 main(int argc, char **argv)
114 char recommand[1024];
116 char *PYTHON_A = "%%PREFIX%%/bin/python%%ALPHA%%";
117 char *PYTHON_B = "%%PREFIX%%/bin/python%%BRAVO%%";
118 char *PYTHON_C = "%%PREFIX%%/bin/python%%CHARLIE%%";
119 char *ALPHA = "%%ALPHA%%";
120 char *BRAVO = "%%BRAVO%%";
121 char *CHARLIE = "%%CHARLIE%%";
123 override = getenv("AUTOPYTHON");
124 if (override != NULL) {
125 if (strcmp (override, ALPHA) == 0) {
127 } else if (strcmp (override, BRAVO) == 0) {
129 } else if (strcmp (override, CHARLIE) == 0) {
134 if (access(PYTHON_A, F_OK) != -1) {
136 } else if (access(PYTHON_B, F_OK) != -1) {
138 } else if (access(PYTHON_C, F_OK) != -1) {
141 /* no versions of python are installed */
142 printf ("There are no versions of python installed at %%PREFIX%%/bin\n");
148 * Get the last path element of the program name being executed
150 cmd = strrchr(argv[0], '/');
156 if (strcmp (cmd, "python-config") == 0) {
157 snprintf(recommand, 1024,
158 "%%PREFIX%%/bin/python%s-config", pyver);
159 } else if (strcmp (cmd, "2to3") == 0) {
160 snprintf(recommand, 1024,
161 "%%PREFIX%%/bin/2to3-", pyver);
163 snprintf(recommand, 1024,
164 "%%PREFIX%%/bin/%s%s", cmd, pyver);
167 execv(recommand, argv);
170 * Execution failed, so write out an error message
172 printf ("Command execution failed: %s\n", recommand);
173 printf (" arguments:");
174 for (x = 1; x < argc; x++)
175 printf (" %s", argv[x]);
181 [FILE:2086:files/only3.c.in]
183 * This program will determine the latest version of python
184 * installed by checking %%PREFIX%%/bin/python-<x> where <x> checks
185 * all possible versions of python 3.
187 * If no version is present, an error message will be displayed,
188 * otherwise the versioned counterpart of the python command
189 * requested will be will be executed with the same arguments
190 * provided to this one. If the versioned command isn't present, an
191 * error message will be provided as a fallback.
201 main(int argc, char **argv)
206 char recommand[1024];
208 char *PYTHON_A = "%%PREFIX%%/bin/python%%ALPHA%%";
209 char *PYTHON_B = "%%PREFIX%%/bin/python%%BRAVO%%";
210 char *ALPHA = "%%ALPHA%%";
211 char *BRAVO = "%%BRAVO%%";
213 override = getenv("AUTOPYTHON");
214 if (override != NULL) {
215 if (strcmp (override, ALPHA) == 0) {
217 } else if (strcmp (override, BRAVO) == 0) {
222 if (access(PYTHON_A, F_OK) != -1) {
224 } else if (access(PYTHON_B, F_OK) != -1) {
227 /* no versions of python 3 are installed */
228 printf ("There are no versions of python 3 installed at %%PREFIX%%/bin\n");
234 * Get the last path element of the program name being executed
236 cmd = strrchr(argv[0], '/');
242 if (strcmp (cmd, "python-config3") == 0) {
243 snprintf(recommand, 1024,
244 "%%PREFIX%%/bin/python%s-config", pyver);
245 } else if (strcmp (cmd, "python3") == 0) {
246 snprintf(recommand, 1024,
247 "%%PREFIX%%/bin/python%s", pyver);
249 printf ("only3 doesn't handle this file: %s\n", cmd);
253 execv(recommand, argv);
256 * Execution failed, so write out an error message
258 printf ("Command execution failed: %s\n", recommand);
259 printf (" arguments:");
260 for (x = 1; x < argc; x++)
261 printf (" %s", argv[x]);