I have an issue with SIP that needs to be addressed, that I'm not sure how do execute in port via Portfiles. I have a solution, but it's kinda a hack.
Background --- Some SIP dependencies use sipconfig to glean the directory into which to install generated SIP files [in Python: "import sipconfig"; "sipcfg = sipconfig.Configuration()"; "sipcfg.default_sip_dir" -> default "--sipdir" for installing generated SIP files]. Other SIP dependencies use a configuration --sipdir for this directory, with the default generally being "$prefix/share/pyXY-sip/$subport", but sometimes "$PYTHON_PREFIX/share/sip/$subport" where "PYTHON_PREFIX" is the top-level Python directory (in MacPorts, "$frameworks_dir/Python.framework/Versions/X.Y/"). I've been told that the "sipconfig" import is being removed from SIP sometime soonish, so we're better off specifying a directory into which ports install SIP files. Also, different ports choose different SIP directories, and combining these makes sense. What I'd like to do is symlink "$prefix/share/pyXY-sip/$subport" -> "$PYTHON_PREFIX/share/sip/$subport", so that it doesn't matter which method the port chooses, even if we specify one directory or the other. I can fix all of the ports that I know of that use SIP to install into the PYTHON_PREFIX version, but the ordering makes a difference because both of the SIP directories are populated at least on my MacPorts install. This poses the issue that the SIP port should be creating the latter directory as well as symlink, but it cannot while the former directory has anything in it. I can update the dependencies first, so that they are all installing into the PYTHON_PREFIX directory, then update SIP ... but, if someone does a "sudo port selfupdate" then port will do the update with SIP first followed by dependencies, which won't work. I can do this & update SIP maybe a year down the road ... but, that seems silly ... there has got to be a better way! I'd prefer to not require the user to deactivate various ports, instead automating the process of moving the files to allow the symlink to be created by the SIP port. My Hack --- My "hack" is to have SIP check in pre-activate for the directory "$prefix/share/pyXY-sip/" and if found then create an archive of its contents (into /tmp/something.tar), and "cd $prefix/share && rm -rf pyXY-sip". Then the 'activate' takes place, which creates the symlink to the "$PYTHON_PREFIX/share/sip/$subport" directory. Then in post-activate check for the archive & if found restore the contents into the directory "$PYTHON_PREFIX/share/sip/" && remove the archive. In my testing, this hack works perfectly & without user intervention. That said, it's a hack & maybe not the right thing to do. Hence me reaching out to MP devs: is there a good way to combine the contents of multiple directories via a common port? Should I just give up on trying to automate the process, instead force the user to deactivate / reactivate ports? Thanks for your thoughts / comments. - MLD
