Blame SOURCES/macros.python3

2599dd
%__python3 /usr/libexec/platform-python
bae33e
%python3 %__python3
2599dd
%python3_sitelib %(%{__python3} -Ic "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
2599dd
%python3_sitearch %(%{__python3} -Ic "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")
2599dd
%python3_version %(%{__python3} -Ic "import sys; sys.stdout.write(sys.version[:3])")
2599dd
%python3_version_nodots %(%{__python3} -Ic "import sys; sys.stdout.write(sys.version[:3].replace('.',''))")
2599dd
%python3_platform %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_platform())")
bae33e
%python3_platform_triplet %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('MULTIARCH'))")
bae33e
%python3_ext_suffix %(%{__python3} -Ic "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))")
2599dd
%py3dir %{_builddir}/python3-%{name}-%{version}-%{release}
2599dd
2599dd
%py3_shbang_opts -s
bae33e
%py3_shbang_opts_nodash %(opts=%{py3_shbang_opts}; echo ${opts#-})
bae33e
%py3_shebang_flags %(opts=%{py3_shbang_opts}; echo ${opts#-})
bae33e
%py3_shebang_fix %{expand:\\\
bae33e
  if [ -f /usr/bin/pathfix%{python3_version}.py ]; then
bae33e
    pathfix=/usr/bin/pathfix%{python3_version}.py
bae33e
  else
bae33e
    # unversioned pathfix.py provided by platform-python-devel
bae33e
    pathfix=/usr/bin/pathfix.py
bae33e
  fi
bae33e
  if [ -z "%{?py3_shebang_flags}" ]; then
bae33e
    shebang_flags="-k"
bae33e
  else
bae33e
    shebang_flags="-ka%{py3_shebang_flags}"
bae33e
  fi
bae33e
  $pathfix -pni %{__python3} $shebang_flags}
2599dd
2599dd
# Use the slashes after expand so that the command starts on the same line as
2599dd
# the macro
2599dd
%py3_build() %{expand:\\\
2599dd
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
2599dd
  %{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?*}
2599dd
  sleep 1
2599dd
}
2599dd
2599dd
%py3_build_egg() %{expand:\\\
2599dd
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
2599dd
  %{__python3} %{py_setup} %{?py_setup_args} bdist_egg %{?*}
2599dd
  sleep 1
2599dd
}
2599dd
2599dd
%py3_build_wheel() %{expand:\\\
2599dd
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
2599dd
  %{__python3} %{py_setup} %{?py_setup_args} bdist_wheel %{?*}
2599dd
  sleep 1
2599dd
}
2599dd
2599dd
%py3_install() %{expand:\\\
2599dd
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
2599dd
  %{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}
2599dd
}
2599dd
2599dd
%py3_install_egg() %{expand:\\\
2599dd
  mkdir -p %{buildroot}%{python3_sitelib}
2599dd
  CFLAGS="%{optflags}" %{__python3} -m easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python3_version}.egg %{?*}
2599dd
}
2599dd
2599dd
%py3_install_wheel() %{expand:\\\
2599dd
  CFLAGS="%{optflags}" %{__python3} -m pip install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps
2599dd
}
bae33e
bae33e
# This only supports Python 3.5+ and will never work with Python 2.
bae33e
# Hence, it has no Python version in the name.
bae33e
%pycached() %{lua:
bae33e
  path = rpm.expand("%{?*}")
bae33e
  if (string.sub(path, "-3") ~= ".py") then
bae33e
    rpm.expand("%{error:%%pycached can only be used with paths explicitly ending with .py}")
bae33e
  else
bae33e
    print(path)
bae33e
    pyminor = path:match("/python3.(%d+)/") or "*"
bae33e
    dirname = path:match("(.*/)")
bae33e
    modulename = path:match(".*/([^/]+).py")
bae33e
    print("\\n" .. dirname .. "__pycache__/" .. modulename .. ".cpython-3" .. pyminor .. "{,.opt-?}.pyc")
bae33e
  end
bae33e
}
bae33e
bae33e
# This is intended for Python 3 only, hence also no Python version in the name.
d6955c
%__pytest /usr/bin/pytest-%{_python3_pkgversion_with_dot}
bae33e
%pytest %{expand:\\\
bae33e
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
bae33e
  PATH="%{buildroot}%{_bindir}:$PATH"\\\
bae33e
  PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\
bae33e
  PYTHONDONTWRITEBYTECODE=1\\\
bae33e
  %__pytest}