No edit summary |
Churchyard (talk | contribs) (Go away) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{admon/important|Old page|This page is very very old. The information on this page is '''not accurate'''. See https://src.fedoraproject.org/rpms/pyproject-rpm-macros instead for packaging wheels.}} | |||
= Python Wheels in fedora = | = Python Wheels in fedora = | ||
Line 9: | Line 11: | ||
{{Anchor|Buildrequires}} | {{Anchor|Buildrequires}} | ||
== BuildRequires == | == BuildRequires == | ||
{{admon/important|Old page|This page is very very old. The information on this page is '''not accurate'''. See https://src.fedoraproject.org/rpms/pyproject-rpm-macros instead for packaging wheels.}} | |||
The package has to BuildRequire python?-pip and python?-wheel: | The package has to BuildRequire python?-pip and python?-wheel: | ||
<pre> | <pre> | ||
BuildRequires: | BuildRequires: python2-pip | ||
BuildRequires: | BuildRequires: python2-wheel | ||
BuildRequires: python3-pip | BuildRequires: python3-pip | ||
BuildRequires: python3-wheel | BuildRequires: python3-wheel | ||
</pre> | </pre> | ||
{{Anchor|Build}} | {{Anchor|Build}} | ||
== Build section == | == Build section == | ||
{{admon/important|Old page|This page is very very old. The information on this page is '''not accurate'''. See https://src.fedoraproject.org/rpms/pyproject-rpm-macros instead for packaging wheels.}} | |||
The package has to use the ''bdist_wheel'' command, which creates a wheel file in the ''dist'' directory. A minimal build section thus becomes: | The package has to use the ''bdist_wheel'' command, which creates a wheel file in the ''dist'' directory. A minimal build section thus becomes: | ||
<pre> | <pre> | ||
% | %py2_build_wheel | ||
%py3_build_wheel | |||
</pre> | |||
The above uses <code>setup.py</code> . But this might not be present at all if upstream uses different tools, such as [https://github.com/takluyver/flit flit]. In that case, just create the wheel as needed, for example with flit: | |||
<pre> | |||
flit build --format wheel | |||
</pre> | </pre> | ||
{{Anchor|Install}} | {{Anchor|Install}} | ||
== Install section == | == Install section == | ||
{{admon/important|Old page|This page is very very old. The information on this page is '''not accurate'''. See https://src.fedoraproject.org/rpms/pyproject-rpm-macros instead for packaging wheels.}} | |||
Tha package has to use ''pip'' to install the newly created wheel. A minimal install section | Tha package has to use ''pip'' to install the newly created wheel. A minimal install section | ||
Line 44: | Line 52: | ||
<pre> | <pre> | ||
% | %py2_install_wheel dist/%{python2_wheelname} | ||
%py3_install_wheel dist/%{python3_wheelname} | |||
% | |||
</pre> | </pre> | ||
Line 66: | Line 69: | ||
%global python3_wheelname %{srcname}-%{version}-cp%{python3_version_nodots}-none-linux_%{_target_cpu}.whl | %global python3_wheelname %{srcname}-%{version}-cp%{python3_version_nodots}-none-linux_%{_target_cpu}.whl | ||
</pre> | </pre> | ||
{{Anchor|Files}} | {{Anchor|Files}} | ||
== Files section == | == Files section == | ||
{{admon/important|Old page|This page is very very old. The information on this page is '''not accurate'''. See https://src.fedoraproject.org/rpms/pyproject-rpm-macros instead for packaging wheels.}} | |||
Unless covered by an already existing glob, you also need to add the following entries to the files section: | Unless covered by an already existing glob, you also need to add the following entries to the files section: |
Latest revision as of 11:29, 26 March 2021
Python Wheels in fedora
Starting with Fedora 22, Python packages will have the option to install itself into buildroot via Python wheels.[1] Wheels are the new binary distribution format for python modules, note that as such they are not suitable for use as Source archive.
Unless you have a good reason to use this method of installation, please use the one specified in Packaging:Python. Installing with wheels currently uses a fedora-specific pip option[2] that upstream may eventually implement differently.
The text below describes the minimal specfile changes needed, if installation with wheel is desired.
BuildRequires
The package has to BuildRequire python?-pip and python?-wheel:
BuildRequires: python2-pip BuildRequires: python2-wheel BuildRequires: python3-pip BuildRequires: python3-wheel
Build section
The package has to use the bdist_wheel command, which creates a wheel file in the dist directory. A minimal build section thus becomes:
%py2_build_wheel %py3_build_wheel
The above uses setup.py
. But this might not be present at all if upstream uses different tools, such as flit. In that case, just create the wheel as needed, for example with flit:
flit build --format wheel
Install section
Tha package has to use pip to install the newly created wheel. A minimal install section thus becomes:
%py2_install_wheel dist/%{python2_wheelname} %py3_install_wheel dist/%{python3_wheelname}
When packaging pure python packages python?_wheelname should be defined as
%global python2_wheelname %{srcname}-%{version}-py2.py3-none-any.whl %global python3_wheelname %python2_wheelname
For packages that include any extension modules or C libraries python?_wheelname should be defined as
%global python2_wheelname %{srcname}-%{version}-cp%{python2_version_nodots}-none-linux_%{_target_cpu}.whl %global python3_wheelname %{srcname}-%{version}-cp%{python3_version_nodots}-none-linux_%{_target_cpu}.whl
Files section
Unless covered by an already existing glob, you also need to add the following entries to the files section:
%{python2_sitelib}/%{name}-%{version}.dist-info/
%{python3_sitelib}/%{name}-%{version}.dist-info/