Visualized MacPorts Ports

Rainer Müller raimue at
Wed Jul 3 09:45:02 PDT 2013

On 2013-07-03 18:16, Jean-François Caron wrote:
> I'm wondering if there is a MacPorts equivalent to the python-apt
> package, for getting MacPorts information directly within python.  Or
> otherwise a good way to access the MacPorts list of ports,
> dependencies, and categories from Python.

There is no API for Python. However, you can query the information
straight-forward with the port tool.

List of all available ports:
  port -q echo all

List of all dependencies of a specific port:
  port -q echo depof:$NAME

There is no such thing as suggest/recommends in MacPorts, but it still
has different kinds of dependencies. On the one hand there are
depends_fetch, depends_extract and depends_build, that are only required
for building the port. On the other hand there are depends_lib and
depends_run which are required at runtime. The command above using
depof: includes all of them.

I guess it's more interesting to see runtime dependencies for such a
graph, but you could also add both build and runtime dependencies with a
different weight as in the graph for Ubuntu. Anyway, we should
distinguish between these two types of dependencies.

Retrieving only the runtime dependencies of a specific port in a nice
line-wise format proves to be a lot harder:

port -q info --depends_lib --depends_run $NAME |tr ',' '\n' |awk -F: 'NF
> 0 {print $NF}'

I hope that helps you to get started for a similar project. In case you
need more assistance with the port command, just ask :-)


More information about the macports-users mailing list