Skip to content

Commit 85be247

Browse files
committed
Merge branch 'newer_builds' into 'master'
Release 1.2.2 See merge request tcl/pytiger!2
2 parents 2c1c381 + a255235 commit 85be247

File tree

11 files changed

+156
-88
lines changed

11 files changed

+156
-88
lines changed

.gitlab-ci.yml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ stages:
55

66
.build_template: &build_template
77
stage: build
8-
variables:
9-
COVERAGE_PKG: "coverage"
108
script:
119
- pip install -r requirements.txt
12-
- pip install $COVERAGE_PKG flake8 nose mock
10+
- pip install coverage flake8 mock pytest pytest-cov
1311
# - python3 setup.py check -mrs
14-
# - python3 setup.py flake8
15-
- python setup.py nosetests
12+
- flake8 src/pytiger
13+
- pytest --cov pytiger src/pytiger
1614

1715
build-py2.7:
1816
<<: *build_template
@@ -42,21 +40,32 @@ build-py3.9:
4240
<<: *build_template
4341
image: python:3.9
4442

43+
build-py3.10:
44+
<<: *build_template
45+
image: python:3.10
46+
47+
build-py3.11:
48+
<<: *build_template
49+
image: python:3.11
50+
51+
build-py3.12:
52+
<<: *build_template
53+
image: python:3.12
54+
4555
pages:
4656
stage: build
47-
image: python:3.7
57+
image: python:3.12
4858
script:
4959
- pip install -r requirements.txt
5060
- pip install sphinx
51-
- python setup.py build_sphinx
52-
- mv build/sphinx/html public
61+
- sphinx-build docs public
5362
artifacts:
5463
paths:
5564
- public
5665

5766
rpm-source:
5867
stage: build
59-
image: centos:7
68+
image: rockylinux:9
6069
before_script:
6170
- yum -y install
6271
git
@@ -97,6 +106,8 @@ rpm-source:
97106
- yum -y install
98107
epel-release
99108
${rpm_scl:+centos-release-scl}
109+
# https://wiki.rockylinux.org/rocky/repo/#notes-on-crb
110+
- /usr/bin/crb enable || true
100111
- yum -y install
101112
epel-rpm-macros
102113
rpm-build
@@ -120,12 +131,6 @@ epel-7-x86_64:
120131
extends: .rpm-binary-template
121132
image: centos:7
122133

123-
epel-7-sclpy35-x86_64:
124-
extends: .rpm-binary-template
125-
image: centos:7
126-
variables:
127-
rpm_scl: rh-python35
128-
129134
epel-7-sclpy36-x86_64:
130135
extends: .rpm-binary-template
131136
image: centos:7

docs/changes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
Changes in pytiger
33
******************
44

5+
Release 1.2.2
6+
=============
7+
8+
* Add GitLab CI test runs and RPM building.
9+
* Overhaul the RPM spec file completely.
10+
* Refactor :mod:`pytiger.utils.plugins` for Python 3.12.
11+
512
Release 1.2.1
613
=============
714

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
# The short X.Y version.
5959
version = '1.2'
6060
# The full version, including alpha/beta/rc tags.
61-
release = '1.2.1'
61+
release = '1.2.2'
6262

6363
# The language for content autogenerated by Sphinx. Refer to documentation
6464
# for a list of supported languages.

pytiger.spec

Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
%{?scl:%scl_package pytiger}
2-
%{!?scl:%global pkg_name %{name}}
1+
%if 0%{?scl:1}
2+
%scl_package pytiger
3+
%global py_prefix %{scl_prefix}python
4+
%else
5+
%global pkg_name pytiger
6+
%global py_prefix python%{python3_pkgversion}
7+
%endif
38

49
%if 0%{?rhel} == 7 && 0%{!?scl:1}
510
# This flag denotes we want to build python2 and python3 RPMs in one go, which
6-
# only applies on CentOS 7 for Python 2.7 and 3.4/3.6, and only if we are NOT
11+
# only applies on CentOS 7 for Python 2.7 and 3.6, and only if we are NOT
712
# building for an SCL Python package.
8-
%global _want_dual_pythons 1
9-
%endif
10-
11-
# The current convention for Python 2.x non-SCL packages is to prefix them
12-
# python2-, so conditionally define a macro we can use to add this tag.
13-
%if 0%{!?scl:1}
14-
%global python2_pkgtag 2
13+
%global _want_python2 1
1514
%endif
1615

1716
%global sum Tiger Computing Ltd Python Utilities
1817

19-
Name: %{?scl_prefix}pytiger
18+
Name: %{?scl_prefix}%{pkg_name}
2019
Summary: %{sum}
21-
Version: 1.2.1
22-
Release: 4%{?dist}
20+
Version: 1.2.2
21+
Release: 1%{?dist}
2322

2423
Group: Development/Libraries
2524
License: BSD-3-clause
@@ -28,73 +27,66 @@ Url: https://github.com/tigercomputing/%{pkg_name}
2827

