1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
3 NAMEBASE= autoselect-python
8 SDESC[standard]= Dynamic links to the latest installed python
13 SPKGS[standard]= single
15 OPTIONS_AVAILABLE= none
16 OPTIONS_STANDARD= none
19 LICENSE_FILE= ISCL:{{FILESDIR}}/LICENSE_ISC
22 SUB_FILES= autoselect.c
30 ${CP} ${WRKDIR}/*.c ${WRKSRC}
33 (cd ${WRKSRC} && ${CC} ${CFLAGS} ${LDFLAGS} -o generic autoselect.c)
34 (cd ${WRKSRC} && ${CC} ${CFLAGS} ${LDFLAGS} -o only3 only3.c)
37 .for prog in 2to3 idle pydoc python python-config
38 ${INSTALL_PROGRAM} ${WRKSRC}/generic ${STAGEDIR}${PREFIX}/bin/${prog}
40 .for prog in python3 python-config3
41 ${INSTALL_PROGRAM} ${WRKSRC}/only3 ${STAGEDIR}${PREFIX}/bin/${prog}
44 [FILE:570:descriptions/desc.single]
45 This package provides:
52 It automatically selects the latest version of python available.
53 For example, if python 2.7, 3.5, and 3.6 are all installed,
54 bin/python executes bin/python3.6 with the same arguments. If
55 python 3.6 is then deinstalled, the linkage will automatically
56 adjust to python 3.5. The python 2.7 binaries will only be
57 executed if no python 3.x packages are installed.
59 The priority check can be overridden by setting AUTOPYTHON=<python version>
60 in the environment, e.g. AUTOPYTHON=2.7.
63 [FILE:72:manifests/plist.single]
74 [FILE:742:files/LICENSE_ISC]
75 Copyright (c) 2018, The Ravenports Project.
77 Permission to use, copy, modify, and/or distribute this software for any
78 purpose with or without fee is hereby granted, provided that the above
79 copyright notice and this permission notice appear in all copies.
81 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
82 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
83 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
84 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
85 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
86 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
87 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
90 [FILE:2282:files/autoselect.c.in]
92 * This program will determine the latest version of python
93 * installed by checking %%PREFIX%%/bin/python-<x> where <x> checks
94 * all possible versions.
96 * If no version is present, an error message will be displayed,
97 * otherwise the versioned counterpart of the python command
98 * requested will be will be executed with the same arguments
99 * provided to this one. If the versioned command isn't present, an
100 * error message will be provided as a fallback.
110 main(int argc, char **argv)
115 char recommand[1024];
117 char *PYTHON_A = "%%PREFIX%%/bin/python%%ALPHA%%";
118 char *PYTHON_B = "%%PREFIX%%/bin/python%%BRAVO%%";
119 char *PYTHON_C = "%%PREFIX%%/bin/python%%CHARLIE%%";
120 char *ALPHA = "%%ALPHA%%";
121 char *BRAVO = "%%BRAVO%%";
122 char *CHARLIE = "%%CHARLIE%%";
124 override = getenv("AUTOPYTHON");
125 if (override != NULL) {
126 if (strcmp (override, ALPHA) == 0) {
128 } else if (strcmp (override, BRAVO) == 0) {
130 } else if (strcmp (override, CHARLIE) == 0) {
135 if (access(PYTHON_A, F_OK) != -1) {
137 } else if (access(PYTHON_B, F_OK) != -1) {
139 } else if (access(PYTHON_C, F_OK) != -1) {
142 /* no versions of python are installed */
143 printf ("There are no versions of python installed at %%PREFIX%%/bin\n");
149 * Get the last path element of the program name being executed
151 cmd = strrchr(argv[0], '/');
157 if (strcmp (cmd, "python-config") == 0) {
158 snprintf(recommand, 1024,
159 "%%PREFIX%%/bin/python%s-config", pyver);
160 } else if (strcmp (cmd, "2to3") == 0) {
161 snprintf(recommand, 1024,
162 "%%PREFIX%%/bin/2to3-", pyver);
164 snprintf(recommand, 1024,
165 "%%PREFIX%%/bin/%s%s", cmd, pyver);
168 execv(recommand, argv);
171 * Execution failed, so write out an error message
173 printf ("Command execution failed: %s\n", recommand);
174 printf (" arguments:");
175 for (x = 1; x < argc; x++)
176 printf (" %s", argv[x]);
182 [FILE:2086:files/only3.c.in]
184 * This program will determine the latest version of python
185 * installed by checking %%PREFIX%%/bin/python-<x> where <x> checks
186 * all possible versions of python 3.
188 * If no version is present, an error message will be displayed,
189 * otherwise the versioned counterpart of the python command
190 * requested will be will be executed with the same arguments
191 * provided to this one. If the versioned command isn't present, an
192 * error message will be provided as a fallback.
202 main(int argc, char **argv)
207 char recommand[1024];
209 char *PYTHON_A = "%%PREFIX%%/bin/python%%ALPHA%%";
210 char *PYTHON_B = "%%PREFIX%%/bin/python%%BRAVO%%";
211 char *ALPHA = "%%ALPHA%%";
212 char *BRAVO = "%%BRAVO%%";
214 override = getenv("AUTOPYTHON");
215 if (override != NULL) {
216 if (strcmp (override, ALPHA) == 0) {
218 } else if (strcmp (override, BRAVO) == 0) {
223 if (access(PYTHON_A, F_OK) != -1) {
225 } else if (access(PYTHON_B, F_OK) != -1) {
228 /* no versions of python 3 are installed */
229 printf ("There are no versions of python 3 installed at %%PREFIX%%/bin\n");
235 * Get the last path element of the program name being executed
237 cmd = strrchr(argv[0], '/');
243 if (strcmp (cmd, "python-config3") == 0) {
244 snprintf(recommand, 1024,
245 "%%PREFIX%%/bin/python%s-config", pyver);
246 } else if (strcmp (cmd, "python3") == 0) {
247 snprintf(recommand, 1024,
248 "%%PREFIX%%/bin/python%s", pyver);
250 printf ("only3 doesn't handle this file: %s\n", cmd);
254 execv(recommand, argv);
257 * Execution failed, so write out an error message
259 printf ("Command execution failed: %s\n", recommand);
260 printf (" arguments:");
261 for (x = 1; x < argc; x++)
262 printf (" %s", argv[x]);