Questo contenuto non è disponibile nella lingua selezionata.
4.2. Extending the python27 and rh-python35 Software Collections
This section describes extending the python27 and rh-python35 Software Collections by creating a dependent Software Collection.
In Red Hat Software Collections 3.8, the scl tool is extended to support a macro
%scl_package_override()
, which allows for easier packaging of your own dependent Software Collection.
4.2.1. The vt191 Software Collection Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
Below is a commented example of building a dependent Software Collection. The Software Collection is named
vt191
and contains the versiontools Python package version 1.9.1.
Note the following in the vt191 Software Collection metapackage:
- The vt191 Software Collection metapackage has the following build dependency set:
BuildRequires: %{scl_prefix_python}scldevel
BuildRequires: %{scl_prefix_python}scldevel
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This expands to, for example, python27-scldevel.The python27-scldevel subpackage ships two important macros,%scl_python
and%scl_prefix_python
. Note that these macros are defined at the top of the metapackage spec file. Although the definitions are not required, they provide a visual hint that the vt191 Software Collection has been designed to be built on top of the python27 Software Collection. They also serve as a fallback value. - To have a
site-packages
directory set up properly, use the value of the%python27python_sitelib
macro and replacepython27
withvt191
. Note that if you are building the Software Collection with a different provider (for example,/opt/myorganization/
instead of/opt/rh/
), you will need to change these, too.Important
Because the/opt/rh/
provider is used to install Software Collections provided by Red Hat, it is strongly recommended to use a different provider to avoid possible conflicts. See Section 2.3, “The Software Collection Root Directory” for more information. - The vt191-build subpackage has the following dependency set:
Requires: %{scl_prefix_python}scldevel
Requires: %{scl_prefix_python}scldevel
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This expands to, for example, python27-scldevel. The purpose of this dependency is to ensure that the macros are always present when building packages for the vt191 Software Collection. - The
enable
scriptlet for the vt191 Software Collection uses the following line:. scl_source enable %{scl_python}
. scl_source enable %{scl_python}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note the dot at the beginning of the line. This line makes the Python Software Collection start implicitly when the vt191 Software Collection is started so that the user can only typescl enable vt191 command
instead ofscl enable python27 vt191 command
to run command in the Software Collection environment. - The macro file
macros.vt191-config
calls the%scl_package_override
function to properly override%__os_install_post
, Python dependency generators, and certain Python-specific macros used in other packages' spec files.
4.2.2. The python-versiontools Package Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
Below is a commented example of the python-versiontools package spec file. Note the following in the spec file:
- The
BuildRequires
tags are prefixed with%{?scl_prefix_python}
instead of%{scl_prefix}
. - The
%install
section explictly specifies--install-purelib
.
4.2.3. Building the vt191 Software Collection Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
To build the vt191 Software Collection:
- Install the python27-scldevel and python27-python-devel subpackages that are part of the python27 Software Collection.
- Build
vt191.spec
and install the vt191-runtime and vt191-build packages. - Install the python27-python-setuptools package, which is a build requirement for versiontools.
- Build
python-versiontools.spec
.
4.2.4. Testing the vt191 Software Collection Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
To test the vt191 Software Collection:
- Install the vt191-python-versiontools package.
- Run the following command:
scl enable vt191 "python -c 'import versiontools; print(versiontools.__file__)'"
$ scl enable vt191 "python -c 'import versiontools; print(versiontools.__file__)'"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Verify that the output contains the following line:
/opt/rh/vt191/root/usr/lib/python2.7/site-packages/versiontools/__init__.pyc
/opt/rh/vt191/root/usr/lib/python2.7/site-packages/versiontools/__init__.pyc
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note that the providerrh
in the path may vary depending on your redefinition of the%_scl_prefix
macro. See Section 2.3, “The Software Collection Root Directory” for more information.