The python.mk file as it is currently is very unfriendly to full ports
tree scans, such as those down by poudriere bulk -a.
For example, even when no python is installed as is always the case
on the full scan, every single port that has USES=python in it is
attempting to launch python anyway, and falling back to the default,
which is then piped into tail(1)! An obvious improvement is don't
shell commands when they are 100% guaranteed to fail.
A similar case exists for PYTHONBASE. An attempt to launch python
is made every time and fails every time in the case above.
The worst offender of all is the definition of PYTHON_PORTVERSION
which unconditionally spawns another instance of make just to figure
out the port version. This is extremely heavy during porttree scanning.
Even when python is on the system, it is unnecessary and heavy work
to spawn pytho over and over to retrieve extremly simple information.
This solution:
- lang/python creates a makefile fragment with the sought information already defined. This actions as a cache.
- If this cache is present, it is used thus eliminating all chained shell commands
- if it's not present, and bin/python is not present, the default is used. Note that over time, all the lang/python ports will be updated and the existence check for bin/python will ALWAYS fail. In the meantime, there are going to be older lang/python ports installed so the bin/python fallback has to remain, at least for a while. In time it can be removed.
- The lang/pythonXY ports each define PYTHON_PORTVERSION in a separate file called Makefile.version. This eliminated another shell command (replacing it with a friendlier include). As a side benefit, python35 was really cleaned it. It was a mess with all the regex which actually emitted matching errors. It's much better now.
The improvements are dramatic. On DragonFly poudriere on a 4-core
machine, the time needed to scan the entire tree dropped from 13.5
minutes to 11.5 minutes just with this one modification.
Hopefully these modications will be seen as useful.