From 7e892b51638a2c7c6d6edb5dec5f83fddea4fd17 Mon Sep 17 00:00:00 2001 From: u Date: Sun, 12 May 2024 19:33:22 +0300 Subject: [PATCH 1/5] fix bug: AttributeError: 'Namespace' object has no attribute 'localfile' for fetch command --- py2pack/__init__.py | 12 +- py2pack/templates/fedora.spec | 120 +++++++++---- py2pack/version.py | 2 +- test/examples/py2pack-fedora-augmented.spec | 80 +++++++++ test/examples/py2pack-fedora.spec | 169 ------------------ .../sampleproject-fedora-augmented.spec | 84 +++++++++ test/examples/sampleproject-mageia.spec | 32 ++++ .../sampleproject-opensuse-legacy.spec | 84 +++++++++ test/examples/sampleproject-opensuse.dsc | 8 + test/test_template.py | 2 +- 10 files changed, 382 insertions(+), 211 deletions(-) mode change 100644 => 100755 py2pack/__init__.py create mode 100644 test/examples/py2pack-fedora-augmented.spec delete mode 100644 test/examples/py2pack-fedora.spec create mode 100644 test/examples/sampleproject-fedora-augmented.spec create mode 100644 test/examples/sampleproject-mageia.spec create mode 100644 test/examples/sampleproject-opensuse-legacy.spec create mode 100644 test/examples/sampleproject-opensuse.dsc diff --git a/py2pack/__init__.py b/py2pack/__init__.py old mode 100644 new mode 100755 index 5c0dc81..d654465 --- a/py2pack/__init__.py +++ b/py2pack/__init__.py @@ -97,9 +97,9 @@ def _get_template_dirs(): is important. The first found template from the first found dir wins!""" return filter(lambda x: os.path.exists(x), [ # user dir - os.path.join(os.path.expanduser('~'), '.py2pack', 'templates'), + os.path.join(os.path.expanduser('~'), '.py2pack/templates'), # system wide dir - os.path.join('/', 'usr', 'share', 'py2pack', 'templates'), + '/usr/share/py2pack/templates', # usually inside the site-packages dir os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates'), ]) @@ -339,7 +339,7 @@ def generate(args): warnings.warn("the '--run' switch is deprecated and a noop", DeprecationWarning) - fetch_data(args) + fetch_local_data(args) if not args.template: args.template = file_template_list()[0] if not args.filename: @@ -393,7 +393,7 @@ def generate(args): outfile.close() -def fetch_data(args): +def fetch_local_data(args): localfile = args.localfile local = args.local @@ -407,6 +407,10 @@ def fetch_data(args): args.fetched_data = data args.version = args.fetched_data['info']['version'] return + fetch_data(args) + + +def fetch_data(args): args.fetched_data = pypi_json(args.name, args.version) urls = args.fetched_data['urls'] if len(urls) == 0: diff --git a/py2pack/templates/fedora.spec b/py2pack/templates/fedora.spec index e5db1d6..611cbe8 100644 --- a/py2pack/templates/fedora.spec +++ b/py2pack/templates/fedora.spec @@ -1,61 +1,109 @@ -# -# spec file for package python-{{ name }} -# -# Copyright (c) {{ year }} {{ user_name }}. -# - -Name: python-{{ name }} +%define pypi_name {{ name }} +%define python_name python3-%{pypi_name} +Name: python-%{pypi_name} Version: {{ version }} -Release: 0 +Release: %autorelease Summary: {{ summary }} + +# Check if the automatically generated License and its spelling is correct for Fedora +# https://docs.fedoraproject.org/en-US/packaging-guidelines/LicensingGuidelines/ License: {{ license }} URL: {{ home_page }} Source: {{ source_url|replace(version, '%{version}') }} -BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: python-devel {%- if requires_python %} = {{ requires_python }} {% endif %} -{%- for req in requires %} -BuildRequires: python-{{ req|replace('(','')|replace(')','') }} -Requires: python-{{ req|replace('(','')|replace(')','') }} + +BuildRequires: pyproject-rpm-macros +BuildRequires: python-devel +%if %{undefined python_module} +%define python_module() python3dist(%1) +%endif + +{%- set build_requires_plus_pip = ((build_requires if build_requires and build_requires is not none else []) + + ['pip']) %} +{%- for req in build_requires_plus_pip |sort %} +BuildRequires: %{python_module {{ req }}} +{%- endfor %} +{%- if (install_requires and install_requires is not none) or (tests_require and tests_require is not none) %} +# SECTION test requirements +%if %{with test} +{%- if install_requires and install_requires is not none %} +{%- for req in install_requires|reject("in",build_requires)|sort %} +BuildRequires: %{python_module {{ req }}} {%- endfor %} -{%- for req in install_requires %} -BuildRequires: python-{{ req|replace('(','')|replace(')','') }} -Requires: python-{{ req|replace('(','')|replace(')','') }} +{%- endif %} +{%- if tests_require and tests_require is not none %} +{%- for req in tests_require|sort|reject("in",build_requires|sort) %} +BuildRequires: %{python_module {{ req }}} {%- endfor %} -{%- if extras_require %} +{%- endif %} +%endif +# /SECTION +{%- endif %} +{%- if source_url.endswith('.zip') %} +BuildRequires: unzip +{%- endif %} +BuildRequires: fdupes +{%- if install_requires and install_requires is not none %} +{%- for req in install_requires|sort %} +Requires: %{python_module {{ req }}} +{%- endfor %} +{%- endif %} +{%- if extras_require and extras_require is not none %} {%- for reqlist in extras_require.values() %} {%- for req in reqlist %} -Suggests: python-{{ req|replace('(','')|replace(')','') }} +Suggests: %{python_module {{ req }}} {%- endfor %} {%- endfor %} {%- endif %} +{%- if not has_ext_modules %} +BuildArch: noarch +{%- endif %} + +# Fill in the actual package description to submit package to Fedora +%global _description %{expand: +{{ description }}} + +%description %_description + +%package -n %{python_name} +Summary: %{summary} + +%description -n %{python_name} %_description -%description -{{ description }} %prep -%setup -q -n {{ name }}-%{version} +%autosetup -p1 -n %{pypi_name}-%{version} %build -{%- if is_extension %} -export CFLAGS="%{optflags}" -{%- endif %} -python setup.py build +%pyproject_wheel + %install -python setup.py install --prefix=%{_prefix} --root=%{buildroot} +%pyproject_install +{%- set scripts_or_console_scripts = ( + (scripts|map('basename')|list if scripts and scripts is not none else []) + + (console_scripts if console_scripts and console_scripts is not none else [])) %} +#{%- for script in scripts_or_console_scripts %} +#%python_clone -a %{buildroot}%{_bindir}/{{ script }} +#{%- endfor %} +# For official Fedora packages, including files with '*' +auto is not allowed +# Replace it with a list of relevant Python modules/globs and list extra files in %%files +%pyproject_save_files '*' +auto -%clean -rm -rf %{buildroot} -%files -%defattr(-,root,root,-) -{%- if doc_files %} -%doc {{ doc_files|join(" ") }} +{%- if testsuite or test_suite %} +%if %{with test} +%check +{%- if has_ext_modules %} +%pytest_arch +{%- else %} +%pytest +{%- endif %} +%endif {%- endif %} -{%- for script in scripts|default([], true) %} -%{_bindir}/{{ script }} -{%- endfor %} -%{python_sitelib}/* + +%files -n %{python_name} -f %{pyproject_files} %changelog +%autochangelog + diff --git a/py2pack/version.py b/py2pack/version.py index a89bfeb..e7da665 100644 --- a/py2pack/version.py +++ b/py2pack/version.py @@ -16,6 +16,6 @@ # limitations under the License. # this one is read by hatch or hatchling during build -__version__ = "0.9.0" +__version__ = "0.9.3" version = __version__ diff --git a/test/examples/py2pack-fedora-augmented.spec b/test/examples/py2pack-fedora-augmented.spec new file mode 100644 index 0000000..06330f0 --- /dev/null +++ b/test/examples/py2pack-fedora-augmented.spec @@ -0,0 +1,80 @@ +%define pypi_name py2pack +%define python_name python3-%{pypi_name} +Name: python-%{pypi_name} +Version: 0.8.5 +Release: %autorelease +Summary: Generate distribution packages from PyPI + +# Check if the automatically generated License and its spelling is correct for Fedora +# https://docs.fedoraproject.org/en-US/packaging-guidelines/LicensingGuidelines/ +License: Apache-2.0 +URL: http://github.com/openSUSE/py2pack +Source: https://files.pythonhosted.org/packages/source/p/py2pack/py2pack-%{version}.tar.gz + +BuildRequires: pyproject-rpm-macros +BuildRequires: python-devel +%if %{undefined python_module} +%define python_module() python3dist(%1) +%endif +BuildRequires: %{python_module pbr >= 1.8} +BuildRequires: %{python_module pip} +BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} +# SECTION test requirements +%if %{with test} +BuildRequires: %{python_module Jinja2} +BuildRequires: %{python_module metaextract} +BuildRequires: %{python_module six} +BuildRequires: %{python_module coverage} +BuildRequires: %{python_module ddt} +BuildRequires: %{python_module flake8} +BuildRequires: %{python_module pytest} +BuildRequires: %{python_module Sphinx >= 1.2.1} +BuildRequires: %{python_module sphinxcontrib.programoutput} +%endif +# /SECTION +BuildRequires: fdupes +Requires: %{python_module Jinja2} +Requires: %{python_module metaextract} +Requires: %{python_module setuptools} +Requires: %{python_module six} +Suggests: %{python_module typing} +BuildArch: noarch + +# Fill in the actual package description to submit package to Fedora +%global _description %{expand: +Generate distribution packages from PyPI} + +%description %_description + +%package -n %{python_name} +Summary: %{summary} + +%description -n %{python_name} %_description + + +%prep +%autosetup -p1 -n %{pypi_name}-%{version} + +%build +%pyproject_wheel + + +%install +%pyproject_install +# +#%python_clone -a %{buildroot}%{_bindir}/py2pack +# +# For official Fedora packages, including files with '*' +auto is not allowed +# Replace it with a list of relevant Python modules/globs and list extra files in %%files +%pyproject_save_files '*' +auto +%if %{with test} +%check +%pytest +%endif + +%files -n %{python_name} -f %{pyproject_files} + +%changelog +%autochangelog + diff --git a/test/examples/py2pack-fedora.spec b/test/examples/py2pack-fedora.spec deleted file mode 100644 index be3ff94..0000000 --- a/test/examples/py2pack-fedora.spec +++ /dev/null @@ -1,169 +0,0 @@ -# -# spec file for package python-py2pack -# -# Copyright (c) __YEAR__ __USER__. -# - -Name: python-py2pack -Version: 0.8.5 -Release: 0 -Summary: Generate distribution packages from PyPI -License: Apache-2.0 -URL: http://github.com/openSUSE/py2pack -Source: https://files.pythonhosted.org/packages/source/p/py2pack/py2pack-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: python-devel - -%description -Py2pack: Generate distribution packages from PyPI -================================================= - -.. image:: https://travis-ci.org/openSUSE/py2pack.png?branch=master - :target: https://travis-ci.org/openSUSE/py2pack - - -This script allows to generate RPM spec or DEB dsc files from Python modules. -It allows to list Python modules or search for them on the Python Package Index -(PyPI). Conveniently, it can fetch tarballs and changelogs making it an -universal tool to package Python modules. - - -Installation ------------- - -To install py2pack from the `Python Package Index`_, simply: - -.. code-block:: bash - - $ pip install py2pack - -Or, if you absolutely must: - -.. code-block:: bash - - $ easy_install py2pack - -But, you really shouldn't do that. Lastly, you can check your distro of choice -if they provide packages. For openSUSE, you can find packages in the `Open -Build Service`_ for all releases. If you happen to use openSUSE:Factory (the -rolling release / development version), simply: - -.. code-block:: bash - - $ sudo zypper install python-py2pack - - -Usage ------ - -Lets suppose you want to package zope.interface_ and you don't know how it is named -exactly. First of all, you can search for it and download the source tarball if -you found the correct module: - -.. code-block:: bash - - $ py2pack search zope.interface - searching for module zope.interface... - found zope.interface-3.6.1 - $ py2pack fetch zope.interface - downloading package zope.interface-3.6.1... - from http://pypi.python.org/packages/source/z/zope.interface/zope.interface-3.6.1.tar.gz - - -As a next step you may want to generate a package recipe for your distribution. -For RPM_-based distributions (let's use openSUSE_ as an example), you want to -generate a spec file (named 'python-zope.interface.spec'): - -.. code-block:: bash - - $ py2pack generate zope.interface -t opensuse.spec -f python-zope.interface.spec - -The source tarball and the package recipe is all you need to generate the RPM_ -(or DEB_) file. -This final step may depend on which distribution you use. Again, -for openSUSE_ (and by using the `Open Build Service`_), the complete recipe is: - -.. code-block:: bash - - $ osc mkpac python-zope.interface - $ cd python-zope.interface - $ py2pack fetch zope.interface - $ py2pack generate zope.interface -f python-zope.interface.spec - $ osc build - ... - -Depending on the module, you may have to adapt the resulting spec file slightly. -To get further help about py2pack usage, issue the following command: - -.. code-block:: bash - - $ py2pack help - - -Hacking and contributing ------------------------- - -You can test py2pack from your git checkout by executing the py2pack module: - -.. code-block:: bash - - $ python -m py2pack - -Fork `the repository`_ on Github to start making your changes to the **master** -branch (or branch off of it). Don't forget to write a test for fixed issues or -implemented features whenever appropriate. You can invoke the testsuite from -the repository root directory via `tox`_: - -.. code-block:: bash - - $ tox - -To run a single test class via `tox`_, use i.e.: - -.. code-block:: bash - - $ tox -epy27 test.test_py2pack:Py2packTestCase - - -You can also run `pytest`_ directly: - -.. code-block:: bash - - $ pytest - -It assumes you have the test dependencies installed (available on PYTHONPATH) -on your system. - -:copyright: (c) 2013 Sascha Peilicke. -:license: Apache-2.0, see LICENSE for more details. - - -.. _argparse: http://pypi.python.org/pypi/argparse -.. _Jinja2: http://pypi.python.org/pypi/Jinja2 -.. _zope.interface: http://pypi.python.org/pypi/zope.interface/ -.. _openSUSE: http://www.opensuse.org/en/ -.. _RPM: http://en.wikipedia.org/wiki/RPM_Package_Manager -.. _DEB: http://en.wikipedia.org/wiki/Deb_(file_format) -.. _`Python Package Index`: https://pypi.org/ -.. _`Open Build Service`: https://build.opensuse.org/package/show/devel:languages:python/python-py2pack -.. _`the repository`: https://github.com/openSUSE/py2pack -.. _`pytest`: https://github.com/pytest-dev/pytest -.. _`tox`: http://testrun.org/tox - -%prep -%setup -q -n py2pack-%{version} - -%build -python setup.py build - -%install -python setup.py install --prefix=%{_prefix} --root=%{buildroot} - -%clean -rm -rf %{buildroot} - -%files -%defattr(-,root,root,-) -%{python_sitelib}/* - -%changelog diff --git a/test/examples/sampleproject-fedora-augmented.spec b/test/examples/sampleproject-fedora-augmented.spec new file mode 100644 index 0000000..5ccce9d --- /dev/null +++ b/test/examples/sampleproject-fedora-augmented.spec @@ -0,0 +1,84 @@ +%define pypi_name sampleproject +%define python_name python3-%{pypi_name} +Name: python-%{pypi_name} +Version: 3.0.0 +Release: %autorelease +Summary: A sample Python project + +# Check if the automatically generated License and its spelling is correct for Fedora +# https://docs.fedoraproject.org/en-US/packaging-guidelines/LicensingGuidelines/ +License: Copyright (c) 2016 The Python Packaging Authority (PyPA) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + (FIXME:No SPDX) +URL: https://github.com/pypa/sampleproject +Source: https://files.pythonhosted.org/packages/source/s/sampleproject/sampleproject-%{version}.tar.gz + +BuildRequires: pyproject-rpm-macros +BuildRequires: python-devel +%if %{undefined python_module} +%define python_module() python3dist(%1) +%endif +BuildRequires: %{python_module pip} +BuildRequires: %{python_module setuptools >= 43.0.0} +BuildRequires: %{python_module wheel} +# SECTION test requirements +%if %{with test} +BuildRequires: %{python_module peppercorn} +BuildRequires: %{python_module coverage} +%endif +# /SECTION +BuildRequires: fdupes +Requires: %{python_module peppercorn} +Suggests: %{python_module check-manifest} +BuildArch: noarch + +# Fill in the actual package description to submit package to Fedora +%global _description %{expand: +A sample Python project} + +%description %_description + +%package -n %{python_name} +Summary: %{summary} + +%description -n %{python_name} %_description + + +%prep +%autosetup -p1 -n %{pypi_name}-%{version} + +%build +%pyproject_wheel + + +%install +%pyproject_install +# +#%python_clone -a %{buildroot}%{_bindir}/sample +# +# For official Fedora packages, including files with '*' +auto is not allowed +# Replace it with a list of relevant Python modules/globs and list extra files in %%files +%pyproject_save_files '*' +auto + +%files -n %{python_name} -f %{pyproject_files} + +%changelog +%autochangelog + diff --git a/test/examples/sampleproject-mageia.spec b/test/examples/sampleproject-mageia.spec new file mode 100644 index 0000000..4f0f033 --- /dev/null +++ b/test/examples/sampleproject-mageia.spec @@ -0,0 +1,32 @@ +%define mod_name sampleproject + +Name: python-%{mod_name} +Version: 3.0.0 +Release: %mkrel 1 +Url: +Summary: A sample Python project +License: Copyright (c) 2016 The Python Packaging Authority (PyPA) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. (FIXME:No SPDX) +Group: Development/Python +Source: https://files.pythonhosted.org/packages/source/s/sampleproject/sampleproject-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot +BuildRequires: python-devel + +%description +A sample Python project + + +%prep +%setup -q -n %{mod_name}-%{version} + +%build +%{__python} setup.py build + +%install +%{__python} setup.py install --prefix=%{_prefix} --root=%{buildroot} + +%clean +rm -rf %{buildroot} + +%files -f +%defattr(-,root,root) +%{python_sitelib}/* diff --git a/test/examples/sampleproject-opensuse-legacy.spec b/test/examples/sampleproject-opensuse-legacy.spec new file mode 100644 index 0000000..407452b --- /dev/null +++ b/test/examples/sampleproject-opensuse-legacy.spec @@ -0,0 +1,84 @@ +# +# spec file for package python-sampleproject +# +# Copyright (c) __YEAR__ SUSE LINUX GmbH, Nuernberg, Germany. +# +# 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/ + + +Name: python-sampleproject +Version: 3.0.0 +Release: 0 +Summary: A sample Python project +License: Copyright (c) 2016 The Python Packaging Authority (PyPA) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. (FIXME:No SPDX) +URL: +Source: https://files.pythonhosted.org/packages/source/s/sampleproject/sampleproject-%{version}.tar.gz +BuildRequires: python-setuptools +BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildArch: noarch + +%description +# A sample Python project + +![Python Logo](https://www.python.org/static/community_logos/python-logo.png "Sample inline image") + +A sample project that exists as an aid to the [Python Packaging User +Guide][packaging guide]'s [Tutorial on Packaging and Distributing +Projects][distribution tutorial]. + +This project does not aim to cover best practices for Python project +development as a whole. For example, it does not provide guidance or tool +recommendations for version control, documentation, or testing. + +[The source for this project is available here][src]. + +The metadata for a Python project is defined in the `pyproject.toml` file, +an example of which is included in this project. You should edit this file +accordingly to adapt this sample project to your needs. + +---- + +This is the README file for the project. + +The file should use UTF-8 encoding and can be written using +[reStructuredText][rst] or [markdown][md use] with the appropriate [key set][md +use]. It will be used to generate the project webpage on PyPI and will be +displayed as the project homepage on common code-hosting services, and should be +written for that purpose. + +Typical contents for this file would include an overview of the project, basic +usage examples, etc. Generally, including the project changelog in here is not a +good idea, although a simple “What's New” section for the most recent version +may be appropriate. + +[packaging guide]: https://packaging.python.org +[distribution tutorial]: https://packaging.python.org/tutorials/packaging-projects/ +[src]: https://github.com/pypa/sampleproject +[rst]: http://docutils.sourceforge.net/rst.html +[md]: https://tools.ietf.org/html/rfc7764#section-3.5 "CommonMark variant" +[md use]: https://packaging.python.org/specifications/core-metadata/#description-content-type-optional + + +%prep +%autosetup -p1 -n sampleproject-%{version} + +%build +python setup.py build + +%install +python setup.py install --prefix=%{_prefix} --root=%{buildroot} + +%files +%defattr(-,root,root,-) +%{python_sitelib}/* + +%changelog diff --git a/test/examples/sampleproject-opensuse.dsc b/test/examples/sampleproject-opensuse.dsc new file mode 100644 index 0000000..c967d4e --- /dev/null +++ b/test/examples/sampleproject-opensuse.dsc @@ -0,0 +1,8 @@ +Format: 1.0 +Source: sampleproject +Version: 3.0.0 +Binary: python-sampleproject +Maintainer: __USER__ +Architecture: any +Standards-Version: 3.7.1 +Build-Depends: debhelper (>= 4.0.0), python-dev diff --git a/test/test_template.py b/test/test_template.py index c08ea40..d4dd8b7 100644 --- a/test/test_template.py +++ b/test/test_template.py @@ -44,7 +44,7 @@ class Args(object): @pytest.mark.parametrize('template, fetch_tarball', - [('fedora.spec', False), + [('fedora.spec', True), ('mageia.spec', False), ('opensuse-legacy.spec', False), ('opensuse.dsc', False), From 6e4abeaa5eae981d0f90bbaad88cc24c45bd4f4f Mon Sep 17 00:00:00 2001 From: huakim <92579808+huakim@users.noreply.github.com> Date: Mon, 20 May 2024 18:26:40 +0300 Subject: [PATCH 2/5] Update version.py --- py2pack/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py2pack/version.py b/py2pack/version.py index e7da665..a89bfeb 100644 --- a/py2pack/version.py +++ b/py2pack/version.py @@ -16,6 +16,6 @@ # limitations under the License. # this one is read by hatch or hatchling during build -__version__ = "0.9.3" +__version__ = "0.9.0" version = __version__ From ae62a674bd58992b0786d9fe5b1086b605d1fe3c Mon Sep 17 00:00:00 2001 From: huakim <92579808+huakim@users.noreply.github.com> Date: Mon, 20 May 2024 18:37:16 +0300 Subject: [PATCH 3/5] Update __init__.py --- py2pack/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py2pack/__init__.py b/py2pack/__init__.py index 9eb490f..6c7f7f9 100755 --- a/py2pack/__init__.py +++ b/py2pack/__init__.py @@ -98,9 +98,9 @@ def _get_template_dirs(): is important. The first found template from the first found dir wins!""" return filter(lambda x: os.path.exists(x), [ # user dir - os.path.join(os.path.expanduser('~'), '.py2pack/templates'), + os.path.join(os.path.expanduser('~'), '.py2pack', 'templates'), # system wide dir - '/usr/share/py2pack/templates', + os.path.join('/', 'usr', 'share', 'py2pack', 'templates'), # usually inside the site-packages dir os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates'), ]) From c4a5e1815bb9e3a5083e7ded8f395523d8457b80 Mon Sep 17 00:00:00 2001 From: huakim <92579808+huakim@users.noreply.github.com> Date: Mon, 20 May 2024 18:38:48 +0300 Subject: [PATCH 4/5] Update __init__.py --- py2pack/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py2pack/__init__.py b/py2pack/__init__.py index 6c7f7f9..3601065 100755 --- a/py2pack/__init__.py +++ b/py2pack/__init__.py @@ -410,7 +410,7 @@ def fetch_local_data(args): local = args.local if not localfile and local: - localfile = f'{args.name}.egg-info/PKG-INFO' + localfile = os.path.join(f'{args.name}.egg-info', 'PKG-INFO') if os.path.isfile(localfile): try: data = pypi_json_file(localfile) From c686a431a50622dd776612a8ae3ffecbbc074a7c Mon Sep 17 00:00:00 2001 From: huakim Date: Mon, 20 May 2024 19:13:00 +0300 Subject: [PATCH 5/5] fix bug: AttributeError: 'Namespace' object has no attribute 'localfile' for fetch command --- py2pack/__init__.py | 10 +- py2pack/templates/fedora.spec | 120 +++++++++---- test/examples/py2pack-fedora-augmented.spec | 80 +++++++++ test/examples/py2pack-fedora.spec | 169 ------------------ .../sampleproject-fedora-augmented.spec | 84 +++++++++ test/examples/sampleproject-mageia.spec | 32 ++++ .../sampleproject-opensuse-legacy.spec | 84 +++++++++ test/examples/sampleproject-opensuse.dsc | 8 + test/test_template.py | 2 +- 9 files changed, 380 insertions(+), 209 deletions(-) mode change 100644 => 100755 py2pack/__init__.py create mode 100644 test/examples/py2pack-fedora-augmented.spec delete mode 100644 test/examples/py2pack-fedora.spec create mode 100644 test/examples/sampleproject-fedora-augmented.spec create mode 100644 test/examples/sampleproject-mageia.spec create mode 100644 test/examples/sampleproject-opensuse-legacy.spec create mode 100644 test/examples/sampleproject-opensuse.dsc diff --git a/py2pack/__init__.py b/py2pack/__init__.py old mode 100644 new mode 100755 index a43bb09..3601065 --- a/py2pack/__init__.py +++ b/py2pack/__init__.py @@ -351,7 +351,7 @@ def generate(args): warnings.warn("the '--run' switch is deprecated and a noop", DeprecationWarning) - fetch_data(args) + fetch_local_data(args) if not args.template: args.template = file_template_list()[0] if not args.filename: @@ -405,12 +405,12 @@ def generate(args): outfile.close() -def fetch_data(args): +def fetch_local_data(args): localfile = args.localfile local = args.local if not localfile and local: - localfile = f'{args.name}.egg-info/PKG-INFO' + localfile = os.path.join(f'{args.name}.egg-info', 'PKG-INFO') if os.path.isfile(localfile): try: data = pypi_json_file(localfile) @@ -419,6 +419,10 @@ def fetch_data(args): args.fetched_data = data args.version = args.fetched_data['info']['version'] return + fetch_data(args) + + +def fetch_data(args): args.fetched_data = pypi_json(args.name, args.version) urls = args.fetched_data['urls'] if len(urls) == 0: diff --git a/py2pack/templates/fedora.spec b/py2pack/templates/fedora.spec index e5db1d6..611cbe8 100644 --- a/py2pack/templates/fedora.spec +++ b/py2pack/templates/fedora.spec @@ -1,61 +1,109 @@ -# -# spec file for package python-{{ name }} -# -# Copyright (c) {{ year }} {{ user_name }}. -# - -Name: python-{{ name }} +%define pypi_name {{ name }} +%define python_name python3-%{pypi_name} +Name: python-%{pypi_name} Version: {{ version }} -Release: 0 +Release: %autorelease Summary: {{ summary }} + +# Check if the automatically generated License and its spelling is correct for Fedora +# https://docs.fedoraproject.org/en-US/packaging-guidelines/LicensingGuidelines/ License: {{ license }} URL: {{ home_page }} Source: {{ source_url|replace(version, '%{version}') }} -BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: python-devel {%- if requires_python %} = {{ requires_python }} {% endif %} -{%- for req in requires %} -BuildRequires: python-{{ req|replace('(','')|replace(')','') }} -Requires: python-{{ req|replace('(','')|replace(')','') }} + +BuildRequires: pyproject-rpm-macros +BuildRequires: python-devel +%if %{undefined python_module} +%define python_module() python3dist(%1) +%endif + +{%- set build_requires_plus_pip = ((build_requires if build_requires and build_requires is not none else []) + + ['pip']) %} +{%- for req in build_requires_plus_pip |sort %} +BuildRequires: %{python_module {{ req }}} +{%- endfor %} +{%- if (install_requires and install_requires is not none) or (tests_require and tests_require is not none) %} +# SECTION test requirements +%if %{with test} +{%- if install_requires and install_requires is not none %} +{%- for req in install_requires|reject("in",build_requires)|sort %} +BuildRequires: %{python_module {{ req }}} {%- endfor %} -{%- for req in install_requires %} -BuildRequires: python-{{ req|replace('(','')|replace(')','') }} -Requires: python-{{ req|replace('(','')|replace(')','') }} +{%- endif %} +{%- if tests_require and tests_require is not none %} +{%- for req in tests_require|sort|reject("in",build_requires|sort) %} +BuildRequires: %{python_module {{ req }}} {%- endfor %} -{%- if extras_require %} +{%- endif %} +%endif +# /SECTION +{%- endif %} +{%- if source_url.endswith('.zip') %} +BuildRequires: unzip +{%- endif %} +BuildRequires: fdupes +{%- if install_requires and install_requires is not none %} +{%- for req in install_requires|sort %} +Requires: %{python_module {{ req }}} +{%- endfor %} +{%- endif %} +{%- if extras_require and extras_require is not none %} {%- for reqlist in extras_require.values() %} {%- for req in reqlist %} -Suggests: python-{{ req|replace('(','')|replace(')','') }} +Suggests: %{python_module {{ req }}} {%- endfor %} {%- endfor %} {%- endif %} +{%- if not has_ext_modules %} +BuildArch: noarch +{%- endif %} + +# Fill in the actual package description to submit package to Fedora +%global _description %{expand: +{{ description }}} + +%description %_description + +%package -n %{python_name} +Summary: %{summary} + +%description -n %{python_name} %_description -%description -{{ description }} %prep -%setup -q -n {{ name }}-%{version} +%autosetup -p1 -n %{pypi_name}-%{version} %build -{%- if is_extension %} -export CFLAGS="%{optflags}" -{%- endif %} -python setup.py build +%pyproject_wheel + %install -python setup.py install --prefix=%{_prefix} --root=%{buildroot} +%pyproject_install +{%- set scripts_or_console_scripts = ( + (scripts|map('basename')|list if scripts and scripts is not none else []) + + (console_scripts if console_scripts and console_scripts is not none else [])) %} +#{%- for script in scripts_or_console_scripts %} +#%python_clone -a %{buildroot}%{_bindir}/{{ script }} +#{%- endfor %} +# For official Fedora packages, including files with '*' +auto is not allowed +# Replace it with a list of relevant Python modules/globs and list extra files in %%files +%pyproject_save_files '*' +auto -%clean -rm -rf %{buildroot} -%files -%defattr(-,root,root,-) -{%- if doc_files %} -%doc {{ doc_files|join(" ") }} +{%- if testsuite or test_suite %} +%if %{with test} +%check +{%- if has_ext_modules %} +%pytest_arch +{%- else %} +%pytest +{%- endif %} +%endif {%- endif %} -{%- for script in scripts|default([], true) %} -%{_bindir}/{{ script }} -{%- endfor %} -%{python_sitelib}/* + +%files -n %{python_name} -f %{pyproject_files} %changelog +%autochangelog + diff --git a/test/examples/py2pack-fedora-augmented.spec b/test/examples/py2pack-fedora-augmented.spec new file mode 100644 index 0000000..06330f0 --- /dev/null +++ b/test/examples/py2pack-fedora-augmented.spec @@ -0,0 +1,80 @@ +%define pypi_name py2pack +%define python_name python3-%{pypi_name} +Name: python-%{pypi_name} +Version: 0.8.5 +Release: %autorelease +Summary: Generate distribution packages from PyPI + +# Check if the automatically generated License and its spelling is correct for Fedora +# https://docs.fedoraproject.org/en-US/packaging-guidelines/LicensingGuidelines/ +License: Apache-2.0 +URL: http://github.com/openSUSE/py2pack +Source: https://files.pythonhosted.org/packages/source/p/py2pack/py2pack-%{version}.tar.gz + +BuildRequires: pyproject-rpm-macros +BuildRequires: python-devel +%if %{undefined python_module} +%define python_module() python3dist(%1) +%endif +BuildRequires: %{python_module pbr >= 1.8} +BuildRequires: %{python_module pip} +BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} +# SECTION test requirements +%if %{with test} +BuildRequires: %{python_module Jinja2} +BuildRequires: %{python_module metaextract} +BuildRequires: %{python_module six} +BuildRequires: %{python_module coverage} +BuildRequires: %{python_module ddt} +BuildRequires: %{python_module flake8} +BuildRequires: %{python_module pytest} +BuildRequires: %{python_module Sphinx >= 1.2.1} +BuildRequires: %{python_module sphinxcontrib.programoutput} +%endif +# /SECTION +BuildRequires: fdupes +Requires: %{python_module Jinja2} +Requires: %{python_module metaextract} +Requires: %{python_module setuptools} +Requires: %{python_module six} +Suggests: %{python_module typing} +BuildArch: noarch + +# Fill in the actual package description to submit package to Fedora +%global _description %{expand: +Generate distribution packages from PyPI} + +%description %_description + +%package -n %{python_name} +Summary: %{summary} + +%description -n %{python_name} %_description + + +%prep +%autosetup -p1 -n %{pypi_name}-%{version} + +%build +%pyproject_wheel + + +%install +%pyproject_install +# +#%python_clone -a %{buildroot}%{_bindir}/py2pack +# +# For official Fedora packages, including files with '*' +auto is not allowed +# Replace it with a list of relevant Python modules/globs and list extra files in %%files +%pyproject_save_files '*' +auto +%if %{with test} +%check +%pytest +%endif + +%files -n %{python_name} -f %{pyproject_files} + +%changelog +%autochangelog + diff --git a/test/examples/py2pack-fedora.spec b/test/examples/py2pack-fedora.spec deleted file mode 100644 index be3ff94..0000000 --- a/test/examples/py2pack-fedora.spec +++ /dev/null @@ -1,169 +0,0 @@ -# -# spec file for package python-py2pack -# -# Copyright (c) __YEAR__ __USER__. -# - -Name: python-py2pack -Version: 0.8.5 -Release: 0 -Summary: Generate distribution packages from PyPI -License: Apache-2.0 -URL: http://github.com/openSUSE/py2pack -Source: https://files.pythonhosted.org/packages/source/p/py2pack/py2pack-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: python-devel - -%description -Py2pack: Generate distribution packages from PyPI -================================================= - -.. image:: https://travis-ci.org/openSUSE/py2pack.png?branch=master - :target: https://travis-ci.org/openSUSE/py2pack - - -This script allows to generate RPM spec or DEB dsc files from Python modules. -It allows to list Python modules or search for them on the Python Package Index -(PyPI). Conveniently, it can fetch tarballs and changelogs making it an -universal tool to package Python modules. - - -Installation ------------- - -To install py2pack from the `Python Package Index`_, simply: - -.. code-block:: bash - - $ pip install py2pack - -Or, if you absolutely must: - -.. code-block:: bash - - $ easy_install py2pack - -But, you really shouldn't do that. Lastly, you can check your distro of choice -if they provide packages. For openSUSE, you can find packages in the `Open -Build Service`_ for all releases. If you happen to use openSUSE:Factory (the -rolling release / development version), simply: - -.. code-block:: bash - - $ sudo zypper install python-py2pack - - -Usage ------ - -Lets suppose you want to package zope.interface_ and you don't know how it is named -exactly. First of all, you can search for it and download the source tarball if -you found the correct module: - -.. code-block:: bash - - $ py2pack search zope.interface - searching for module zope.interface... - found zope.interface-3.6.1 - $ py2pack fetch zope.interface - downloading package zope.interface-3.6.1... - from http://pypi.python.org/packages/source/z/zope.interface/zope.interface-3.6.1.tar.gz - - -As a next step you may want to generate a package recipe for your distribution. -For RPM_-based distributions (let's use openSUSE_ as an example), you want to -generate a spec file (named 'python-zope.interface.spec'): - -.. code-block:: bash - - $ py2pack generate zope.interface -t opensuse.spec -f python-zope.interface.spec - -The source tarball and the package recipe is all you need to generate the RPM_ -(or DEB_) file. -This final step may depend on which distribution you use. Again, -for openSUSE_ (and by using the `Open Build Service`_), the complete recipe is: - -.. code-block:: bash - - $ osc mkpac python-zope.interface - $ cd python-zope.interface - $ py2pack fetch zope.interface - $ py2pack generate zope.interface -f python-zope.interface.spec - $ osc build - ... - -Depending on the module, you may have to adapt the resulting spec file slightly. -To get further help about py2pack usage, issue the following command: - -.. code-block:: bash - - $ py2pack help - - -Hacking and contributing ------------------------- - -You can test py2pack from your git checkout by executing the py2pack module: - -.. code-block:: bash - - $ python -m py2pack - -Fork `the repository`_ on Github to start making your changes to the **master** -branch (or branch off of it). Don't forget to write a test for fixed issues or -implemented features whenever appropriate. You can invoke the testsuite from -the repository root directory via `tox`_: - -.. code-block:: bash - - $ tox - -To run a single test class via `tox`_, use i.e.: - -.. code-block:: bash - - $ tox -epy27 test.test_py2pack:Py2packTestCase - - -You can also run `pytest`_ directly: - -.. code-block:: bash - - $ pytest - -It assumes you have the test dependencies installed (available on PYTHONPATH) -on your system. - -:copyright: (c) 2013 Sascha Peilicke. -:license: Apache-2.0, see LICENSE for more details. - - -.. _argparse: http://pypi.python.org/pypi/argparse -.. _Jinja2: http://pypi.python.org/pypi/Jinja2 -.. _zope.interface: http://pypi.python.org/pypi/zope.interface/ -.. _openSUSE: http://www.opensuse.org/en/ -.. _RPM: http://en.wikipedia.org/wiki/RPM_Package_Manager -.. _DEB: http://en.wikipedia.org/wiki/Deb_(file_format) -.. _`Python Package Index`: https://pypi.org/ -.. _`Open Build Service`: https://build.opensuse.org/package/show/devel:languages:python/python-py2pack -.. _`the repository`: https://github.com/openSUSE/py2pack -.. _`pytest`: https://github.com/pytest-dev/pytest -.. _`tox`: http://testrun.org/tox - -%prep -%setup -q -n py2pack-%{version} - -%build -python setup.py build - -%install -python setup.py install --prefix=%{_prefix} --root=%{buildroot} - -%clean -rm -rf %{buildroot} - -%files -%defattr(-,root,root,-) -%{python_sitelib}/* - -%changelog diff --git a/test/examples/sampleproject-fedora-augmented.spec b/test/examples/sampleproject-fedora-augmented.spec new file mode 100644 index 0000000..5ccce9d --- /dev/null +++ b/test/examples/sampleproject-fedora-augmented.spec @@ -0,0 +1,84 @@ +%define pypi_name sampleproject +%define python_name python3-%{pypi_name} +Name: python-%{pypi_name} +Version: 3.0.0 +Release: %autorelease +Summary: A sample Python project + +# Check if the automatically generated License and its spelling is correct for Fedora +# https://docs.fedoraproject.org/en-US/packaging-guidelines/LicensingGuidelines/ +License: Copyright (c) 2016 The Python Packaging Authority (PyPA) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + (FIXME:No SPDX) +URL: https://github.com/pypa/sampleproject +Source: https://files.pythonhosted.org/packages/source/s/sampleproject/sampleproject-%{version}.tar.gz + +BuildRequires: pyproject-rpm-macros +BuildRequires: python-devel +%if %{undefined python_module} +%define python_module() python3dist(%1) +%endif +BuildRequires: %{python_module pip} +BuildRequires: %{python_module setuptools >= 43.0.0} +BuildRequires: %{python_module wheel} +# SECTION test requirements +%if %{with test} +BuildRequires: %{python_module peppercorn} +BuildRequires: %{python_module coverage} +%endif +# /SECTION +BuildRequires: fdupes +Requires: %{python_module peppercorn} +Suggests: %{python_module check-manifest} +BuildArch: noarch + +# Fill in the actual package description to submit package to Fedora +%global _description %{expand: +A sample Python project} + +%description %_description + +%package -n %{python_name} +Summary: %{summary} + +%description -n %{python_name} %_description + + +%prep +%autosetup -p1 -n %{pypi_name}-%{version} + +%build +%pyproject_wheel + + +%install +%pyproject_install +# +#%python_clone -a %{buildroot}%{_bindir}/sample +# +# For official Fedora packages, including files with '*' +auto is not allowed +# Replace it with a list of relevant Python modules/globs and list extra files in %%files +%pyproject_save_files '*' +auto + +%files -n %{python_name} -f %{pyproject_files} + +%changelog +%autochangelog + diff --git a/test/examples/sampleproject-mageia.spec b/test/examples/sampleproject-mageia.spec new file mode 100644 index 0000000..4f0f033 --- /dev/null +++ b/test/examples/sampleproject-mageia.spec @@ -0,0 +1,32 @@ +%define mod_name sampleproject + +Name: python-%{mod_name} +Version: 3.0.0 +Release: %mkrel 1 +Url: +Summary: A sample Python project +License: Copyright (c) 2016 The Python Packaging Authority (PyPA) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. (FIXME:No SPDX) +Group: Development/Python +Source: https://files.pythonhosted.org/packages/source/s/sampleproject/sampleproject-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot +BuildRequires: python-devel + +%description +A sample Python project + + +%prep +%setup -q -n %{mod_name}-%{version} + +%build +%{__python} setup.py build + +%install +%{__python} setup.py install --prefix=%{_prefix} --root=%{buildroot} + +%clean +rm -rf %{buildroot} + +%files -f +%defattr(-,root,root) +%{python_sitelib}/* diff --git a/test/examples/sampleproject-opensuse-legacy.spec b/test/examples/sampleproject-opensuse-legacy.spec new file mode 100644 index 0000000..407452b --- /dev/null +++ b/test/examples/sampleproject-opensuse-legacy.spec @@ -0,0 +1,84 @@ +# +# spec file for package python-sampleproject +# +# Copyright (c) __YEAR__ SUSE LINUX GmbH, Nuernberg, Germany. +# +# 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/ + + +Name: python-sampleproject +Version: 3.0.0 +Release: 0 +Summary: A sample Python project +License: Copyright (c) 2016 The Python Packaging Authority (PyPA) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. (FIXME:No SPDX) +URL: +Source: https://files.pythonhosted.org/packages/source/s/sampleproject/sampleproject-%{version}.tar.gz +BuildRequires: python-setuptools +BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildArch: noarch + +%description +# A sample Python project + +![Python Logo](https://www.python.org/static/community_logos/python-logo.png "Sample inline image") + +A sample project that exists as an aid to the [Python Packaging User +Guide][packaging guide]'s [Tutorial on Packaging and Distributing +Projects][distribution tutorial]. + +This project does not aim to cover best practices for Python project +development as a whole. For example, it does not provide guidance or tool +recommendations for version control, documentation, or testing. + +[The source for this project is available here][src]. + +The metadata for a Python project is defined in the `pyproject.toml` file, +an example of which is included in this project. You should edit this file +accordingly to adapt this sample project to your needs. + +---- + +This is the README file for the project. + +The file should use UTF-8 encoding and can be written using +[reStructuredText][rst] or [markdown][md use] with the appropriate [key set][md +use]. It will be used to generate the project webpage on PyPI and will be +displayed as the project homepage on common code-hosting services, and should be +written for that purpose. + +Typical contents for this file would include an overview of the project, basic +usage examples, etc. Generally, including the project changelog in here is not a +good idea, although a simple “What's New” section for the most recent version +may be appropriate. + +[packaging guide]: https://packaging.python.org +[distribution tutorial]: https://packaging.python.org/tutorials/packaging-projects/ +[src]: https://github.com/pypa/sampleproject +[rst]: http://docutils.sourceforge.net/rst.html +[md]: https://tools.ietf.org/html/rfc7764#section-3.5 "CommonMark variant" +[md use]: https://packaging.python.org/specifications/core-metadata/#description-content-type-optional + + +%prep +%autosetup -p1 -n sampleproject-%{version} + +%build +python setup.py build + +%install +python setup.py install --prefix=%{_prefix} --root=%{buildroot} + +%files +%defattr(-,root,root,-) +%{python_sitelib}/* + +%changelog diff --git a/test/examples/sampleproject-opensuse.dsc b/test/examples/sampleproject-opensuse.dsc new file mode 100644 index 0000000..c967d4e --- /dev/null +++ b/test/examples/sampleproject-opensuse.dsc @@ -0,0 +1,8 @@ +Format: 1.0 +Source: sampleproject +Version: 3.0.0 +Binary: python-sampleproject +Maintainer: __USER__ +Architecture: any +Standards-Version: 3.7.1 +Build-Depends: debhelper (>= 4.0.0), python-dev diff --git a/test/test_template.py b/test/test_template.py index 9557eab..3d3d487 100644 --- a/test/test_template.py +++ b/test/test_template.py @@ -45,7 +45,7 @@ class Args(object): @pytest.mark.parametrize('template, fetch_tarball', - [('fedora.spec', False), + [('fedora.spec', True), ('mageia.spec', False), ('opensuse-legacy.spec', False), ('opensuse.dsc', False),