# # spec file # # Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via https://bugs.opensuse.org/ # %define skip_python36 1 %define skip_python38 1 %define skip_python39 1 %define skip_python311 1 %global flavor %{nil} %if "%{flavor}" == "test" %define psuffix -%{flavor} %bcond_without test %else %define psuffix %{nil} %bcond_with test %endif %{?sle15_python_module_pythons} Name: python-apipkg%{psuffix} Version: 3.0.1 Release: 3.1 Summary: Namespace control and lazy-import mechanism License: MIT Group: Development/Languages/Python URL: https://github.com/pytest-dev/apipkg/ Source: https://files.pythonhosted.org/packages/source/a/apipkg/apipkg-%{version}.tar.gz %if %{with test} BuildRequires: %{python_module apipkg = %{version}} BuildRequires: %{python_module pytest} %endif BuildRequires: %{python_module hatchling} BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools_scm} BuildRequires: %{python_module setuptools} BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros BuildArch: noarch %python_subpackages %description With apipkg you can control the exported namespace of a python package and greatly reduce the number of imports for your users. It is a small pure python module that works on CPython 2.7 and 3.4+, Jython and PyPy. It co-operates well with Python's help() system, custom importers (PEP302) and common command line completion tools. Usage is very simple: you can require 'apipkg' as a dependency or you can copy paste the ~200 lines of code into your project. %prep %autosetup -p1 -n apipkg-%{version} # Set the package version static, not dynamic, to build without the .git folder sed -i ':a;N;$!ba;s/dynamic = \[[^]]*\]/version = "%{version}"/g' pyproject.toml # Remove hatch-vcs dep to avoid cycles rm .gitignore sed -i '/tool.hatch.build.hooks.vcs/d' pyproject.toml cat << EOF > src/apipkg/_version.py version = "%{version}" version_tuple = tuple(map(int, version.split("."))) EOF %build %pyproject_wheel %install %if ! %{with test} %pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} %endif %check %if %{with test} # Do not test distribution version, it's broken because pytest doesn't require # python-py anymore %pytest -k 'not test_get_distribution_version' %endif %if ! %{with test} %files %{python_files} %license LICENSE %doc README.rst %{python_sitelib}/apipkg %{python_sitelib}/apipkg-%{version}*-info %endif %changelog * Fri Apr 21 2023 Dirk Müller - add sle15_python_module_pythons (jsc#PED-68) * Thu Apr 13 2023 Matej Cepl - Make calling of %%{sle15modernpython} optional. * Mon Feb 27 2023 Matej Cepl - Don't use fdupes -s, it hurts. * Wed Nov 30 2022 Daniel Garcia - Generate the _version.py file in %%prep to remove completely hatch-vcs from pyproject to make it build and run tests correctly * Wed Nov 30 2022 Daniel Garcia - Remove python-hatch-vcs dependency * Wed Nov 30 2022 Daniel Garcia - Remove python-py dependency * Tue Nov 29 2022 Daniel Garcia - Remove python_module macro definition - Update to 3.0.1: * restore tox.ini to support tox --current-env based packaging - 3.0.0 * add support for python 3.11 and drop dead pythons (thanks hukgo) * migrate to hatch * split up __init__.py * add some type annotations - 2.1.1 * drop the python 3.4 support marker, 2.1.0 broke it 2.1.0 will be yanked after release * Sun Oct 17 2021 Ben Greiner - Update to v2.1.0 * fix race condition for import of modules using apipkg.initpkg in Python 3.3+ by updating existing modules in-place rather than replacing in sys.modules with an apipkg.ApiModule instances. This race condition exists for import statements (and __import__) in Python 3.3+ where sys.modules is checked before obtaining an import lock, and for importlib.import_module in Python 3.11+ for the same reason. - Release 2.0.1 * fix race conditions for attribute creation - Release 2.0.0 * also transfer __spec__ attribute * make py.test hack more specific to avoid hiding real errors * switch from Travis CI to GitHub Actions * modernize package build * reformat code with black - Drop pytest4.patch * Tue Dec 8 2020 Benjamin Greiner - The now broken apicycle requires apipkg to be importable from elsewhere -- use src dir. * Sun Dec 6 2020 Matej Cepl - Split package into multibuild, to avoid apipkg -> pytest -> py -> apipkg cycle. * Fri Jul 19 2019 Ondřej Súkup - refresh pytest4.patch for pytest5 * Tue Feb 12 2019 Tomáš Chvátal - Add patch to fix build with pytest newer than 4: * pytest4.patch * Sun Aug 5 2018 mimi.vx@gmail.com - update to 1.5 - fixed dependencies * switch to setuptools_scm * avoid dict iteration (fixes issue on python3) * preserve __package__ - ths gets us better pep 302 compliance * Thu Apr 27 2017 aloisio@gmx.com - Fixed source URL * Fri Apr 21 2017 aloisio@gmx.com - Converted to single-spec - Enabled tests * Fri Mar 11 2016 tbechtold@suse.com - update to 1.4: - revert the automated version gathering - fix issue2 - adapt tests on Jython - handle jython __pkgpath__ missabstraction when running python from jar files - alias modules pointing to unimportable modules will return None for all their attributes instead of raising ImportError. This addresses python3.4 where any call to getframeinfo() can choke on sys.modules contents if pytest is not installed (because py.test.* imports it). - introduce apipkg.distribution_version(name) as helper to obtain the current version number of a package from install metadata its used by default with the package name - add an eagerloading option and eagerload automatically if bpython is used (workaround for their monkeypatching) - Switch to use .tar.gz sdist instead of zip - Install LICENSE - BuildRequires python-setuptools * Tue Nov 20 2012 saschpe@suse.de - Initial version