Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added blackPanther OS support #215

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c926e4d
added blackPanther OS support
blackPantherOS Jan 29, 2020
e910815
setup_method and test_rpm_name has been fixed
hmikihth Apr 18, 2020
c246181
Merge pull request #1 from hmikihth/master
blackPantherOS Apr 18, 2020
ce6e8d9
blackPanther OS spec file
hmikihth Apr 18, 2020
4c0ed7b
blackPanther OS spec file
hmikihth Apr 18, 2020
c9681ab
Merge pull request #2 from hmikihth/master
blackPantherOS Apr 18, 2020
d6ea250
Update python-Jinja2_blackpantheros_py23.spec
hmikihth Apr 18, 2020
5889326
Merge pull request #3 from hmikihth/patch-1
blackPantherOS Apr 18, 2020
44d4fa5
Update python-Jinja2_blackpantheros_py23.spec
hmikihth Apr 18, 2020
f10cef2
Merge pull request #4 from hmikihth/patch-2
blackPantherOS Apr 18, 2020
a94ca44
Update python-Jinja2_blackpantheros_py23.spec
hmikihth Apr 18, 2020
173ece1
Merge pull request #5 from hmikihth/master
blackPantherOS Apr 18, 2020
aa77ed8
Update python-Jinja2_blackpantheros_py23.spec
hmikihth Apr 18, 2020
e156312
Merge branch 'master' into master
blackPantherOS Apr 18, 2020
e180ca0
Update python-Jinja2_blackpantheros_py23.spec
hmikihth Apr 18, 2020
d9d3414
Merge pull request #6 from hmikihth/master
blackPantherOS Apr 18, 2020
4cd7054
Update python-Jinja2_blackpantheros_py23.spec
hmikihth Apr 18, 2020
88656e7
Merge pull request #7 from hmikihth/master
blackPantherOS Apr 18, 2020
0a6233f
Update python-Jinja2_blackpantheros_py23.spec
hmikihth Apr 18, 2020
f5a86a9
Merge pull request #8 from hmikihth/master
blackPantherOS Apr 18, 2020
834e764
Update python-Jinja2_blackpantheros_py23.spec
hmikihth Apr 18, 2020
0d20cdd
Merge pull request #9 from hmikihth/patch-3
blackPantherOS Apr 18, 2020
1147b7e
Update python-Jinja2_blackpantheros_py23.spec
hmikihth Apr 18, 2020
0db24f2
Merge branch 'master' into master
blackPantherOS Apr 18, 2020
c75bee9
Merge pull request #10 from hmikihth/master
blackPantherOS Apr 18, 2020
534f971
Missing items fix
blackPantherOS Apr 18, 2020
6808fbb
Mistake fix
blackPantherOS Apr 18, 2020
441bba3
Test package names add
blackPantherOS Apr 18, 2020
b5ed97c
specfile clean
blackPantherOS Apr 18, 2020
49e9daf
specfile fix
blackPantherOS Apr 18, 2020
ffc8700
Upper name fix
blackPantherOS Apr 18, 2020
7dbc01a
null
blackPantherOS Apr 18, 2020
d694ac0
Update name_convertor.py
blackPantherOS Apr 18, 2020
768b823
Update test_name_convertor.py
blackPantherOS Apr 18, 2020
c571933
Update README.md
blackPantherOS Apr 18, 2020
18d09fd
Merge pull request #11 from fedora-python/master
blackPantherOS Apr 18, 2020
fe2bf51
Update tox.ini
blackPantherOS Apr 18, 2020
f0cfae8
pyparsing
blackPantherOS Apr 19, 2020
b1c7645
Update tox.ini
blackPantherOS Apr 19, 2020
aba8df7
Important XMLRPC time fix
blackPantherOS Nov 5, 2020
cd3e066
XSS Security hotfix
blackPantherOS Oct 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pyp2rpm

A tool to convert a PyPI package to an RPM SPECFILE or to generate an SRPM.
Under heavy development, see the TODO file for a list of planned features.
pyp2rpm currently ships with Fedora and Mageia specific templates.
pyp2rpm currently ships with Fedora, Mageia and blackPanther OS specific templates.

## Usage

