# -*- 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 10 # Needed for change to meta-versioning epoch 1 name py-clang python.versions 38 39 310 311 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 17.0.6 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-16.0.4.src.tar.xz \ rmd160 cca5ea9f1ebbbe810fd4994ae6e49b7a9ff39d3b \ sha256 56f5797c20834769d4bf6c35b1677cebf31d27ad34d5c9b8d9f0237c1d11b51a \ clang-17.0.6.src.tar.xz \ rmd160 1fb51adf1b992220bebb4f066480cd4b0ecc1888 \ sha256 a78f668a726ae1d3d9a7179996d97b12b90fb76ab9442a43110b972ff7ad9029 depends_build-append port:py${python.version}-setuptools # Keeping 37 around for old systems; otherwise two latest releases. set clanglist {37 16 17} set clangvlist {3.7.1 16.0.4 17.0.6} 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 clang17] && ![variant_isset clang16]} { default_variants +clang17 } 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 clang17] && ![variant_isset clang16]} { 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)(). } }