| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| %__default_python3_version 3.9 |
| |
| |
| |
| |
| %__default_python3_pkgversion %__default_python3_version |
| |
| |
| |
| |
| |
| %python3_pkgversion 3 |
| |
| |
| |
| |
| |
| |
| |
| %__python2 /usr/bin/python2 |
| %__python3 /usr/bin/python%{python3_pkgversion} |
| |
| |
| %python2 %__python2 |
| %python3 %__python3 |
| |
| |
| %__python %{error:attempt to use unversioned python, define %%__python to %{__python2} or %{__python3} explicitly} |
| |
| |
| %python %__python |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| %python_wheel_pkg_prefix python%{?rhel:%{!?eln:%{python3_pkgversion}}} |
| %python_wheel_dir %{_datadir}/%{python_wheel_pkg_prefix}-wheels |
| |
| |
| |
| |
| |
| |
| |
| %py_dist_name() %{lua:\ |
| name = rpm.expand("%{?1:%{1}}");\ |
| canonical = string.gsub(string.lower(name), "[^%w%[%]]+", "-");\ |
| print(canonical);\ |
| } |
| |
| |
| |
| |
| %py2_dist() %{lua:\ |
| args = {}\ |
| arg = 1\ |
| while (true) do\ |
| name = rpm.expand("%{?" .. arg .. ":%{" .. arg .. "}}");\ |
| if (name == nil or name == '') then\ |
| break\ |
| end\ |
| args[arg] = name\ |
| arg = arg + 1\ |
| end\ |
| for arg, name in ipairs(args) do\ |
| canonical = rpm.expand("%py_dist_name " .. name);\ |
| print("python2dist(" .. canonical .. ") ");\ |
| end\ |
| } |
| |
| |
| |
| |
| %py3_dist() %{lua:\ |
| python3_pkgversion = rpm.expand("%python3_pkgversion");\ |
| args = {}\ |
| arg = 1\ |
| while (true) do\ |
| name = rpm.expand("%{?" .. arg .. ":%{" .. arg .. "}}");\ |
| if (name == nil or name == '') then\ |
| break\ |
| end\ |
| args[arg] = name\ |
| arg = arg + 1\ |
| end\ |
| for arg, name in ipairs(args) do\ |
| canonical = rpm.expand("%py_dist_name " .. name);\ |
| print("python" .. python3_pkgversion .. "dist(" .. canonical .. ") ");\ |
| end\ |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| %__pypi_url https://files.pythonhosted.org/packages/source/ |
| %__pypi_default_extension tar.gz |
| |
| %pypi_source() %{lua: |
| local src = rpm.expand('%1') |
| local ver = rpm.expand('%2') |
| local ext = rpm.expand('%3') |
| local url = rpm.expand('%__pypi_url') |
| \ |
| -- If no first argument, try %srcname, then %pypi_name, then %name |
| -- Note that rpm leaves macros unchanged if they are not defined. |
| if src == '%1' then |
| src = rpm.expand('%srcname') |
| end |
| if src == '%srcname' then |
| src = rpm.expand('%pypi_name') |
| end |
| if src == '%pypi_name' then |
| src = rpm.expand('%name') |
| end |
| \ |
| -- If no second argument, use %version |
| if ver == '%2' then |
| ver = rpm.expand('%version'):gsub('~', '') |
| end |
| \ |
| -- If no third argument, use the preset default extension |
| if ext == '%3' then |
| ext = rpm.expand('%__pypi_default_extension') |
| end |
| \ |
| local first = string.sub(src, 1, 1) |
| \ |
| print(url .. first .. '/' .. src .. '/' .. src .. '-' .. ver .. '.' .. ext) |
| } |
| |
| %py_provides() %{lua: |
| local python = require 'fedora.srpm.python' |
| local rhel = rpm.expand('%{?rhel}') |
| local name = rpm.expand('%1') |
| if name == '%1' then |
| rpm.expand('%{error:%%py_provides requires at least 1 argument, the name to provide}') |
| end |
| local evr = rpm.expand('%2') |
| if evr == '%2' then |
| evr = rpm.expand('%{?epoch:%{epoch}:}%{version}-%{release}') |
| end |
| print('Provides: ' .. name .. ' = ' .. evr .. '\\n') |
| local provides = python.python_altprovides(name, evr) |
| for i, provide in ipairs(provides) do |
| print('Provides: ' .. provide .. '\\n') |
| end |
| -- We only generate these Obsoletes on CentOS/RHEL to provide clean upgrade |
| -- path, e.g. python3-foo obsoletes python39-foo from previous RHEL. |
| -- In Fedora this is not needed as we don't ship ecosystem packages |
| -- for alternative Python interpreters. |
| if rhel ~= '' then |
| -- Create Obsoletes only if the name does not end in a parenthesis, |
| -- as Obsoletes can't include parentheses. |
| -- This most commonly happens when the name contains an isa. |
| if (string.sub(name, "-1") ~= ")") then |
| local obsoletes = python.python_altobsoletes(name, evr) |
| for i, obsolete in ipairs(obsoletes) do |
| print('Obsoletes: ' .. obsolete .. '\\n') |
| end |
| end |
| end |
| } |
| |
| %python_extras_subpkg(n:i:f:F) %{expand:%{lua: |
| local option_n = '-n (name of the base package)' |
| local option_i = '-i (buildroot path to metadata)' |
| local option_f = '-f (builddir path to a filelist)' |
| local option_F = '-F (skip %%files section)' |
| local value_n = rpm.expand('%{-n*}') |
| local value_i = rpm.expand('%{-i*}') |
| local value_f = rpm.expand('%{-f*}') |
| local value_F = rpm.expand('%{-F}') |
| local args = rpm.expand('%{*}') |
| if value_n == '' then |
| rpm.expand('%{error:%%%0: missing option ' .. option_n .. '}') |
| end |
| if value_i == '' and value_f == '' and value_F == '' then |
| rpm.expand('%{error:%%%0: missing option ' .. option_i .. ' or ' .. option_f .. ' or ' .. option_F .. '}') |
| end |
| if value_i ~= '' and value_f ~= '' then |
| rpm.expand('%{error:%%%0: simultaneous ' .. option_i .. ' and ' .. option_f .. ' options are not possible}') |
| end |
| if value_i ~= '' and value_F ~= '' then |
| rpm.expand('%{error:%%%0: simultaneous ' .. option_i .. ' and ' .. option_F .. ' options are not possible}') |
| end |
| if value_f ~= '' and value_F ~= '' then |
| rpm.expand('%{error:%%%0: simultaneous ' .. option_f .. ' and ' .. option_F .. ' options are not possible}') |
| 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('[^%s,]+') do |
| local rpmname = value_n .. '+' .. extras |
| local pkgdef = '%package -n ' .. rpmname |
| local summary = 'Summary: Metapackage for ' .. value_n .. ': ' .. extras .. ' extras' |
| local description = '%description -n ' .. rpmname .. '\\\n' |
| local current_line = 'This is a metapackage bringing in' |
| for _, word in ipairs({extras, 'extras', 'requires', 'for', value_n .. '.'}) do |
| local line = current_line .. ' ' .. word |
| if line:len() > 79 then |
| description = description .. current_line .. '\\\n' |
| current_line = word |
| else |
| current_line = line |
| end |
| end |
| description = description .. current_line .. '\\\n' .. |
| 'It makes sure the dependencies are installed.\\\n' |
| local files = '' |
| if value_i ~= '' then |
| files = '%files -n ' .. rpmname .. '\\\n' .. '%ghost ' .. value_i |
| elseif value_f ~= '' then |
| files = '%files -n ' .. rpmname .. ' -f ' .. value_f |
| end |
| for i, line in ipairs({pkgdef, summary, requires, description, files, ''}) do |
| print(line .. '\\\n') |
| end |
| end |
| }} |