tags:

views:

20

answers:

2

Hi guys, I was wondering how you can append a variant to a port if you have already installed the port. For example I installed the 'vim' port and would like to go back and add the python25 variant. Do I need to delete vim and reinstall it? This is just an example, I would really like to know the process to do this for any port.

Thanks for any help, Greg

A: 

You do need to reinstall. There's no way to add a variant on afterwards – nor does it even make sense to do so. Variants affect settings during the build process.

Kevin Ballard
+2  A: 

Only one variant of a MacPorts port can be active at any one time. However, in MacPorts terminology, multiple variants and/or versions of a port can be installed simultaneously. Of those, at most one is active, any others are inactive. If you need to occasionally alternate between variants, you can activate a specific variant as needed. That will also automatically deactivate any conflicting active port. For example, here's a hypothetical vim example (not fully tested!):

$ sudo port install vim +python26
$ sudo port clean vim
$ sudo port install vim +python31
$ sudo port echo installed |grep vim
vim                            @7.3.21_0+python26
vim                            @7.3.21_0+python31
$ sudo port activate vim @7.3.21_0+python26
# ... edit with Python 2
# ...
$ sudo port activate vim @7.3.21_0+python31
# ... edit with Python 3
# ...
Ned Deily
I'm confused. Since a variant is a compile time option vim +python26 builds vim with python26 support. You are then recompiling it with python31 support. How does it keep both compile options? Is this a Mac Port feature?
gsieranski
I'm not an expert on the internals but essentially it keeps copies of each `installed` port (look in `/opt/local/var/macports/software/`). The process of activating a port creates hard links from the files in there to the normal locations (`/opt/local/bin` etc). Deactivating a port removes those hard links. So the process is fast and does not require extra copies of each file, just the hard link entries.
Ned Deily
I see how it works. Thanks so much for the help!
gsieranski