wiki:Python

Version 9 (modified by jmroot (Joshua Root), 4 years ago) (diff)

update current versions

Python

Python is a dynamic object-oriented programming language that can be used for many kinds of software development. It offers strong support for integration with other languages and tools, comes with extensive standard libraries, and can be learned in a few days. Many Python programmers report substantial productivity gains and feel the language encourages the development of higher quality, more maintainable code.

Python in MacPorts

MacPorts allows the installation of several different versions of python.
Versions 3.6 and later, however, are the primary focus of work. New ports should support Python 3.9, with support for older versions added only if there is a good reason.

Frameworks

Python is installed as a Framework.

Avoiding Conflicts

Since MacPorts supports several different version of Python, conventions are adopted to ensure that there are no conflicts.
Ports of python modules which use the python PortGroup are automatically installed so as to avoid conflicts.
Other python packages must self-enforce conventions to avoid conflicts.

Versions 2.6 and Later

  • Header files are installed into ${frameworks_dir}/Python.framework/Versions/${python.branch}/include/python${python.branch}.
  • Library files are installed into ${frameworks_dir}/Python.framework/Versions/${python.branch}/lib/python${python.branch}.
  • Site-packages are installed into ${frameworks_dir}/Python.framework/Versions/${python.branch}/lib/python${python.branch}/site-packages.

pkg-config Files

Some python packages (such as Pycairo) install .pc files for pkg-config.
Since these files do not have the python version in their names, they can not be installed in the standard locations for pkg-config.
Instead they are installed into ${frameworks_dir}/Python.framework/Versions/${python.branch}/lib/lib/pkgconfig.

In order for pkg-config to find the .pc files, the environment variable PKG_CONFIG_PATH must be set.
For MacPorts Portfiles, the variable configure.pkg_config_path can be used for this purpose.

no-user-cfg Option

The existence of ~/pydistutils.cfg can cause problems during installation of python packages (see #9831).
For Python version 2.5 and later, the option --no-user-cfg has been added to allow this file to be ignored.

Converting to the unified python PortGroup

As of July 2011, a new unified python PortGroup has been introduced to simplify the maintenance of Python module ports. It uses subports to keep a single Portfile for all versions of python.

Look at the examples to know how to convert to it...

Examples: r82756, r82241

Mailing List archive: Unifying Python Ports Python portgroup

Version Policy

Ports should attempt to support the latest stable version of Python, and should generally avoid using Python versions that are no longer receiving upstream updates (a.k.a. "end-of-life"), unless it is impossible to use a newer version for some reason. As always, no port should be removed without first ensuring it has no remaining dependents (remember that this applies recursively), and the permission of relevant maintainers should be obtained. Port maintainers may extend support for older Python versions at their discretion.

End-of-life Python versions should include the deprecated portgroup so that users know they are EOL and can make an informed decision whether to continue using them.

The setuptools, pip and virtualenv modules should continue to be provided even for EOL Python versions, so that users who need them can still install modules.