How to Git Clone Subrepo for Build (opencv-python)

Ryan Schmidt ryandesign at macports.org
Fri Dec 20 12:47:58 UTC 2019



On Dec 10, 2019, at 15:35, Steven Smith wrote:

> The opencv-python package needs to clone a subrepo of opencv4 as part of the build. See:
> 
> https://pypi.org/project/opencv-python/
> https://github.com/skvark/opencv-python
> 
> How should this be done within a Portfile? Effectively, `git clone https://github.com/opencv/opencv.git` must be run in the pre-build stage.
> 
> It must be a proper git repo—installing the opencv4 port isn’t enough.

You should not git clone (or do any other kind of downloading, nor allow a build system to do so) in any phase other than the fetch phase. You can certainly write a pre-fetch or post-fetch block to run additional commands if the standard fetching infrastructure of MacPorts is not expressive enough for a port's needs. MacPorts support downloading any number of distfiles, *or* cloning one repo, so if you need to clone 2 of them, you'll have to write a block to clone the second one.

Certainly make sure that you are cloning a certain known good commit or tag of each repo, and not the head of master or another branch since those might change later.

If downloading distfiles would be sufficient, that would be preferable to cloning repos, for all the usual reasons.


More information about the macports-dev mailing list