1. Introduction
2. Installing MacPorts
2.1. Install Xcode
2.2. Install MacPorts
2.3. Upgrade MacPorts
2.4. Uninstall MacPorts
2.5. MacPorts and the Shell
3. Using MacPorts
3.1. The port Command
3.2. Port Variants
3.3. Common Tasks
3.4. Port Binaries
4. Portfile Development
4.1. Portfile Introduction
4.2. Creating a Portfile
4.3. Example Portfiles
4.4. Port Variants
4.5. Patch Files
4.6. Local Portfile Repositories
4.7. Portfile Best Practices
4.8. MacPorts' buildbot
5. Portfile Reference
5.1. Global Keywords
5.2. Global Variables
5.3. Port Phases
5.4. Dependencies
5.5. Variants
5.6. Tcl Extensions & Useful Tcl Commands
5.7. StartupItems
5.8. Livecheck / Distcheck
5.9. PortGroups
5.10. PortGroup Introduction
5.11. PortGroup github
5.12. PortGroup gnustep
5.13. PortGroup golang
5.14. PortGroup haskell
5.15. PortGroup java
5.16. PortGroup perl5
5.17. PortGroup python
5.18. PortGroup ruby
5.19. PortGroup xcode
6. MacPorts Internals
6.1. File Hierarchy
6.2. Configuration Files
6.3. Port Images
6.4. APIs and Libs
6.5. The MacPorts Registry
6.6. Tests
7. MacPorts Project
7.1. Using Trac for Tickets
7.2. Using Git and GitHub
7.3. Contributing to MacPorts
7.4. Port Update Policies
7.5. Updating Documentation
7.6. MacPorts Membership
7.7. The PortMgr Team
8. MacPorts Guide Glossary
Glossary

5.17. PortGroup python

PortGroup python allows for efficient porting of python-based open source software.

5.17.1. python PortGroup Specific Keywords

Portfiles using the python PortGroup allow for port authors to set the following keywords in addition to the general Portfile keywords.

python.versions

Defines the python versions supported by this port. If the port name starts with py-, then a subport will be defined for each version in the list. For example, if a port named py-foo declares +python.versions 26 27+, subports py26-foo and py27-foo will be created, and will depend on python26 and python27 respectively.

If the port name does not start with py-, it is interpreted as an application written in python rather than a python module. In this case, no subports are defined, and python.versions defaults to the value of +python.default_version+, which must be set. For example, if a port named mercurial sets +python.default_version 27+, then python.versions will automatically be set to 27, and a dependency on python27 will be added.

  • Type: required for modules, optional for apps
  • Example:

    python.versions     25 26 27
python.default_version

For modules (i.e., name starts with py-), this sets the subport that will be installed if the user asks to install py-foo rather than, e.g., py26-foo or py27-foo. If not explicitly set, a reasonable default is chosen from the list in +python.versions+.

For applications (i.e., name does not start with py-), this chooses which version of python to use, and must be set. It can be changed in variants if desired.

  • Type: required for apps, optional for modules
  • Example:

    python.default_version     32
python.link_binaries

When yes (the default), tells the PortGroup to automatically link any executable binaries installed in the bin/ directory within the framework into ${prefix}/bin.

  • Type: optional
  • Example:

    python.link_binaries     no
python.link_binaries_suffix

Suffix to add to the names of the links created in ${prefix}/bin when ${python.link_binaries} is enabled. Can be cleared if no suffix is desired.

  • Type: optional
  • Default: -+${python.branch}+
python.add_archflags

When yes (the default), the PortGroup will automatically try to pass the correct arch-specific flags during build time (via the standard CFLAGS, LDFLAGS, etc environment variables). Set this to no and set up those variables in build.env manually if the default does not work.

  • Type: optional
  • Example:

    python.add_archflags     no

5.17.2. python PortGroup Specific Variables

When the python PortGroup is declared within a Portfile, the following variables are provided.

python.version
The python version in use in the current subport. This will be one of the versions listed in +python.versions+.
python.branch
The python version in use in the current subport, in normal dotted notation. For example, if python.version is 26, python.branch will be 2.6.
python.prefix
The prefix in which the current python version is installed. For framework builds, this is ${frameworks_dir}/Python.framework/Versions/${python.branch}, whereas for non-framework builds, it is the same as +${prefix}+.
python.bin
The path to the MacPorts Python executable.
python.lib
The Python dynamic library path, i.e., ${python.prefix}/Python (framework builds) or ${prefix}/lib/libpython2.4.dylib (python24).
python.libdir
The path to python’s lib directory, i.e., ${python.prefix}/lib/python${python.branch}.
python.include
Path to the Python include directory.
python.pkgd
Path to the Python site-packages directory. (i.e., ${python.prefix}/lib/python${python.branch}/site-packages).

5.17.3. python PortGroup Sugar

Portfiles using PortGroup python do not need to define the following variables:

categories
Default: python
depends_lib
Default: port:python${python.version}
use_configure
Default: no
build.cmd
Default: ${python.bin} setup.py --no-user-cfg
build.target
Default: build
destroot.cmd
Default: ${python.bin} setup.py --no-user-cfg
destroot.destdir
Default: --prefix=+${python.prefix}+ --root=+${destroot}+
pre-destroot
Default: creates directory ${destroot}${prefix}/share/doc/${subport}/examples.