# Buildsheet autogenerated by ravenadm tool -- Do not edit. NAMEBASE= autoselect-python VERSION= 5 KEYWORDS= lang VARIANTS= standard SDESC[standard]= Dynamic links to the latest installed python HOMEPAGE= none CONTACT= nobody DOWNLOAD_GROUPS= none SPKGS[standard]= single OPTIONS_AVAILABLE= none OPTIONS_STANDARD= none LICENSE= ISCL:single LICENSE_FILE= ISCL:{{FILESDIR}}/LICENSE_ISC LICENSE_SCHEME= solo SUB_FILES= autoselect.c SUB_LIST= ALPHA=3.11 BRAVO=3.12 post-patch: ${MKDIR} ${WRKSRC} ${CP} ${WRKDIR}/*.c ${WRKSRC} do-build: (cd ${WRKSRC} && ${CC} ${CFLAGS} ${LDFLAGS} -o autoselect autoselect.c) do-install: .for prog in python python3 python-config python3-config 2to3 idle pydoc pip ${INSTALL_PROGRAM} ${WRKSRC}/autoselect ${STAGEDIR}${PREFIX}/bin/${prog} .endfor [FILE:493:descriptions/desc.single] This package provides: bin/python bin/python-config bin/pydoc bin/idle bin/2to3 bin/pip It automatically selects the latest version of python available. For example, if python 3.10 and 3.11 are both installed, bin/python executes bin/python3.11 with the same arguments. If python 3.11 is then deinstalled, the linkage will automatically adjust to python 3.10. The priority check can be overridden by setting AUTOPYTHON= in the environment, e.g. AUTOPYTHON=3.11. [FILE:77:manifests/plist.single] bin/ 2to3 idle pip pydoc python python-config python3 python3-config [FILE:742:files/LICENSE_ISC] Copyright (c) 2018, The Ravenports Project. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. [FILE:2333:files/autoselect.c.in] /* * This program will determine the latest version of python * installed by checking %%PREFIX%%/bin/python- where checks * all possible versions of python 3. * * If no version is present, an error message will be displayed, * otherwise the versioned counterpart of the python command * requested will be will be executed with the same arguments * provided to this one. If the versioned command isn't present, an * error message will be provided as a fallback. */ #include #include #include #include int main(int argc, char **argv) { int x; char *cmd; char *override; char recommand[1024]; char *pyver = NULL; char *PYTHON_A = "%%PREFIX%%/bin/python%%ALPHA%%"; char *PYTHON_B = "%%PREFIX%%/bin/python%%BRAVO%%"; char *ALPHA = "%%ALPHA%%"; char *BRAVO = "%%BRAVO%%"; override = getenv("AUTOPYTHON"); if (override != NULL) { if (strcmp (override, ALPHA) == 0) { pyver = ALPHA; } else if (strcmp (override, BRAVO) == 0) { pyver = BRAVO; } } if (pyver == NULL) { if (access(PYTHON_A, F_OK) != -1) { pyver = ALPHA; } else if (access(PYTHON_B, F_OK) != -1) { pyver = BRAVO; } else { /* no versions of python 3 are installed */ printf ("There are no versions of python 3 installed at %%PREFIX%%/bin\n"); exit (1); } } /* * Get the last path element of the program name being executed */ cmd = strrchr(argv[0], '/'); if (cmd != NULL) cmd++; else cmd = argv[0]; if (strcmp (cmd, "python-config") == 0) { snprintf(recommand, 1024, "%%PREFIX%%/bin/python%s-config", pyver); } else if (strcmp (cmd, "python3-config") == 0) { snprintf(recommand, 1024, "%%PREFIX%%/bin/python%s-config", pyver); } else if (strcmp (cmd, "python3") == 0) { snprintf(recommand, 1024, "%%PREFIX%%/bin/python%s", pyver); } else if (strcmp (cmd, "2to3") == 0) { snprintf(recommand, 1024, "%%PREFIX%%/bin/2to3-", pyver); } else { snprintf(recommand, 1024, "%%PREFIX%%/bin/%s%s", cmd, pyver); } argv[0] = recommand; execv(recommand, argv); /* * Execution failed, so write out an error message */ printf ("Command execution failed: %s\n", recommand); printf (" arguments:"); for (x = 1; x < argc; x++) printf (" %s", argv[x]); printf ("\n"); exit (1); }