%global python3_pkgversion 3.11 Name: python-django %global pkgname Django %global ver 4.2.11 #global pre ... %global real_version %{ver}%{?pre:%{pre}} Version: %{ver}%{?pre:~%{pre}} Release: 2.ac12.py3.11%{?dist} Summary: A high-level Python Web framework License: BSD-3-Clause URL: https://www.djangoproject.com/ Source: %{pypi_source %{pkgname} %{real_version}} Source: %{name}.rpmlintrc # This allows to build the package without tests, e.g. when bootstrapping new Python version %bcond tests 0 BuildArch: noarch %global _description %{expand: Django is a high-level Python Web framework that encourages rapid development and a clean, pragmatic design. It focuses on automating as much as possible and adhering to the DRY (Don't Repeat Yourself) principle.} %description %_description %package bash-completion Summary: Bash completion files for Django BuildRequires: bash-completion Requires: bash-completion # Make sure this replaces any other Django bash-completion package Provides: python-django-bash-completion-impl Conflicts: python-django-bash-completion-impl %description bash-completion This package contains the Bash completion files form Django high-level Python Web framework. %package -n python%{python3_pkgversion}-django-doc Summary: Documentation for Django Suggests: python3-django = %{version}-%{release} BuildRequires: make # Make sure this replaces any other Django doc package Provides: python-django-doc-impl Conflicts: python-django-doc-impl %description -n python%{python3_pkgversion}-django-doc This package contains the documentation for the Django high-level Python Web framework. %package -n python%{python3_pkgversion}-django Summary: A high-level Python Web framework Recommends: (%{name}-bash-completion = %{version}-%{release} if bash) BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-asgiref # see django/contrib/admin/static/admin/js/vendor/ Provides: bundled(jquery) = 3.6.4 Provides: bundled(select2) = 4.0.13 Provides: bundled(xregexp) = 3.2.0 # Make sure this replaces any other Django package Provides: python-django-impl Conflicts: python-django-impl %description -n python%{python3_pkgversion}-django %_description %prep %autosetup -p1 -n %{pkgname}-%{real_version} # hard-code python3 in django-admin pushd django for file in conf/project_template/manage.py-tpl ; do sed -i "s/\/env python/\/python3/" $file ; done popd # Use non optimised psycopg for tests # Not available in Fedora sed -i 's/psycopg\[binary\]>=3\.1\.8/psycopg>=3.1.8/' tests/requirements/postgres.txt # Remove unnecessary test BRs sed -i '/^pywatchman\b/d' tests/requirements/py3.txt sed -i '/^tzdata$/d' tests/requirements/py3.txt # Remove deps on code checkers/linters sed -i '/^black\b/d' tests/requirements/py3.txt sed -i '/^black\b/d' docs/requirements.txt sed -i '/^blacken-docs\b/d' docs/requirements.txt %generate_buildrequires %pyproject_buildrequires -r %{?with_tests:tests/requirements/{py3,postgres,mysql,oracle}.txt} docs/requirements.txt %build sed -i -re "s|sphinx-build|sphinx-build-%{python3_pkgversion}|" docs/Makefile %pyproject_wheel %install %pyproject_install %pyproject_save_files django # build documentation (cd docs && mkdir djangohtml && mkdir -p _build/{doctrees,html} && make html) cp -ar docs .. # install man pages (for the main executable only) mkdir -p %{buildroot}%{_mandir}/man1/ cp -p docs/man/* %{buildroot}%{_mandir}/man1/ # install bash completion script mkdir -p %{buildroot}%{bash_completions_dir} install -m 0644 -p extras/django_bash_completion \ %{buildroot}%{bash_completions_dir}/django-admin.py for file in django-admin django-admin-3 django-admin-%{python3_version} python3-django-admin manage.py ; do ln -s django-admin.py %{buildroot}%{bash_completions_dir}/$file done # Add backward compatible links to %%{_bindir} ln -s ./django-admin %{buildroot}%{_bindir}/django-admin-3 ln -s ./django-admin %{buildroot}%{_bindir}/django-admin-%{python3_version} ln -s ./django-admin %{buildroot}%{_bindir}/python3-django-admin # remove .po files find %{buildroot} -name "*.po" | xargs rm -f sed -i '/.po$/d' %{pyproject_files} %check # many contrib modules assume a configured app, "Requested setting INSTALLED_APPS..." # the rest needs optional dependencies %{pyproject_check_import \ -e 'django.contrib.*' \ -e 'django.core.serializers.pyyaml' \ -e 'django.db.backends.mysql*' \ -e 'django.db.backends.oracle*' \ -e 'django.db.backends.postgresql*'} %if %{with tests} cd %{_builddir}/%{pkgname}-%{real_version} export PYTHONPATH=$(pwd) cd tests %{python3} runtests.py --settings=test_sqlite --verbosity=2 --parallel 1 %endif rm -f %{buildroot}%{_bindir}/django-admin mv %{buildroot}%{_bindir}/django-admin-{3,%{python3_pkgversion}} mv %{buildroot}%{_bindir}/python{3,%{python3_pkgversion}}-django-admin for m in $(find %{buildroot}%{_mandir}/ -type f) ; do mv "$m" $(sed -re "s|(.*).([1-8])(.*)$|\1-%{python3_pkgversion}.\2\3|"<<<"$m"); done for m in $(find %{buildroot}%{_datadir}/locale/* -type f) ; do mv "$m" $(sed -re "s|(.*).mo$|\1-%{python3_pkgversion}.mo|"<<<"$m"); done for l in $(find %{buildroot}/usr/lib64/lib* -type f -o -type l) ; do mv "$l" $(sed -re "s|(.*).so(.*)$|\1-py%{python3_pkgversion}.so\2|"<<<"$l"); done for p in $(find %{buildroot}/usr/lib64/pkgconfig/* -type f) ; do mv "$p" $(sed -re "s|(.*).pc$|\1-py%{python3_pkgversion}.pc|"<<<"$p"); done %files bash-completion %{bash_completions_dir}/* %files -n python%{python3_pkgversion}-django-doc %doc docs/_build/html/* %files -n python%{python3_pkgversion}-django -f %{pyproject_files} %doc AUTHORS README.rst %license LICENSE %{_bindir}/django-admin-%{python3_version} %{_bindir}/python%{python3_pkgversion}-django-admin %{_mandir}/man1/django-admin-%{python3_pkgversion}.1* %changelog * Mon Apr 15 2024 Ding-Yi Chen - %{ver}%{?pre:~%{pre}}-2.ac12.py3.11 - Cut corner packaging