[PATCH] D67533: [LNT] Python 3 support: Set up (client) setup requirements

Hubert Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 12 20:54:58 PDT 2019


hubert.reinterpretcast created this revision.
hubert.reinterpretcast added reviewers: cmatthews, thopre, kristof.beyls.

Changes required to allow setup of a LNT client with Python 3.

- Use `PyModule_Create` instead of `Py_InitModule`
- Add environment markers to skip argparse and wsgiref for Python 3
- Add `requirements-py3.client.txt` for `setup.py`


https://reviews.llvm.org/D67533

Files:
  lnt/testing/profile/cPerf.cpp
  requirements-py3.client.txt
  requirements.client.txt
  setup.py


Index: setup.py
===================================================================
--- setup.py
+++ setup.py
@@ -30,7 +30,10 @@
     sys.argv.remove("--server")
     req_file = "requirements.server.txt"
 else:
-    req_file = "requirements.client.txt"
+    if sys.version_info[0] > 2:
+        req_file = "requirements-py3.client.txt"
+    else:
+        req_file = "requirements.client.txt"
 try:
     install_reqs = parse_requirements(req_file, session=False)
 except TypeError:
Index: requirements.client.txt
===================================================================
--- requirements.client.txt
+++ requirements.client.txt
@@ -7,12 +7,12 @@
 MarkupSafe==0.23
 SQLAlchemy==1.1.11
 Werkzeug==0.12.2
-argparse==1.3.0
+argparse==1.3.0;python_version<"3.0"
 itsdangerous==0.24
 python-dateutil==2.6.0
 python-gnupg==0.3.7
 pytz==2016.10
-wsgiref==0.1.2
+wsgiref==0.1.2;python_version<"3.0"
 WTForms==2.0.2
 Flask-WTF==0.12
 typing
Index: requirements-py3.client.txt
===================================================================
--- requirements-py3.client.txt
+++ requirements-py3.client.txt
@@ -7,12 +7,10 @@
 MarkupSafe==0.23
 SQLAlchemy==1.1.11
 Werkzeug==0.12.2
-argparse==1.3.0
 itsdangerous==0.24
 python-dateutil==2.6.0
 python-gnupg==0.3.7
 pytz==2016.10
-wsgiref==0.1.2
 WTForms==2.0.2
 Flask-WTF==0.12
 typing
Index: lnt/testing/profile/cPerf.cpp
===================================================================
--- lnt/testing/profile/cPerf.cpp
+++ lnt/testing/profile/cPerf.cpp
@@ -812,7 +812,25 @@
                                       "Import perf.data from a filename"},
                                      {NULL, NULL, 0, NULL}};
 
-PyMODINIT_FUNC initcPerf(void) { (void)Py_InitModule("cPerf", cPerfMethods); }
+#if PY_MAJOR_VERSION >= 3
+static PyModuleDef cPerfModuleDef = {PyModuleDef_HEAD_INIT,
+                                     "cPerf",
+                                     nullptr,
+                                     -1,
+                                     cPerfMethods,
+                                     nullptr,
+                                     nullptr,
+                                     nullptr,
+                                     nullptr};
+#endif
+
+PyMODINIT_FUNC initcPerf(void) {
+#if PY_MAJOR_VERSION >= 3
+  return PyModule_Create(&cPerfModuleDef);
+#else
+  (void)Py_InitModule("cPerf", cPerfMethods);
+#endif
+}
 
 #else // STANDALONE
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67533.220038.patch
Type: text/x-patch
Size: 2419 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190913/174e19f1/attachment.bin>


More information about the llvm-commits mailing list