2928
BuildArch: noarch
3029
BuildRequires: epel-rpm-macros
31-
32-
BuildRequires: python%{python3_pkgversion}-devel
33-
BuildRequires: python%{python3_pkgversion}-setuptools
30+
%{?scl:BuildRequires: %{scl_prefix}build}
31+
BuildRequires: %{py_prefix}-devel
32+
BuildRequires: %{py_prefix}-setuptools
3433

3534
# Requirements for RHEL7 py2 only
36-
%if 0%{?_want_dual_pythons:1}
37-
BuildRequires: %{?scl_prefix}python-devel
38-
BuildRequires: %{?scl_prefix}python-setuptools
35+
%if 0%{?_want_python2:1}
36+
BuildRequires: python-devel
37+
BuildRequires: python-setuptools
3938
%endif
4039

4140
%description
4241
This is the Tiger Computing Ltd Python Utility library, pytiger.
4342

44-
%package -n python%{python3_pkgversion}-%{pkg_name}
43+
%package -n %{py_prefix}-%{pkg_name}
4544
Summary: %{sum}
46-
Requires: python%{python3_pkgversion}-six
45+
Requires: %{py_prefix}-six
4746

48-
%description -n python%{python3_pkgversion}-%{pkg_name}
47+
%description -n %{py_prefix}-%{pkg_name}
4948
This is the Tiger Computing Ltd Python Utility library, pytiger.
5049

5150
# For dual pythons, add in the extra binary package
52-
%if 0%{?_want_dual_pythons:1}
53-
%package -n %{?scl_prefix}python%{?python2_pkgtag}-%{pkg_name}
51+
%if 0%{?_want_python2:1}
52+
%package -n python2-%{pkg_name}
5453
Summary: %{sum}
55-
Requires: %{?scl_prefix}python-six
56-
%if 0%{!?scl:1}
57-
%{?python_provide:%python_provide python%{?python2_pkgtag}-%{pkg_name}}
58-
%endif
54+
Requires: python-six
5955

60-
%description -n %{?scl_prefix}python%{?python2_pkgtag}-%{pkg_name}
56+
%description -n python2-%{pkg_name}
6157
This is the Tiger Computing Ltd Python Utility library, pytiger.
6258
%endif
6359

6460
%prep
6561
%setup -n %{pkg_name}-%{version} -q
6662