Expand Down Expand Up @@ -38,7 +38,7 @@ All of the options are (print this by running pyp2rpm -h):
-t TEMPLATE Template file (jinja2 format) to render
(default: "fedora").Search order is 1)
filesystem, 2) default templates.
-o [fedora|epel7|epel6|mageia|pld]
-o [fedora|epel7|epel6|mageia|pld|blackpantheros]
Default distro whose conversion rules to use
(default:"fedora"). Default templates have
their rules associated and ignore this.
Expand Down
2 changes: 1 addition & 1 deletion pyp2rpm.1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Tool which converts a package from PyPI to RPM specfile or SRPM.
PyPI name of the package or path to compressed source file.

.SH DESCRIPTION
Tool convert Python package to RPM SPECFILES. The package can be download from PyPI or from the local filesystem and the produced SPEC is in line with Fedora packaging Guidelines or Mageia Python Policy.
Tool convert Python package to RPM SPECFILES. The package can be download from PyPI or from the local filesystem and the produced SPEC is in line with Fedora packaging Guidelines or Mageia and blackPanther OS Python Policy.
.PP
Users can provide their own templates for rendering the package metadata. Both the package source and metadata can be extracted from PyPI or from local filesystem (local file doesn't provide that much information though).

Expand Down
13 changes: 10 additions & 3 deletions pyp2rpm/convertor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import re
import sys
import time
try:
import urllib2 as urllib
except ImportError:
Expand Down Expand Up @@ -149,7 +150,7 @@ def convert(self):

jinja_env = jinja2.Environment(loader=jinja2.ChoiceLoader([
jinja2.FileSystemLoader(['/']),
jinja2.PackageLoader('pyp2rpm', 'templates'), ]))
jinja2.PackageLoader('pyp2rpm', 'templates'), ]), autoescape=True)

for filter in filters.__all__:
jinja_env.filters[filter.__name__] = filter
Expand Down Expand Up @@ -222,7 +223,8 @@ def name_convertor(self):
name_convertor.NameConvertor.distro = self.distro
if self.autonc or (self.autonc is None and
(self.distro == 'fedora' or
self.distro == 'mageia')):
self.distro == 'mageia' or
self.distro == 'blackpantheros')):
logger.debug("Using AutoProvidesNameConvertor to convert "
"names of the packages.")
self._name_convertor = name_convertor.AutoProvidesNameConvertor(
Expand Down Expand Up @@ -300,14 +302,19 @@ def client(self):
if self.proxy:
logger.info('Using provided proxy: {0}.'.format(
self.proxy))
self._client = xmlrpclib.ServerProxy(settings.PYPI_URL,
self._client = RateLimitedServerProxy(settings.PYPI_URL,
transport=transport)
self._client_set = True
else:
self._client = None

return self._client

class RateLimitedServerProxy(xmlrpclib.ServerProxy):

def __getattr__(self, name):
time.sleep(1)
return super(RateLimitedServerProxy, self).__getattr__(name)

class ProxyTransport(xmlrpclib.Transport):
"""This class serves as Proxy Transport for XMLRPC server."""
Expand Down
3 changes: 3 additions & 0 deletions pyp2rpm/name_convertor.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ def rpm_name(self, name, python_version=None, pkg_name=False):

if self.distro == 'mageia':
rpmized_name = rpmized_name.lower()
elif self.distro == 'blackpantheros':
rpmized_name = rpmized_name.lower()

logger.debug('Rpmized name of {0}: {1}.'.format(name, rpmized_name))
return NameConvertor.rpm_versioned_name(rpmized_name, python_version)

Expand Down
1 change: 1 addition & 0 deletions pyp2rpm/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'epel7': ['2', '3'],
'epel6': ['2'],
'mageia': ['3'],
'blackpantheros': ['2', '3'],
'pld': ['2', '3']
}
DEFAULT_PYTHON_VERSION = DEFAULT_PYTHON_VERSIONS[DEFAULT_TEMPLATE][0]
Expand Down
130 changes: 130 additions & 0 deletions pyp2rpm/templates/blackpantheros.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{{ data.credit_line }}
{% from 'macros.spec' import dependencies, for_python_versions, underscored_or_pypi -%}
%global pypi_name {{ data.name }}
{%- if data.srcname %}
%global srcname {{ data.srcname }}
{%- endif %}

Name: {{ data.pkg_name|macroed_pkg_name(data.srcname) }}
Version: {{ data.version }}
Release: %mkrel 1
Summary: {{ data.summary }}
Group: Development/Python
License: {{ data.license }}
URL: {{ data.home_page }}
Source0: {{ data.source0|replace(data.name, '%{pypi_name}')|replace(data.version, '%{version}') }}

{%- if not data.has_extension %}
BuildArch: noarch
{%- endif %}
{%- for pv in data.sorted_python_versions %}
{{ dependencies(data.build_deps, False, pv, data.base_python_version, False) }}
{%- endfor %}

%description
{{ data.description|truncate(400)|wordwrap }}
{% for pv in data.sorted_python_versions %}
%package -n {{data.pkg_name|macroed_pkg_name(data.srcname)|name_for_python_version(pv, True) }}
Summary: %{summary}
%{?python_provide:%python_provide {{data.pkg_name|macroed_pkg_name(data.srcname)|name_for_python_version(pv, True)}}}
{{ dependencies(data.runtime_deps, True, pv, pv) }}
%description -n {{data.pkg_name|macroed_pkg_name(data.srcname)|name_for_python_version(pv, True) }}
{{ data.description|truncate(400)|wordwrap }}
{% endfor -%}
{%- if data.sphinx_dir %}
%package -n {{ data.pkg_name|macroed_pkg_name(data.srcname)|name_for_python_version(None, True) }}-doc
Summary: {{ data.name }} documentation
%description -n {{ data.pkg_name|macroed_pkg_name(data.srcname)|name_for_python_version(None, True) }}-doc
Documentation for {{ data.name }}
{%- endif %}

%prep
%autosetup -n {{ data.dirname|replace(data.name, '%{pypi_name}')|replace(data.version, '%{version}')|default('%{pypi_name}-%{version}', true) }}
{%- if data.has_bundled_egg_info %}
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
{%- endif %}

%build
{%- for pv in data.sorted_python_versions %}
%py{{ pv }}_build
{%- endfor %}
{%- if data.sphinx_dir %}
# generate html docs
PYTHONPATH=${PWD} {{ "sphinx-build"|script_name_for_python_version(data.base_python_version, False, True) }} {{ data.sphinx_dir }} html
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}
{%- endif %}

