From 00956cf13a298cc8d3e474b9db182fd20e9be6f8 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Tue, 23 Aug 2022 14:28:11 +0200 Subject: [PATCH 1/7] Fix conf import in tests/common.py --- tests/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/common.py b/tests/common.py index 0a8c96ca..82a88648 100644 --- a/tests/common.py +++ b/tests/common.py @@ -11,6 +11,7 @@ from xml.etree import ElementTree as ET import urllib3.response +import osc.conf import osc.core @@ -201,7 +202,7 @@ class OscTestCase(unittest.TestCase): EXPECTED_REQUESTS = [] os.chdir(os.path.dirname(__file__)) oscrc = os.path.join(self._get_fixtures_dir(), 'oscrc') - osc.core.conf.get_config(override_conffile=oscrc, + osc.conf.get_config(override_conffile=oscrc, override_no_keyring=True, override_no_gnome_keyring=True) os.environ['OSC_CONFIG'] = oscrc From 1c581fdf2c969d5160e761435de2f6f50e0ab8c1 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Tue, 23 Aug 2022 14:28:57 +0200 Subject: [PATCH 2/7] Move _get_fixture() to OscTestCase class --- tests/common.py | 5 +++++ tests/test_results.py | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/common.py b/tests/common.py index 82a88648..0cb5c200 100644 --- a/tests/common.py +++ b/tests/common.py @@ -223,6 +223,11 @@ class OscTestCase(unittest.TestCase): def _get_fixtures_dir(self): raise NotImplementedError('subclasses should implement this method') + def _get_fixture(self, filename): + path = os.path.join(self._get_fixtures_dir(), filename) + with open(path) as f: + return f.read() + def _change_to_pkg(self, name): os.chdir(os.path.join(self.tmpdir, 'osctest', name)) diff --git a/tests/test_results.py b/tests/test_results.py index cbfa60a9..7269c7e7 100644 --- a/tests/test_results.py +++ b/tests/test_results.py @@ -28,9 +28,6 @@ class TestResults(OscTestCase): cli.main(argv=argv) return sys.stdout.getvalue() - def _get_fixture(self, filename): - return open(os.path.join(self._get_fixtures_dir(), filename)).read() - @GET('http://localhost/build/testproject/_result', file='result.xml') def testPrjresults(self): out = self._run_osc('prjresults', '--xml', 'testproject') From 9cc4a5594f26581d22d5bd720d90b3079506f842 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Wed, 24 Aug 2022 08:43:09 +0200 Subject: [PATCH 3/7] Fix resource warnings (unclosed files) --- osc/commandline.py | 11 ++++------- osc/connection.py | 22 ++++++++++++++++++++-- osc/core.py | 28 ++++++++++++++++++---------- tests/common.py | 19 +++++++++++++++++-- tests/test_addfiles.py | 6 +++--- tests/test_commit.py | 8 ++++---- tests/test_init_package.py | 3 ++- tests/test_repairwc.py | 6 +++--- tests/test_request.py | 12 ++++++------ tests/test_revertfiles.py | 2 +- tests/test_update.py | 8 +++----- 11 files changed, 81 insertions(+), 44 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index c1c042b0..5bd5a7b3 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -4249,13 +4249,10 @@ Please submit there instead, or use --nodevelproject to force direct submission. def _prdiff_output_diff(self, opts, rdiff): if opts.diffstat: print() - p = subprocess.Popen("diffstat", - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - close_fds=True) - p.stdin.write(rdiff) - p.stdin.close() - print("".join(decode_it(x) for x in p.stdout.readlines())) + with subprocess.Popen("diffstat", stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True) as p: + p.stdin.write(rdiff) + p.stdin.close() + print("".join(decode_it(x) for x in p.stdout.readlines())) elif opts.unified: print() if isinstance(rdiff, str): diff --git a/osc/connection.py b/osc/connection.py index 0154c0f8..db7afd64 100644 --- a/osc/connection.py +++ b/osc/connection.py @@ -123,6 +123,24 @@ HTTP_PROXY_MANAGER = get_proxy_manager("HTTP_PROXY") HTTPS_PROXY_MANAGER = get_proxy_manager("HTTPS_PROXY") +def http_request_wrap_file(func): + """ + Turn file path into a file object and close it automatically + by using a context manager. + """ + def new_func(method, url, headers=None, data=None, file=None): + if file: + with open(file, "rb") as f: + return func(method, url, headers, data, file=f) + else: + return func(method, url, headers, data, file) + + new_func.__name__ = func.__name__ + new_func.__doc__ = func.__doc__ + return new_func + + +@http_request_wrap_file def http_request(method, url, headers=None, data=None, file=None): """ Send a HTTP request to a server. @@ -162,8 +180,8 @@ def http_request(method, url, headers=None, data=None, file=None): data = data.encode("utf-8") content_length = len(data) elif file: - content_length = os.path.getsize(file) - data = open(file, "rb") + content_length = os.fstat(file.fileno()).st_size + data = file else: content_length = 0 diff --git a/osc/core.py b/osc/core.py index 3716281e..f039315f 100644 --- a/osc/core.py +++ b/osc/core.py @@ -2023,7 +2023,8 @@ class Package: if not add: tmpl = b'-%s' ltmpl = b'@@ -1,%d +0,0 @@\n' - lines = [tmpl % i for i in open(fname, 'rb').readlines()] + with open(fname, 'rb') as f: + lines = [tmpl % i for i in f.readlines()] if len(lines): diff.append(ltmpl % len(lines)) if not lines[-1].endswith(b'\n'): @@ -3277,7 +3278,8 @@ def store_readlist(dir, name): r = [] if os.path.exists(os.path.join(dir, store, name)): - r = [line.rstrip('\n') for line in open(os.path.join(dir, store, name))] + with open(os.path.join(dir, store, name)) as f: + r = [line.rstrip('\n') for line in f] return r def read_tobeadded(dir): @@ -3293,7 +3295,8 @@ def read_sizelimit(dir): fname = os.path.join(dir, store, '_size_limit') if os.path.exists(fname): - r = open(fname).readline().strip() + with open(fname) as f: + r = f.readline().strip() if r is None or not r.isdigit(): return None @@ -3351,7 +3354,8 @@ def check_store_version(dir): versionfile = os.path.join(dir, store, '_osclib_version') try: - v = open(versionfile).read().strip() + with open(versionfile) as f: + v = f.read().strip() except: v = '' @@ -4741,7 +4745,8 @@ def binary(s): def binary_file(fn): """read 4096 bytes from a file named fn, and call binary() on the data""" - return binary(open(fn, 'rb').read(4096)) + with open(fn, 'rb') as f: + return binary(f.read(4096)) def get_source_file_diff(dir, filename, rev, oldfilename = None, olddir = None, origfilename = None): @@ -6500,7 +6505,8 @@ def store_read_project(dir): global store try: - p = open(os.path.join(dir, store, '_project')).readlines()[0].strip() + with open(os.path.join(dir, store, '_project')) as f: + p = f.readline().strip() except OSError: msg = 'Error: \'%s\' is not an osc project dir or working copy' % os.path.abspath(dir) if os.path.exists(os.path.join(dir, '.svn')): @@ -6513,7 +6519,8 @@ def store_read_package(dir): global store try: - p = open(os.path.join(dir, store, '_package')).readlines()[0].strip() + with open(os.path.join(dir, store, '_package')) as f: + p = f.readline().strip() except OSError: msg = 'Error: \'%s\' is not an osc package working copy' % os.path.abspath(dir) if os.path.exists(os.path.join(dir, '.svn')): @@ -6541,7 +6548,8 @@ def store_read_apiurl(dir, defaulturl=True): fname = os.path.join(dir, store, '_apiurl') try: - url = open(fname).readlines()[0].strip() + with open(fname) as f: + url = f.readlines()[0].strip() # this is needed to get a proper apiurl # (former osc versions may stored an apiurl with a trailing slash etc.) apiurl = conf.urljoin(*conf.parse_apisrv_url(None, url)) @@ -6612,8 +6620,8 @@ def store_read_file(dir, file): global store try: - content = open(os.path.join(dir, store, file)).read() - return content + with open(os.path.join(dir, store, file)) as f: + return f.read() except: return None diff --git a/tests/common.py b/tests/common.py index 0cb5c200..0e6766b8 100644 --- a/tests/common.py +++ b/tests/common.py @@ -233,8 +233,7 @@ class OscTestCase(unittest.TestCase): def _check_list(self, fname, exp): fname = os.path.join('.osc', fname) - self.assertTrue(os.path.exists(fname)) - self.assertEqual(open(fname).read(), exp) + self.assertFileContentEqual(fname, exp) def _check_addlist(self, exp): self._check_list('_to_be_added', exp) @@ -262,6 +261,22 @@ class OscTestCase(unittest.TestCase): self.assertTrue(os.path.exists(os.path.join('.osc', i.get('name')))) self.assertEqual(osc.core.dgst(os.path.join('.osc', i.get('name'))), i.get('md5')) + def assertFilesEqual(self, first, second): + self.assertTrue(os.path.exists(first)) + self.assertTrue(os.path.exists(second)) + with open(first) as f1, open(second) as f2: + self.assertEqual(f1.read(), f2.read()) + + def assertFileContentEqual(self, file_path, expected_content): + self.assertTrue(os.path.exists(file_path)) + with open(file_path) as f: + self.assertEqual(f.read(), expected_content) + + def assertFileContentNotEqual(self, file_path, expected_content): + self.assertTrue(os.path.exists(file_path)) + with open(file_path) as f: + self.assertNotEqual(f.read(), expected_content) + def assertXMLEqual(self, act, exp): if xml_equal(act, exp): return diff --git a/tests/test_addfiles.py b/tests/test_addfiles.py index 4dba1f3f..bfee7ff4 100644 --- a/tests/test_addfiles.py +++ b/tests/test_addfiles.py @@ -66,12 +66,12 @@ class TestAddFiles(OscTestCase): """replace a deleted file ('foo')""" self._change_to_pkg('simple') p = osc.core.Package('.') - open('foo', 'w').write('replaced file\n') + with open('foo', 'w') as f: + f.write('replaced file\n') p.addfile('foo') exp = 'A foo\n' self.assertEqual(sys.stdout.getvalue(), exp) - self.assertTrue(os.path.exists(os.path.join('.osc', 'foo'))) - self.assertNotEqual(open(os.path.join('.osc', 'foo')).read(), 'replaced file\n') + self.assertFileContentNotEqual(os.path.join('.osc', 'foo'), 'replaced file\n') self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_deleted'))) self._check_status(p, 'foo', 'R') self._check_addlist('foo\n') diff --git a/tests/test_commit.py b/tests/test_commit.py index 2aab8b1e..667ab6ea 100644 --- a/tests/test_commit.py +++ b/tests/test_commit.py @@ -40,7 +40,7 @@ class TestCommit(OscTestCase): self.assertEqual(sys.stdout.getvalue(), exp) self._check_digests('testSimple_cfilesremote') self.assertTrue(os.path.exists('nochange')) - self.assertEqual(open('nochange').read(), open(os.path.join('.osc', 'nochange')).read()) + self.assertFilesEqual('nochange', os.path.join('.osc', 'nochange')) self._check_status(p, 'nochange', ' ') self._check_status(p, 'foo', ' ') self._check_status(p, 'merge', ' ') @@ -64,7 +64,7 @@ class TestCommit(OscTestCase): self.assertEqual(sys.stdout.getvalue(), exp) self._check_digests('testAddfile_cfilesremote') self.assertTrue(os.path.exists('add')) - self.assertEqual(open('add').read(), open(os.path.join('.osc', 'add')).read()) + self.assertFilesEqual('add', os.path.join('.osc', 'add')) self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added'))) self._check_status(p, 'add', ' ') self._check_status(p, 'foo', ' ') @@ -241,7 +241,7 @@ class TestCommit(OscTestCase): self.assertEqual(sys.stdout.getvalue(), exp) self._check_digests('testAddfile_cfilesremote') self.assertTrue(os.path.exists('add')) - self.assertEqual(open('add').read(), open(os.path.join('.osc', 'add')).read()) + self.assertFilesEqual('add', os.path.join('.osc', 'add')) self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added'))) self._check_status(p, 'add', ' ') self._check_status(p, 'foo', ' ') @@ -341,7 +341,7 @@ class TestCommit(OscTestCase): self.assertEqual(sys.stdout.getvalue(), exp) self._check_digests('testSimple_cfilesremote') self.assertTrue(os.path.exists('nochange')) - self.assertEqual(open('nochange').read(), open(os.path.join('.osc', 'nochange')).read()) + self.assertFilesEqual('nochange', os.path.join('.osc', 'nochange')) self._check_status(p, 'nochange', ' ') self._check_status(p, 'foo', ' ') self._check_status(p, 'merge', ' ') diff --git a/tests/test_init_package.py b/tests/test_init_package.py index fa0bf5f1..30519ac4 100644 --- a/tests/test_init_package.py +++ b/tests/test_init_package.py @@ -84,7 +84,8 @@ class TestInitPackage(OscTestCase): """initialize a package dir (dir is a file)""" pac_dir = os.path.join(self.tmpdir, 'testpkg') os.mkdir(pac_dir) - open(os.path.join(pac_dir, osc.core.store), 'w').write('foo\n') + with open(os.path.join(pac_dir, osc.core.store), 'w') as f: + f.write('foo\n') self.assertRaises(osc.oscerr.OscIOError, osc.core.Package.init_package, 'http://localhost', 'osctest', 'testpkg', pac_dir) if __name__ == '__main__': diff --git a/tests/test_repairwc.py b/tests/test_repairwc.py index ee58ff33..cb224b02 100644 --- a/tests/test_repairwc.py +++ b/tests/test_repairwc.py @@ -192,7 +192,7 @@ class TestRepairWC(OscTestCase): p = osc.core.Package('.', wc_check=False) p.wc_repair('http://localhost') self.assertTrue(os.path.exists(os.path.join('.osc', '_apiurl'))) - self.assertEqual(open(os.path.join('.osc', '_apiurl')).read(), 'http://localhost\n') + self.assertFileContentEqual(os.path.join('.osc', '_apiurl'), 'http://localhost\n') self.assertEqual(p.apiurl, 'http://localhost') def test_invalidapiurl(self): @@ -201,7 +201,7 @@ class TestRepairWC(OscTestCase): p = osc.core.Package('.', wc_check=False) p.wc_repair('http://localhost') self.assertTrue(os.path.exists(os.path.join('.osc', '_apiurl'))) - self.assertEqual(open(os.path.join('.osc', '_apiurl')).read(), 'http://localhost\n') + self.assertFileContentEqual(os.path.join('.osc', '_apiurl'), 'http://localhost\n') self.assertEqual(p.apiurl, 'http://localhost') def test_noapiurlNotExistingApiurl(self): @@ -223,7 +223,7 @@ class TestRepairWC(OscTestCase): prj.wc_repair('http://localhost') self.assertTrue(os.path.exists(os.path.join(storedir, '_apiurl'))) self.assertTrue(os.path.exists(os.path.join(storedir, '_apiurl'))) - self.assertEqual(open(os.path.join(storedir, '_apiurl')).read(), 'http://localhost\n') + self.assertFileContentEqual(os.path.join(storedir, '_apiurl'), 'http://localhost\n') if __name__ == '__main__': diff --git a/tests/test_request.py b/tests/test_request.py index 89807786..9bd84b7a 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -322,7 +322,7 @@ class TestRequest(OscTestCase): def test_read_request1(self): """read in a request""" - xml = open(os.path.join(self._get_fixtures_dir(), 'test_read_request1.xml')).read().strip() + xml = self._get_fixture('test_read_request1.xml') r = osc.core.Request() r.read(ET.fromstring(xml)) self.assertEqual(r.reqid, '42') @@ -353,7 +353,7 @@ class TestRequest(OscTestCase): def test_read_request2(self): """read in a request (with reviews)""" - xml = open(os.path.join(self._get_fixtures_dir(), 'test_read_request2.xml')).read().strip() + xml = self._get_fixture('test_read_request2.xml') r = osc.core.Request() r.read(ET.fromstring(xml)) self.assertEqual(r.reqid, '123') @@ -427,7 +427,7 @@ class TestRequest(OscTestCase): def test_request_list_view1(self): """test the list_view method""" - xml = open(os.path.join(self._get_fixtures_dir(), 'test_request_list_view1.xml')).read().strip() + xml = self._get_fixture('test_request_list_view1.xml') exp = """\ 62 State:new By:Admin When:2010-12-29T14:57:25 set_bugowner: buguser foo @@ -444,7 +444,7 @@ class TestRequest(OscTestCase): def test_request_list_view2(self): """test the list_view method (with history elements and description)""" - xml = open(os.path.join(self._get_fixtures_dir(), 'test_request_list_view2.xml')).read().strip() + xml = self._get_fixture('test_request_list_view2.xml') r = osc.core.Request() r.read(ET.fromstring(xml)) exp = """\ @@ -458,7 +458,7 @@ class TestRequest(OscTestCase): def test_request_str1(self): """test the __str__ method""" - xml = open(os.path.join(self._get_fixtures_dir(), 'test_request_str1.xml')).read().strip() + xml = self._get_fixture('test_request_str1.xml') r = osc.core.Request() r = osc.core.Request() r.read(ET.fromstring(xml)) @@ -555,7 +555,7 @@ Comment: """ def test_get_actions(self): """test get_actions method""" - xml = open(os.path.join(self._get_fixtures_dir(), 'test_request_list_view1.xml')).read().strip() + xml = self._get_fixture('test_request_list_view1.xml') r = osc.core.Request() r.read(ET.fromstring(xml)) sr_actions = r.get_actions('submit') diff --git a/tests/test_revertfiles.py b/tests/test_revertfiles.py index a6b93d88..3248a312 100644 --- a/tests/test_revertfiles.py +++ b/tests/test_revertfiles.py @@ -93,7 +93,7 @@ class TestRevertFiles(OscTestCase): storefile = os.path.join('.osc', fname) self.assertTrue(os.path.exists(fname)) self.assertTrue(os.path.exists(storefile)) - self.assertEqual(open(fname).read(), open(storefile).read()) + self.assertFilesEqual(fname, storefile) if __name__ == '__main__': import unittest diff --git a/tests/test_update.py b/tests/test_update.py index c0b2f168..f6c81a4b 100644 --- a/tests/test_update.py +++ b/tests/test_update.py @@ -115,7 +115,7 @@ class TestUpdate(OscTestCase): self.assertEqual(sys.stdout.getvalue(), exp) self._check_deletelist('foo\n') self._check_conflictlist('merge\n') - self.assertEqual(open('foo').read(), open(os.path.join('.osc', 'foo')).read()) + self.assertFilesEqual('foo', os.path.join('.osc', 'foo')) self._check_digests('testUpdateLocalDeletions_files') @GET('http://localhost/source/osctest/restore?rev=latest', file='testUpdateRestore_files') @@ -201,11 +201,9 @@ class TestUpdate(OscTestCase): exp = 'A bigfile\nD _service:exists\nA _service:bar\nA _service:foo\nAt revision 2.\n' self.assertEqual(sys.stdout.getvalue(), exp) self.assertFalse(os.path.exists(os.path.join('.osc', '_service:bar'))) - self.assertTrue(os.path.exists('_service:bar')) - self.assertEqual(open('_service:bar').read(), 'another service\n') + self.assertFileContentEqual('_service:bar', 'another service\n') self.assertFalse(os.path.exists(os.path.join('.osc', '_service:foo'))) - self.assertTrue(os.path.exists('_service:foo')) - self.assertEqual(open('_service:foo').read(), 'small\n') + self.assertFileContentEqual('_service:foo', 'small\n') self.assertTrue(os.path.exists('_service:exists')) self._check_digests('testUpdateServiceFilesAddDelete_files', '_service:foo', '_service:bar') From 4848b0f42a80823233ebc2550af325fb7725a14c Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Wed, 24 Aug 2022 09:53:26 +0200 Subject: [PATCH 4/7] Move __version__ from osc.core to osc Fixes issues with circular module deps during tests that caused that osc.core wasn't available --- osc/__init__.py | 18 +++++++++++++++++- osc/connection.py | 5 +++-- osc/core.py | 5 +---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/osc/__init__.py b/osc/__init__.py index 475cc39e..1572977f 100644 --- a/osc/__init__.py +++ b/osc/__init__.py @@ -1,3 +1,19 @@ -__all__ = ['babysitter', 'core', 'commandline', 'oscerr', 'build', 'fetch', 'meter', 'grabber'] +__all__ = [ + 'babysitter', + 'build', + 'connection', + 'commandline', + 'core', + 'fetch', + 'grabber', + 'meter', + 'oscerr', + 'oscssl', +] + + +from .util import git_version +__version__ = git_version.get_version('1.0.0~b1') + # vim: sw=4 et diff --git a/osc/connection.py b/osc/connection.py index db7afd64..dd2acf4e 100644 --- a/osc/connection.py +++ b/osc/connection.py @@ -16,6 +16,7 @@ import urllib3.poolmanager import urllib3.response import urllib3.util +from . import __version__ from . import conf from . import oscerr from . import oscssl @@ -98,7 +99,7 @@ def get_proxy_manager(env): proxy_headers = urllib3.make_headers( proxy_basic_auth=proxy_purl.auth, - user_agent=f"osc/{core.__version__}", + user_agent=f"osc/{__version__}", ) manager = urllib3.ProxyManager(proxy_url, proxy_headers=proxy_headers) @@ -171,7 +172,7 @@ def http_request(method, url, headers=None, data=None, file=None): headers = urllib3.response.HTTPHeaderDict(headers or {}) # identify osc - headers.update(urllib3.make_headers(user_agent=f"osc/{core.__version__}")) + headers.update(urllib3.make_headers(user_agent=f"osc/{__version__}")) if data and file: raise RuntimeError('Specify either `data` or `file`') diff --git a/osc/core.py b/osc/core.py index f039315f..ed9257b9 100644 --- a/osc/core.py +++ b/osc/core.py @@ -4,10 +4,6 @@ # either version 2, or version 3 (at your option). -from .util import git_version -__version__ = git_version.get_version('1.0.0~b1') - - # __store_version__ is to be incremented when the format of the working copy # "store" changes in an incompatible way. Please add any needed migration # functionality to check_store_version(). @@ -37,6 +33,7 @@ try: except ImportError: distro = None +from . import __version__ from . import conf from . import oscerr from .connection import http_request, http_GET, http_POST, http_PUT, http_DELETE From 8cdd4abea7f9f097ace26da9dbb5108ed7d6c48d Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Wed, 24 Aug 2022 10:05:49 +0200 Subject: [PATCH 5/7] Move python package metadata from setup.py to setup.cfg --- setup.cfg | 46 +++++++++++++++++++++++++++++++++ setup.py | 76 ++----------------------------------------------------- 2 files changed, 48 insertions(+), 74 deletions(-) diff --git a/setup.cfg b/setup.cfg index 2b40afff..330ef770 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,49 @@ +[metadata] +name = osc +version = attr: osc.__version__ +description = openSUSE commander +long_description = Command-line client for the Open Build Service +keywords = openSUSE, SUSE, RPM, build, buildservice, command-line +license = GPLv2+ +url = http://en.opensuse.org/openSUSE:OSC +download_url = https://github.com/openSUSE/osc +author = openSUSE project +author_email = opensuse-buildservice@opensuse.org +classifiers = + Development Status :: 5 - Production/Stable + Environment :: Console + Intended Audience :: Developers + Intended Audience :: Information Technology + Intended Audience :: System Administrators + License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+) + Operating System :: MacOS :: MacOS X + Operating System :: POSIX :: BSD :: FreeBSD + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Topic :: Software Development :: Build Tools + Topic :: System :: Archiving :: Packaging + +[options] +packages = + osc + osc.util +install_requires = + cryptography + # rpm is not available on pip, install a matching package manually prior installing osc + rpm + urllib3 + +[options.entry_points] +console_scripts = + osc = osc.babysitter:main + [flake8] exclude = .git,__pycache__ max-line-length = 120 diff --git a/setup.py b/setup.py index 6edfd149..a955cbdb 100755 --- a/setup.py +++ b/setup.py @@ -3,78 +3,6 @@ import setuptools -import osc.core - -with open("README.md") as fh: - lines = fh.readlines() - while lines: - line = lines[0].strip() - if not line or line.startswith("["): - # skip leading empty lines - # skip leading lines with links to badges - lines.pop(0) - continue - break - long_description = "".join(lines) - -cmdclass = { -} - -# keep build deps minimal and be tolerant to missing sphinx -# that is not needed during package build -try: - import sphinx.setup_command - cmdclass['build_doc'] = sphinx.setup_command.BuildDoc -except ImportError: - pass - - -setuptools.setup( - name='osc', - version=osc.core.__version__, - description='openSUSE commander', - long_description=long_description, - long_description_content_type="text/plain", - author='openSUSE project', - author_email='opensuse-buildservice@opensuse.org', - license='GPLv2+', - platforms=['Linux', 'MacOS X', 'FreeBSD'], - keywords=['openSUSE', 'SUSE', 'RPM', 'build', 'buildservice'], - url='http://en.opensuse.org/openSUSE:OSC', - download_url='https://github.com/openSUSE/osc', - packages=['osc', 'osc.util'], - install_requires=['cryptography', 'urllib3'], - extras_require={ - 'RPM signature verification': ['rpm'], - }, - entry_points={ - 'console_scripts': [ - 'osc=osc.babysitter:main' - ], - }, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "Intended Audience :: Developers", - "Intended Audience :: Information Technology", - "Intended Audience :: System Administrators", - "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", - "Operating System :: MacOS :: MacOS X", - "Operating System :: POSIX :: BSD :: FreeBSD", - "Operating System :: POSIX :: Linux", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Topic :: Software Development :: Build Tools", - "Topic :: System :: Archiving :: Packaging", - ], - # Override certain command classes with our own ones - cmdclass=cmdclass, - test_suite="tests", -) +if __name__ == "__main__": + setuptools.setup() From f480fef8d1b93d124d3b88d1017198d954047e8d Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Wed, 24 Aug 2022 10:06:17 +0200 Subject: [PATCH 6/7] Rename README to README.md in MANIFEST.in --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 71221356..1893347b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ include NEWS -include README +include README.md include AUTHORS include COPYING From 94a8bc88a4ee4b7474e5f42d7430f6a4c09df753 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Wed, 24 Aug 2022 10:27:52 +0200 Subject: [PATCH 7/7] GHA: Add pip install test --- .../{rpmbuild.yaml => build-install.yaml} | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) rename .github/workflows/{rpmbuild.yaml => build-install.yaml} (83%) diff --git a/.github/workflows/rpmbuild.yaml b/.github/workflows/build-install.yaml similarity index 83% rename from .github/workflows/rpmbuild.yaml rename to .github/workflows/build-install.yaml index ecbef030..fc6024fa 100644 --- a/.github/workflows/rpmbuild.yaml +++ b/.github/workflows/build-install.yaml @@ -1,4 +1,4 @@ -name: 'rpmbuild test' +name: 'build and installation tests' on: push: @@ -19,7 +19,7 @@ on: - 'doc/**' jobs: - test: + rpmbuild: name: 'rpmbuild test' runs-on: 'ubuntu-latest' strategy: @@ -84,3 +84,22 @@ jobs: git fetch upstream --tags --force ./contrib/build_rpm.py --srpm --rpm + + pip: + name: 'pip install test' + runs-on: 'ubuntu-latest' + strategy: + fail-fast: false + + steps: + - name: 'Install packages' + run: | + sudo apt-get -y update + sudo apt-get -y upgrade + sudo apt-get -y --no-install-recommends install git python3-pip python3-rpm + + - uses: actions/checkout@v3 + + - name: 'Install osc from pip' + run: | + pip3 install .