6763
%build
68-
%if 0%{?scl:1}
69-
%{?scl:scl enable %{scl} "}
70-
%{__python} setup.py build
71-
%{?scl:"}
72-
%else
73-
%py3_build
74-
%{?_want_dual_pythons:%py_build}
75-
%endif
64+
%{?scl:scl enable %{scl} - << \EOF}
65+
%{__python3} setup.py build
66+
%{?scl:EOF}
67+
%{?_want_python2:%{__python} setup.py build}
7668
7769
%install
7870
rm -rf $RPM_BUILD_ROOT
79-
%if 0%{?scl:1}
80-
%{?scl:scl enable %{scl} "}
81-
%{__python} setup.py install --skip-build --root $RPM_BUILD_ROOT \
82-
--install-data=%{_datadir}
83-
%{?scl:"}
84-
%else
85-
%py3_install
86-
%{?_want_dual_pythons:%py_install}
87-
%endif
71+
%{?scl:scl enable %{scl} - << \EOF}
72+
%{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
73+
%{?scl:EOF}
74+
%{?_want_python2:%{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT}
8875
89-
%files -n python%{python3_pkgversion}-%{pkg_name}
76+
%files -n %{py_prefix}-%{pkg_name}
9077
%{python3_sitelib}/*
9178
92-
%if 0%{?_want_dual_pythons:1}
93-
%files -n %{?scl_prefix}python%{?python2_pkgtag}-%{pkg_name}
79+
%if 0%{?_want_python2:1}
80+
%files -n python2-%{pkg_name}
9481
%{python_sitelib}/*
9582
%endif
9683
9784
%changelog
85+
* Tue Oct 24 2023 Chris Boot <[email protected]> - 1.2.2-1
86+
- Add GitLab CI test runs and RPM building.
87+
- Overhaul the RPM spec file completely.
88+
- Refactor pytiger.utils.plugins for Python 3.12.
89+
9890
* Wed Jan 13 2021 Jonathan Wiltshire <[email protected]> - 1.2.1-4
9991
- Build for Python 3 by default, and Python 2 as an option.
10092

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from setuptools import setup, find_packages
1010

1111
setup(name='pytiger',
12-
version='1.2.1',
12+
version='1.2.2',
1313
description='Tiger Computing Ltd Python Utilities',
1414
author='Tiger Computing Ltd',
1515
author_email='[email protected]',

src/pytiger/monitoring/test_monitoringcheck.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_exit_messages(self, mock_exit):
5454
with patch('sys.stdout', new=StringIO()) as out:
5555
self.n.exit()
5656
output = out.getvalue().strip()
57-
self.assertEquals(output, 'line 1, line 2')
57+
self.assertEqual(output, 'line 1, line 2')
5858

5959
@patch('sys.exit')
6060
def test_exit_messages_custom_separator(self, mock_exit):
@@ -63,18 +63,18 @@ def test_exit_messages_custom_separator(self, mock_exit):
6363
with patch('sys.stdout', new=StringIO()) as out:
6464
self.n.exit(separator=";")
6565
output = out.getvalue().strip()
66-
self.assertEquals(output, 'line 1;line 2')
66+
self.assertEqual(output, 'line 1;line 2')
6767
with patch('sys.stdout', new=StringIO()) as out:
6868
self.n.exit(separator="\n")
6969
output = out.getvalue().strip()
70-
self.assertEquals(output, 'line 1\nline 2')
70+
self.assertEqual(output, 'line 1\nline 2')
7171

7272
@patch('sys.exit')
7373
def test_exit_unset_nomessages(self, mock_exit):
7474
with patch('sys.stdout', new=StringIO()) as out:
7575
self.n.exit()
7676
output = out.getvalue().strip()
77-
self.assertEquals(output, 'UNKNOWN: No state asserted')
77+
self.assertEqual(output, 'UNKNOWN: No state asserted')
7878
mock_exit.assert_called_once_with(3)
7979

8080
####################

src/pytiger/nagios/test_nagioscheck.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_exit_messages(self, mock_exit):
6363
with patch('sys.stdout', new=StringIO()) as out:
6464
self.n.exit()
6565
output = out.getvalue().strip()
66-
self.assertEquals(output, 'line 1, line 2')
66+
self.assertEqual(output, 'line 1, line 2')
6767

6868
@patch('sys.exit')
6969
def test_exit_messages_custom_separator(self, mock_exit):
@@ -72,18 +72,18 @@ def test_exit_messages_custom_separator(self, mock_exit):
7272
with patch('sys.stdout', new=StringIO()) as out:
7373
self.n.exit(separator=";")
7474
output = out.getvalue().strip()
75-
self.assertEquals(output, 'line 1;line 2')
75+
self.assertEqual(output, 'line 1;line 2')
7676
with patch('sys.stdout', new=StringIO()) as out:
7777
self.n.exit(separator="\n")
7878
output = out.getvalue().strip()
79-
self.assertEquals(output, 'line 1\nline 2')
79+
self.assertEqual(output, 'line 1\nline 2')
8080

8181
@patch('sys.exit')
8282
def test_exit_unset_nomessages(self, mock_exit):
8383
with patch('sys.stdout', new=StringIO()) as out:
8484
self.n.exit()
8585
output = out.getvalue().strip()
86-
self.assertEquals(output, 'UNKNOWN: No state asserted')
86+
self.assertEqual(output, 'UNKNOWN: No state asserted')
8787
mock_exit.assert_called_once_with(3)
8888

8989
####################

src/pytiger/utils/plugins.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33
A simple plugin loading mechanism
44
"""
55

6-
# Copyright © 2015 Tiger Computing Ltd
6+
# Copyright © 2015-2023 Tiger Computing Ltd
77
# This file is part of pytiger and distributed under the terms
88
# of a BSD-like license
99
# See the file COPYING for details
1010

11-
# Idea borrowed and adapted from:
11+
# Idea originally borrowed and adapted from:
1212
# https://copyninja.info/blog/dynamic-module-loading.html
1313
# http://stackoverflow.com/a/3381582
1414

15-
import imp
15+
1616
import os
1717

18+
try:
19+
from .plugins_importlib import _Plugin
20+
except ImportError:
21+
from .plugins_imp import _Plugin
22+
1823

1924
def load(plugin_dir, package=__name__):
2025
"""
@@ -44,25 +49,27 @@ def load(plugin_dir, package=__name__):
4449
plugins = []
4550
for dirent in os.listdir(plugin_dir):
4651
# skip __init__.py
47-
if dirent.startswith('__'):
52+
if dirent.startswith("__"):
4853
continue
4954

55+
full_path = os.path.join(plugin_dir, dirent)
56+
5057
# Load .py files as plugins
51-
if dirent.endswith('.py'):
52-
plugins.append(os.path.splitext(dirent)[0])
58+
if dirent.endswith(".py"):
59+
plugin_name = package + "." + os.path.splitext(dirent)[0]
60+
plugins.append(_Plugin(plugin_name, full_path, plugin_dir))
5361
continue
5462

5563
# Load directories containing __init__.py
56-
full_path = os.path.join(plugin_dir, dirent)
5764
if os.path.isdir(full_path):
58-
if os.path.isfile(os.path.join(full_path, '__init__.py')):
59-
plugins.append(dirent)
65+
plugin_name = package + "." + dirent
66+
plugin_path = os.path.join(full_path, "__init__.py")
67+
if os.path.isfile(plugin_path):
68+
plugins.append(_Plugin(plugin_name, plugin_path, plugin_dir))
6069

6170
# Now load the plugin modules
6271
modules = []
6372
for plugin in plugins:
64-
f, path, desc = imp.find_module(plugin, [plugin_dir])
65-
module = imp.load_module(package + '.' + plugin, f, path, desc)
66-
modules.append(module)
73+
modules.append(plugin.load())
6774

6875
return modules

0 commit comments

Comments
 (0)