# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 PortSystem 1.0 PortGroup python 1.0 # meta-version; bump whenever underlying variants are updated. Needed to # support portindex (variants can't have different versions.) version 12 # Needed for change to meta-versioning epoch 1 name py-clang python.versions 39 310 311 312 license NCSA maintainers {eborisch @eborisch} \ openmaintainer description Python bindings for clang long_description {*}${description} homepage \ https://github.com/llvm/llvm-project/tree/main/clang/bindings/python supported_archs noarch platforms {darwin any} livecheck.url https://api.github.com/repos/llvm/llvm-project/git/refs/tags # Update this to the most recent clang supported livecheck.version 19.1.2 livecheck.regex {llvmorg-([\d.]+)\"} if {${name} ne ${subport}} { # Share llvm's downloads dist_subdir llvm use_xz yes checksums \ cfe-3.7.1.src.tar.xz \ rmd160 185b0f75970bc50682766a21794440578db87b5d \ sha256 56e2164c7c2a1772d5ed2a3e57485ff73ff06c97dff12edbeea1acc4412b0674 \ clang-19.1.2.src.tar.xz \ rmd160 cbc65ca6a76b59d4a8827416a0177cca7fabd95d \ sha256 54aa3514c96a28b26482e84c44916fb3eac7c3bca2d1721d67154b52e84433c1 \ clang-18.1.8.src.tar.xz \ rmd160 703b8825a5451db6011e8614dd7bc403877849b8 \ sha256 5724fe0a13087d5579104cedd2f8b3bc10a212fb79a0fcdac98f4880e19f4519 depends_build-append port:py${python.version}-setuptools # Keeping 37 around for old systems; otherwise two latest releases. set clanglist {37 19 18} set clangvlist {3.7.1 19.1.2 18.1.8} foreach cvnum $clanglist { # Explictly use (and depend on) the libclang we select during install set cvidx [lsearch $clanglist $cvnum] set clang_version [lindex $clangvlist $cvidx] set cflist {} foreach v [lreplace $clanglist $cvidx $cvidx] {lappend cflist clang$v} if {${cvnum} < 90 && ${cvnum} >= 37} { set diststub cfe } else { set diststub clang } # Once clang reaches version 370, this will need to be revisited... if {${cvnum} >= 37} { set cvstr [string index $cvnum 0].[string index $cvnum 1] } else { set cvstr ${cvnum} } set substr \ "library_path = '${prefix}/libexec/llvm-${cvstr}/lib'" variant clang${cvnum} description { Use clang${cvnum}'s libclang } conflicts {*}${cflist} " master_sites https://releases.llvm.org/${clang_version} \ https://github.com/llvm/llvm-project/releases/download/llvmorg-${clang_version} depends_lib-append port:clang-${cvstr} distfiles ${diststub}-${clang_version}.src.tar.xz worksrcdir ${diststub}-${clang_version}.src/bindings/python post-patch { reinplace {s^library_path = None^$substr^} clang/cindex.py reinplace {s/version=.*/version=\"${clang_version}\",/} setup.py } livecheck.version ${clang_version} livecheck.regex \ \"llvmorg-([string range $clang_version 0 1]\\\\.\\\[0-9.\\\]+)\\\"\" " } test.run yes python.test_framework unittest if {![variant_isset clang37] && ![variant_isset clang19] && ![variant_isset clang18]} { default_variants +clang19 } pre-extract { # Will never hit this when installing from packages, which is OK, as # they will have the default variant set above. if {![variant_isset clang37] && ![variant_isset clang19] && ![variant_isset clang18]} { ui_error "At least one of the clangNN variants must be active." return -code error "Unsupported (no) variants selected." } } post-extract { file copy ${filespath}/setup.py ${worksrcpath}/ } post-destroot { set DOCDIR ${destroot}${prefix}/share/doc/${subport} xinstall -d ${DOCDIR} file copy ${worksrcpath}/README.txt ${DOCDIR} } notes { The path to the selected libclang variant has been recorded in the\ installed package. It can be overridden with:\ cindex.set_library_(path|file)(). } }