[Rpm-maint] [rpm-software-management/rpm] Discussion: How to handle Python extras (#1061)
Miro Hrončok
notifications at github.com
Tue May 19 19:07:31 UTC 2020
Here's my idea:
```lua
%python_extras_subpkg(n:i:f:) %{expand:%{lua:
local value_n = rpm.expand('%{-n*}')
local value_i = rpm.expand('%{-i*}')
local value_f = rpm.expand('%{-f*}')
local args = rpm.expand('%{*}')
if value_n == '' then
rpm.expand('%{error:%%%0: missing option -n (name of the base package)}')
end
if value_i == '' and value_f == '' then
rpm.expand('%{error:%%%0: missing option -i (buildroot path to metadata) or -f (builddir path to a filelist)}')
end
if value_i ~= '' and value_f ~= '' then
rpm.expand('%{error:%%%0: simultaneous -i (buildroot path to metadata) and -f (builddir path to a filelist) is not supported}')
end
if args == '' then
rpm.expand('%{error:%%%0 requires at least one argument with "extras" name}')
end
local requires = 'Requires: ' .. value_n .. ' = %{?epoch:%{epoch}:}%{version}-%{release}'
for extras in args:gmatch('%w+') do
local rpmname = value_n .. '+' .. extras
local pyname = value_n .. '[' .. extras .. ']'
local pkgdef = '%package -n ' .. rpmname
local summary = 'Summary: Metapackage requiring requires for ' .. pyname
local description = '%description -n ' .. rpmname .. '\\\n' ..
'This is a metapackage bringing in requires for ' .. pyname .. '.\\\n' ..
'It contains no code, just makes sure the dependencies are installed.\\\n'
local files
if value_i ~= '' then
files = '%files -n ' .. rpmname .. '\\\n' .. '%ghost ' .. value_i
else
files = '%files -n ' .. rpmname .. ' -f ' .. value_f
end
for i, line in ipairs({pkgdef, summary, requires, description, files, ''}) do
print(line .. '\\\n')
end
end
}}
```
You'd put this to your specfile near other subpackage declarations:
```
%python_extras_subpkg -n python3-setuptools_scm -i %{python3_sitelib}/*.egg-info toml
```
It expands to:
```
%package -n python3-setuptools_scm+toml
Summary: Metapackage requiring requires for python3-setuptools_scm[toml]
Requires: python3-setuptools_scm = %{?epoch:%{epoch}:}%{version}-%{release}
%description -n python3-setuptools_scm+toml
This is a metapackage bringing in requires for python3-setuptools_scm[toml].
It contains no code, just makes sure the dependencies are installed.
%files -n python3-setuptools_scm+toml
%ghost /usr/lib/python3.8/site-packages/*.egg-info
```
The rest would be handled by the Python dist dependency generator (taking package name as argument, parsing out the `+toml` part of it, and finding extras named `toml` in the package, eventually providing `python3dist(setuptools_scm[toml]) = 1.2.3` and requiring whatever that requires. If extras `toml` is not found, the dependency generator will error ([somehow](https://github.com/rpm-software-management/rpm/issues/1183)).
Side note: The `-f` option allows to do:
```
%python_extras_subpkg -n python3-setuptools_scm -f %{python_extras_filelist} toml
```
When other automation is at play.
Side note 2: The subpackage should really require `python3-setuptools_scm%{?_isa}` if arched, but I am unsure how to detect if `python3-setuptools_scm` is arched or noarch, so I will just hope for the best :crossed_fingers:
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1061#issuecomment-631023401
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20200519/4a614d52/attachment-0001.html>
More information about the Rpm-maint
mailing list