From nobody Fri Mar 25 13:51:18 2022 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3F7E31A34C39; Fri, 25 Mar 2022 13:51:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KQ3Qt6tBFz3hLV; Fri, 25 Mar 2022 13:51:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648216279; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=54nRxxyM4bzj9oJrm1TG+zflRK173DLva8puImVCZ9o=; b=YdY8CweOYxSo42Do06ceevpN1cwy68tQqxrGfp/SZcjdlqdiNn/xOptPoGz5XZ4M9r4kio LvUlU+CIugyXKZxtSgNPYdM+0yEHNtKBeCwZtAeFpB6wnTI7v2PBIcKHOoTj8Lc/XJCoI0 FTdn3AS/klyCbZG2sS2UZWqmxbKY7vo+b/ufgwzUDhU6X9YifPRyGz6koL/C/v00uOawYZ JQ/pVl02KWkaEsEoZYI28Hsnv2A96wrWBDgkNdXBPJmaAVoJRrIKJqI7Jc+CV9yfoAlb5w hkAo4Sl38C2jWQwMRjgDO7G3idionwUc57Yz6p3l0ly6Qk3RhSIwFVCcNOBbEg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4BF945966; Fri, 25 Mar 2022 13:51:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22PDpIB3038095; Fri, 25 Mar 2022 13:51:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22PDpIWE038094; Fri, 25 Mar 2022 13:51:18 GMT (envelope-from git) Date: Fri, 25 Mar 2022 13:51:18 GMT Message-Id: <202203251351.22PDpIWE038094@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Po-Chuan Hsieh Subject: git: 219183ada617 - main - www/py-restclient: Fix build with setuptools 58.0.0+ List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: sunpoet X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 219183ada617bcafecf02842e919120a4b07fa54 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648216279; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=54nRxxyM4bzj9oJrm1TG+zflRK173DLva8puImVCZ9o=; b=tK2bCu/abWCXn5hh3bVQTFrR/aeZFUZBytjig4CnqzcsR1yhTWcx/59yCJPpsPA9kiR5lS RB4hKx17n/rC+h9HS1TRwsDuT1bss9x7lWBRqU77BeaWctvLnojlNEdKc0qaN/zl606VVC EDl5byz56iQvkBK1Do002zJUN8tbmN4EjhA7UvPB3jhEMpOgwlYPB254PFEiFvGdV0E3fW NS93lGEMOH2bIqQLcMMsm+V/3vWoA+UPH8L9RqFKq8zHMdLEecK+dYlmZwp44XDdtQiAdY hK8Bvr6X4na/JvHEDCsfZ7gdwIXoy5RnLtjX20Dg9gI7tfEplVdcpA1zMhZ+ag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648216279; a=rsa-sha256; cv=none; b=xGn0cRkOC8S8uDtdJtLbBnMFfbVJSOUU4JWkJ45UL8e8E2zx00m7rY0ENyCHR9o9oFExLJ RnzklClY/7Q2RV3df7nywAoqD4HCJyRzccpMTJFk+mmuMMcujsHVimsWM0rgvFPILqrgeT 2y77/LogbVGq+rRH6J5vJqJyER1KKqDsc251E83DgHsrObzfsa0QtH60MYkNUt5ny7VXZH P50x9UQCpUpvuQrXpyNbfgxZ+cmotKErv2q+sRrep+RDetGrojBpv6MU0+Btsb5CSbtmEa 99xifZ9baYtHPFG4L0itwvJy3Dldiv2U01nMAwG2ltqgG22mqZUnLlcTnd4ceA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by sunpoet: URL: https://cgit.FreeBSD.org/ports/commit/?id=219183ada617bcafecf02842e919120a4b07fa54 commit 219183ada617bcafecf02842e919120a4b07fa54 Author: Po-Chuan Hsieh AuthorDate: 2022-03-25 13:35:22 +0000 Commit: Po-Chuan Hsieh CommitDate: 2022-03-25 13:38:25 +0000 www/py-restclient: Fix build with setuptools 58.0.0+ async is a reserved keyword since Python 3.7. Therefore, I change async to asynchronous to fix SyntaxError. With hat: python --- www/py-restclient/files/patch-2to3 | 377 +++++++++++++++++++++++++++++++++++++ 1 file changed, 377 insertions(+) diff --git a/www/py-restclient/files/patch-2to3 b/www/py-restclient/files/patch-2to3 new file mode 100644 index 000000000000..87ce7330c123 --- /dev/null +++ b/www/py-restclient/files/patch-2to3 @@ -0,0 +1,377 @@ +--- restclient/__init__.py.orig 2012-11-17 20:17:26 UTC ++++ restclient/__init__.py +@@ -84,10 +84,10 @@ CHANGESET: + + import httplib2 + import mimetypes +-import thread ++import _thread + import types +-import urllib +-import urllib2 ++import urllib.request, urllib.parse, urllib.error ++import urllib.request, urllib.error, urllib.parse + try: + import json + except ImportError: +@@ -168,7 +168,7 @@ def get_content_type(filename): + return mimetypes.guess_type(filename)[0] or 'application/octet-stream' + + +-def GET(url, params=None, files=None, accept=[], headers=None, async=False, ++def GET(url, params=None, files=None, accept=[], headers=None, asynchronous=False, + resp=False, credentials=None, httplib_params=None): + """ make an HTTP GET request. + +@@ -178,20 +178,20 @@ def GET(url, params=None, files=None, accept=[], heade + in addition, parameters and headers can be specified (as dicts). a + list of mimetypes to accept may be specified. + +- if async=True is passed in, it will perform the request in a new ++ if asynchronous=True is passed in, it will perform the request in a new + thread and immediately return nothing. + + if resp=True is passed in, it will return a tuple of an httplib2 + response object and the content instead of just the content. + """ +- return rest_invoke(url=url, method=u"GET", params=params, ++ return rest_invoke(url=url, method="GET", params=params, + files=files, accept=accept, headers=headers, +- async=async, resp=resp, credentials=credentials, ++ asynchronous=async, resp=resp, credentials=credentials, + httplib_params=httplib_params) + + + def POST(url, params=None, files=None, accept=[], headers=None, +- async=True, resp=False, credentials=None, httplib_params=None): ++ asynchronous=True, resp=False, credentials=None, httplib_params=None): + """ make an HTTP POST request. + + performs a POST request to the specified URL. +@@ -209,19 +209,19 @@ def POST(url, params=None, files=None, accept=[], head + (nothing) immediately. + + To wait for the response and have it return the body of the +- response, specify async=False. ++ response, specify asynchronous=False. + + if resp=True is passed in, it will return a tuple of an httplib2 + response object and the content instead of just the content. + """ +- return rest_invoke(url=url, method=u"POST", params=params, ++ return rest_invoke(url=url, method="POST", params=params, + files=files, accept=accept, headers=headers, +- async=async, resp=resp, credentials=credentials, ++ asynchronous=async, resp=resp, credentials=credentials, + httplib_params=httplib_params) + + + def PUT(url, params=None, files=None, accept=[], headers=None, +- async=True, resp=False, credentials=None, httplib_params=None): ++ asynchronous=True, resp=False, credentials=None, httplib_params=None): + """ make an HTTP PUT request. + + performs a PUT request to the specified URL. +@@ -239,20 +239,20 @@ def PUT(url, params=None, files=None, accept=[], heade + (nothing) immediately. + + To wait for the response and have it return the body of the +- response, specify async=False. ++ response, specify asynchronous=False. + + if resp=True is passed in, it will return a tuple of an httplib2 + response object and the content instead of just the content. + """ + +- return rest_invoke(url=url, method=u"PUT", params=params, ++ return rest_invoke(url=url, method="PUT", params=params, + files=files, accept=accept, headers=headers, +- async=async, resp=resp, credentials=credentials, ++ asynchronous=async, resp=resp, credentials=credentials, + httplib_params=httplib_params) + + + def DELETE(url, params=None, files=None, accept=[], headers=None, +- async=True, resp=False, credentials=None, ++ asynchronous=True, resp=False, credentials=None, + httplib_params=None): + """ make an HTTP DELETE request. + +@@ -265,20 +265,20 @@ def DELETE(url, params=None, files=None, accept=[], he + returns (nothing) immediately. + + To wait for the response and have it return the body of the +- response, specify async=False. ++ response, specify asynchronous=False. + + if resp=True is passed in, it will return a tuple of an httplib2 + response object and the content instead of just the content. + """ + +- return rest_invoke(url=url, method=u"DELETE", params=params, ++ return rest_invoke(url=url, method="DELETE", params=params, + files=files, accept=accept, headers=headers, +- async=async, resp=resp, credentials=credentials, ++ asynchronous=async, resp=resp, credentials=credentials, + httplib_params=httplib_params) + + +-def rest_invoke(url, method=u"GET", params=None, files=None, +- accept=[], headers=None, async=False, resp=False, ++def rest_invoke(url, method="GET", params=None, files=None, ++ accept=[], headers=None, asynchronous=False, resp=False, + httpcallback=None, credentials=None, + httplib_params=None): + """ make an HTTP request with all the trimmings. +@@ -315,7 +315,7 @@ def rest_invoke(url, method=u"GET", params=None, files + accept: list of mimetypes to accept in order of + preference. defaults to '*/*' + headers: dictionary of additional headers to send to the server +- async: Boolean. if true, does request in new thread and nothing is ++ asynchronous: Boolean. if true, does request in new thread and nothing is + returned + resp: Boolean. if true, returns a tuple of response, + content. otherwise returns just content +@@ -325,8 +325,8 @@ def rest_invoke(url, method=u"GET", params=None, files + httplib_params: dict of parameters supplied to httplib2 - for + example ca_certs='/etc/ssl/certs/ca-certificates.crt' + """ +- if async: +- thread.start_new_thread(_rest_invoke, ++ if asynchronous: ++ _thread.start_new_thread(_rest_invoke, + (url, method, params, files, accept, + headers, resp, httpcallback, credentials, + httplib_params)) +@@ -335,7 +335,7 @@ def rest_invoke(url, method=u"GET", params=None, files + resp, httpcallback, credentials, httplib_params) + + +-def _rest_invoke(url, method=u"GET", params=None, files=None, accept=None, ++def _rest_invoke(url, method="GET", params=None, files=None, accept=None, + headers=None, resp=False, httpcallback=None, + credentials=None, httplib_params=None): + if params is None: +@@ -363,7 +363,7 @@ def _rest_invoke(url, method=u"GET", params=None, file + headers[k] = v + + if httpcallback.username or httpcallback.password: +- print "warning: restclient can't handle HTTP auth yet" ++ print("warning: restclient can't handle HTTP auth yet") + if httpcallback.redirections != 5: + print ("warning: restclient doesn't support " + "HTTPCallback's restrictions yet") +@@ -371,18 +371,18 @@ def _rest_invoke(url, method=u"GET", params=None, file + print ("warning: restclient doesn't support " + "HTTPCallback's follow_all_redirects_yet") + if httpcallback.body != "": +- print "warning: restclient doesn't support HTTPCallback's body yet" ++ print("warning: restclient doesn't support HTTPCallback's body yet") + + headers = add_accepts(accept, headers) + if method in ['POST', 'PUT'] and 'Content-Type' not in headers: + headers['Content-Type'] = 'application/x-www-form-urlencoded' +- params = urllib.urlencode(fix_params(params)) ++ params = urllib.parse.urlencode(fix_params(params)) + elif (method in ['POST', 'PUT'] and + headers['Content-Type'] == 'application/json'): + params = json.dumps(params) + else: + # GET and DELETE requests +- params = urllib.urlencode(fix_params(params)) ++ params = urllib.parse.urlencode(fix_params(params)) + + if files: + return post_multipart(extract_host(url), extract_path(url), +@@ -463,11 +463,11 @@ def my_urlparse(url): + + + def unpack_params(params): +- return [(k, params[k]) for k in params.keys()] ++ return [(k, params[k]) for k in list(params.keys())] + + + def unpack_files(files): +- return [(k, files[k]['filename'], files[k]['file']) for k in files.keys()] ++ return [(k, files[k]['filename'], files[k]['file']) for k in list(files.keys())] + + + def add_accepts(accept=None, headers=None): +@@ -485,8 +485,8 @@ def add_accepts(accept=None, headers=None): + def fix_params(params=None): + if params is None: + params = {} +- for k in params.keys(): +- if type(k) not in types.StringTypes: ++ for k in list(params.keys()): ++ if type(k) not in (str,): + new_k = str(k) + params[new_k] = params[k] + del params[k] +@@ -500,8 +500,8 @@ def fix_params(params=None): + except UnicodeDecodeError: + pass + +- for k in params.keys(): +- if type(params[k]) not in types.StringTypes: ++ for k in list(params.keys()): ++ if type(params[k]) not in (str,): + params[k] = str(params[k]) + try: + params[k].encode('ascii') +@@ -517,12 +517,12 @@ def fix_params(params=None): + def fix_headers(headers=None): + if headers is None: + headers = {} +- for k in headers.keys(): +- if type(k) not in types.StringTypes: ++ for k in list(headers.keys()): ++ if type(k) not in (str,): + new_k = str(k) + headers[new_k] = headers[k] + del headers[k] +- if type(headers[k]) not in types.StringTypes: ++ if type(headers[k]) not in (str,): + headers[k] = str(headers[k]) + try: + headers[k].encode('ascii') +@@ -539,8 +539,8 @@ def fix_files(files=None): + if files is None: + files = {} + # fix keys in files +- for k in files.keys(): +- if type(k) not in types.StringTypes: ++ for k in list(files.keys()): ++ if type(k) not in (str,): + new_k = str(k) + files[new_k] = files[k] + del files[k] +@@ -551,7 +551,7 @@ def fix_files(files=None): + files[new_k] = files[k] + del files[k] + # second pass to fix filenames +- for k in files.keys(): ++ for k in list(files.keys()): + try: + files[k]['filename'].encode('ascii') + except UnicodeEncodeError: +@@ -560,15 +560,15 @@ def fix_files(files=None): + + + if __name__ == "__main__": +- print rest_invoke("http://localhost:9090/", ++ print(rest_invoke("http://localhost:9090/", + method="POST", params={'value': 'store this'}, +- accept=["text/plain", "text/html"], async=False) ++ accept=["text/plain", "text/html"], asynchronous=False)) + image = open('sample.jpg').read() + r = rest_invoke("http://resizer.ccnmtl.columbia.edu/resize", + method="POST", + files={'image': {'file': image, + 'filename': 'sample.jpg'}}, +- async=False) ++ asynchronous=False) + out = open("thumb.jpg", "w") + out.write(r) + out.close() +@@ -576,13 +576,13 @@ if __name__ == "__main__": + r = POST("http://resizer.ccnmtl.columbia.edu/resize", + files={'image': {'file': image, + 'filename': 'sample.jpg'}}, +- async=False) ++ asynchronous=False) + # evil unicode tests +- print rest_invoke(u"http://localhost:9090/foo/", +- params={u'foo\u2012': u'\u2012'}, +- headers={u"foo\u2012": u"foo\u2012"}) ++ print(rest_invoke("http://localhost:9090/foo/", ++ params={'foo\u2012': '\u2012'}, ++ headers={"foo\u2012": "foo\u2012"})) + +- r = rest_invoke(u"http://localhost:9090/resize", method="POST", +- files={u'image\u2012': {'file': image, +- 'filename': u'samp\u2012le.jpg'}}, +- async=False) ++ r = rest_invoke("http://localhost:9090/resize", method="POST", ++ files={'image\u2012': {'file': image, ++ 'filename': 'samp\u2012le.jpg'}}, ++ asynchronous=False) +--- restclient/test/test_everything.py.orig 2012-11-17 20:17:26 UTC ++++ restclient/test/test_everything.py +@@ -39,7 +39,7 @@ on each request it handles, please submit a patch. + + from restclient import * + import threading, os +-import BaseHTTPServer ++import http.server + import cgi + + port_num = int(os.environ.get('RESTCLIENT_TEST_PORT',11123)) +@@ -47,12 +47,12 @@ hostname = "http://localhost:%d/" % port_num + image = open('sample.jpg').read() + + def start_server(callback): +- class LoopbackHandler(BaseHTTPServer.BaseHTTPRequestHandler): ++ class LoopbackHandler(http.server.BaseHTTPRequestHandler): + """ a simple http server that will basically echo back the request + that was made to it """ + def respond(self): +- s = self.requestline + u"\n" \ +- + str(self.headers) + u"\n\n" \ ++ s = self.requestline + "\n" \ ++ + str(self.headers) + "\n\n" \ + + self.body() + + response = s.encode('utf-8') +@@ -82,7 +82,7 @@ def start_server(callback): + + def run(): + """ start the server for a single request """ +- server_class=BaseHTTPServer.HTTPServer ++ server_class=http.server.HTTPServer + handler_class=LoopbackHandler + server_address = ('', port_num) + httpd = server_class(server_address, handler_class) +@@ -116,7 +116,7 @@ def test_get(): + @servify + def test_post(): + expected = "POST\nvalue: store this\nDONE\n" +- r = POST(hostname, params={'value' : 'store this'}, accept=["text/plain","text/html"], async=False) ++ r = POST(hostname, params={'value' : 'store this'}, accept=["text/plain","text/html"], asynchronous=False) + assert r.startswith('POST /') + assert "value=store+this" in r + assert "accept: text/plain,text/html" in r +@@ -124,25 +124,25 @@ def test_post(): + @servify + def test_post_image(): + result = POST(hostname + "resize", files={'image' : {'file' : image, 'filename' : 'sample.jpg'}}, +- async=False) ++ asynchronous=False) + assert result.startswith('POST /resize') + assert "multipart" in result + + @servify + def test_get_unicode(): +- expected = u"GET\nfoo\u2012: \u2012\nDONE\n".encode('utf-8') +- r = GET(unicode(hostname + "foo/"),params={u'foo\u2012' : u'\u2012'}, +- headers={u"foo\u2012" : u"foo\u2012"}) ++ expected = "GET\nfoo\u2012: \u2012\nDONE\n".encode('utf-8') ++ r = GET(str(hostname + "foo/"),params={'foo\u2012' : '\u2012'}, ++ headers={"foo\u2012" : "foo\u2012"}) + # unicode in params gets urlencoded + assert r.startswith('GET /foo/?foo%E2%80%92=%E2%80%92') + # unicode in headers gets stripped out. they can only contain ascii. +- assert u"foo: foo" in r ++ assert "foo: foo" in r + + @servify + def test_post_unicode(): +- result = POST(unicode(hostname + "foo/"), +- params={u'foo\u2012' : u'\u2012'}, +- async=False) ++ result = POST(str(hostname + "foo/"), ++ params={'foo\u2012' : '\u2012'}, ++ asynchronous=False) + assert result.startswith('POST /foo/') + expected = "foo%E2%80%92=%E2%80%92" # urlencoded + assert expected in result