%install
{%- if data.python_versions|length > 0 %}
# Must do the default python version install last because
# the scripts in /usr/bin are overwritten with every setup.py install.
{%- endif %}
{%- for pv in data.python_versions + [data.base_python_version] %}
{%- if pv == data.base_python_version and data.python_versions and data.scripts %}
rm -rf %{buildroot}%{_bindir}/*
{%- endif %}
%py{{ pv }}_install
{%- endfor -%}
{% if data.has_test_suite %}

%check
{%- for pv in data.sorted_python_versions %}
%{__python{{ pv }}} setup.py test
{%- endfor %}
{%- endif %}
{% for pv in data.sorted_python_versions %}
%files -n {{ data.pkg_name|macroed_pkg_name(data.srcname)|name_for_python_version(pv, True) }}
{%- if data.doc_license %}
%license {{data.doc_license|join(' ')}}
{%- endif %}
{%- if data.doc_files %}
%doc {{data.doc_files|join(' ') }}
{%- endif %}
{%- if pv == data.base_python_version %}
{%- for script in data.scripts %}
%{_bindir}/{{ script }}
{%- endfor %}
{%- endif %}
{%- if data.py_modules %}
{%- for module in data.py_modules -%}
{%- if pv == '3' %}
%{python{{ pv }}_sitelib}/__pycache__/*
{%- endif %}
%{python{{ pv }}_sitelib}/{{ data.name | module_to_path(module) }}.py{% if pv != '3'%}*{% endif %}
{%- endfor %}
{%- endif %}
{%- if data.has_extension %}
{%- if data.has_packages %}
{%- for package in data.packages %}
%{python{{ pv }}_sitearch}/{{ package | package_to_path(data.name) }}
{%- endfor %}
{%- endif %}
{%- if data.has_pth %}
%{python{{ pv }}_sitearch}/{{ underscored_or_pypi(data.name, data.underscored_name) }}-%{version}-py%{python{{ pv }}_version}-*.pth
{%- endif %}
%{python{{ pv }}_sitearch}/{{ underscored_or_pypi(data.name, data.underscored_name) }}-%{version}-py%{python{{ pv }}_version}.egg-info
{%- else %}
{%- if data.has_packages %}
{%- for package in data.packages %}
%{python{{ pv }}_sitelib}/{{ package | package_to_path(data.name) }}
{%- endfor %}
{%- endif %}
{%- if data.has_pth %}
%{python{{ pv }}_sitelib}/{{ underscored_or_pypi(data.name, data.underscored_name) }}-%{version}-py%{python{{ pv }}_version}-*.pth
{%- endif %}
%{python{{ pv }}_sitelib}/{{ underscored_or_pypi(data.name, data.underscored_name) }}-%{version}-py%{python{{ pv }}_version}.egg-info
{%- endif %}
{% endfor %}
{%- if data.sphinx_dir %}
%files -n {{ data.pkg_name|macroed_pkg_name(data.srcname)|name_for_python_version(None, True) }}-doc
%doc html
{%- if data.doc_license %}
%license {{data.doc_license|join(' ')}}
{%- endif %}
{% endif %}
%changelog
* {{ data.changelog_date_packager }} - {{ data.version }}-1
- Initial for blackPanther OS generated with Pyp2Rpm

3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@


description = """Convert Python packages to RPM SPECFILES. The packages can be downloaded from
PyPI and the produced SPEC is in line with Fedora Packaging Guidelines or Mageia Python Policy.
PyPI and the produced SPEC is in line with Fedora Packaging Guidelines or Mageia and
blackPanther OS Python Policy.

Users can provide their own templates for rendering the package metadata. Both the package
source and metadata can be extracted from PyPI or from local filesystem (local file doesn't
Expand Down
78 changes: 78 additions & 0 deletions tests/test_data/python-Jinja2_blackpantheros_py23.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Created by pyp2rpm-3.3.4
%global pypi_name Jinja2

Name: %{pypi_name}
Version: 2.8
Release: %mkrel 1
Summary: A small but fast and easy to use stand-alone template engine written in pure python
Group: Development/Python
License: BSD
URL: http://jinja.pocoo.org/
Source0: https://files.pythonhosted.org/packages/source/J/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
BuildArch: noarch

BuildRequires: python2-devel
BuildRequires: python2dist(babel) >= 0.8
BuildRequires: python2dist(markupsafe)
BuildRequires: python2dist(setuptools)
BuildRequires: python2dist(sphinx)

%description
Jinja2 is a template engine written in pure Python. It provides a Django_
inspired non-XML syntax but supports inline expressions and an optional
sandboxed_ environment.Nutshell Here a small example of a Jinja template:: {%
extends 'base.html' %} {% block title %}Memberlist{% endblock %} {% block
content %} <ul> {% for user in users %} <li><a href"{{ user.url }}">{{
user.username }}</a></li>...

%package -n python2-%{pypi_name}
Summary: %{summary}
%{?python_provide:%python_provide python2-%{pypi_name}}

Requires: python2dist(babel) >= 0.8
Requires: python2dist(markupsafe)
%description -n python2-%{pypi_name}
Jinja2 is a template engine written in pure Python. It provides a Django_
inspired non-XML syntax but supports inline expressions and an optional
sandboxed_ environment.Nutshell Here a small example of a Jinja template:: {%
extends 'base.html' %} {% block title %}Memberlist{% endblock %} {% block
content %} <ul> {% for user in users %} <li><a href"{{ user.url }}">{{
user.username }}</a></li>...

%package -n %{pypi_name}-doc
Summary: Jinja2 documentation
%description -n %{pypi_name}-doc
Documentation for Jinja2

%prep
%autosetup -n %{pypi_name}-%{version}
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info

%build
%py2_build
# generate html docs
PYTHONPATH=${PWD} sphinx-build-2 docs html
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}

%install
%py2_install

%check
%{__python2} setup.py test

%files -n python2-%{pypi_name}
%license docs/_themes/LICENSE LICENSE
%doc README.rst
%{python2_sitelib}/jinja2
%{python2_sitelib}/%{pypi_name}-%{version}-py%{python2_version}.egg-info

%files -n %{pypi_name}-doc
%doc html
%license docs/_themes/LICENSE LICENSE

%changelog
* Sun Dec 30 2018 Charles K. Barcza <info@blackpanther.hu> 3.3.3-1
- build package for blackPanther OS via pyp2rpm

1 change: 1 addition & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def teardown_method(self, method):
('Jinja2', '-v2.8 -t epel7', 'python-Jinja2_epel7{0}.spec'),
('Jinja2', '-v2.8 -t epel6', 'python-Jinja2_epel6{0}.spec'),
('Jinja2', '-v2.8 -p2 -t mageia', 'python-Jinja2_mageia_py23.spec'),
('Jinja2', '-v2.8 -p2 -t blackpantheros', 'python-Jinja2_blackpantheros_py23.spec'),
('Jinja2', '-v2.8 -p2 --no-autonc', 'python-Jinja2{0}.spec'),
('buildkit', '-v0.2.2 -b2', 'python-buildkit_autonc.spec'),
('paperwork-backend', '-v1.2.4', 'python-paperwork-backend.spec'),
Expand Down
14 changes: 7 additions & 7 deletions tests/test_metadata_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ def desciption_fce(description):
(
'''Convert Python packages to RPM SPECFILES. The packages can be downloaded from
PyPI and the produced SPEC is in line with Fedora Packaging Guidelines or
Mageia Python Policy.Users can provide their own templates for rendering the
package metadata. Both the package source and metadata can be extracted from
PyPI or from local filesystem (local file doesn't provide that much information
though).''',
Mageia and blackPanther OS Python Policy.Users can provide their own templates
for rendering the package metadata. Both the package source and metadata can be
extracted from PyPI or from local filesystem (local file doesn't provide that much
information though).''',
'''Convert Python packages to RPM SPECFILES. The packages can be downloaded from \
PyPI and the produced SPEC is in line with Fedora Packaging Guidelines or \
Mageia Python Policy.Users can provide their own templates for rendering the \
package metadata. Both the package source and metadata can be extracted from \
PyPI or from local filesystem (local file doesn't provide that much information \
Mageia and blackPanther OS Python Policy.Users can provide their own templates for \
rendering the package metadata. Both the package source and metadata can be extracted \
from PyPI or from local filesystem (local file doesn't provide that much information \
though).'''),
(
'''Vex
Expand Down
24 changes: 13 additions & 11 deletions tests/test_name_convertor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ class TestUtils(object):
def setup_method(self, method):
self.ncf = NameConvertor('fedora')
self.ncm = NameConvertor('mageia')

@pytest.mark.parametrize(('input', 'expected_f', 'expected_m'), [
('python-spam', 'python-spam', 'python-spam'),
('python-PySpam', 'python-PySpam', 'python-pyspam'),
('python-spampy', 'python-spampy', 'python-spampy'),
('spam-python', 'python-spam', 'python-spam'),
('python26-foo', 'python-foo', 'python-foo'),
('foo-python26', 'python-foo', 'python-foo'),
('python3-foo', 'python-foo', 'python-foo'),
('foo-python3', 'python-foo', 'python-foo'),
self.ncb = NameConvertor('blackpantheros')

@pytest.mark.parametrize(('input', 'expected_f', 'expected_m', 'expected_b'), [
('python-spam', 'python-spam', 'python-spam', 'python-spam'),
('python-PySpam', 'python-PySpam', 'python-pyspam', 'python-pyspam'),
('python-spampy', 'python-spampy', 'python-spampy', 'python-spampy'),
('spam-python', 'python-spam', 'python-spam', 'python-spam'),
('python26-foo', 'python-foo', 'python-foo', 'python-foo'),
('foo-python26', 'python-foo', 'python-foo', 'python-foo'),
('python3-foo', 'python-foo', 'python-foo', 'python-foo'),
('foo-python3', 'python-foo', 'python-foo', 'python-foo'),
])
def test_rpm_name(self, input, expected_f, expected_m):
def test_rpm_name(self, input, expected_f, expected_m, expected_b):
assert self.ncf.rpm_name(input) == expected_f
assert self.ncm.rpm_name(input) == expected_m
assert self.ncb.rpm_name(input) == expected_b

@pytest.mark.parametrize(('name', 'version', 'expected'), [
('python-spam', None, 'python-spam'),
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ envlist = py27, py34, py35, py36, py37

[testenv]
deps =
pyparsing
more-itertools <= 7.2.0
setuptools
Jinja2
Expand Down