Repository: cython/cython

Issue:
Replace deprecated functions: `setup.py install`, `setDaemon()`, `unittest.makeSuite()` and `Py_SetProgramName`
From a [recent CI run](https://github.com/cython/cython/actions/runs/3427928705/jobs/5711531558) using Python 3.11 I found the following 4 deprecation warnings, aside from the major `distutils` deprecation, which got it's own issue (#5133):
- [x] `setup.py install`: [/opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/site-packages/setuptools/command/install.py:34](https://github.com/cython/cython/actions/runs/3427928705/jobs/5711531558#step:5:721): SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
- [x] `setDaemon()`: [/home/runner/work/cython/cython/runtests.py:2533:](https://github.com/cython/cython/actions/runs/3427928705/jobs/5711531558#step:5:1404) DeprecationWarning: setDaemon() is deprecated, set the daemon attribute instead
- [x] `unittest.makeSuite()`: [runTest (__main__.EndToEndTest.runTest)](https://github.com/cython/cython/actions/runs/3427928705/jobs/5711531558#step:5:1439)
  [5] End-to-end package_compilation ... /home/runner/work/cython/cython/runtests.py:747: DeprecationWarning: unittest.makeSuite() is deprecated and will be removed in Python 3.13. Please use unittest.TestLoader.loadTestsFromTestCase() instead.
  suite.addTest(unittest.makeSuite(EmbedTest))
- [x] `Py_SetProgramName`: [runTest (__main__.CythonCompileTestCase.runTest)](https://github.com/cython/cython/actions/runs/3427928705/jobs/5711531558#step:5:14827)
  ```
  [1] compiling (c/cy2) wave_function ... embedded.c: In function ‘__Pyx_main’:
  embedded.c:3183:9: warning: ‘Py_SetProgramName’ is deprecated [-Wdeprecated-declarations]
           Py_SetProgramName(argv[0]);
           ^~~~~~~~~~~~~~~~~
  In file included from /opt/hostedtoolcache/Python/3.11.0/x64/include/python3.11/Python.h:94,
                   from embedded.c:16:
  /opt/hostedtoolcache/Python/3.11.0/x64/include/python3.11/pylifecycle.h:37:38: note: declared here
   Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetProgramName(const wchar_t *);
                                        ^~~~~~~~~~~~~~~~~
  embedded.c:3191:9: warning: ‘PySys_SetArgv’ is deprecated [-Wdeprecated-declarations]
           PySys_SetArgv(argc, argv);
           ^~~~~~~~~~~~~
  In file included from /opt/hostedtoolcache/Python/3.11.0/x64/include/python3.11/Python.h:96,
                   from embedded.c:16:
  /opt/hostedtoolcache/Python/3.11.0/x64/include/python3.11/sysmodule.h:13:38: note: declared here
   Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetArgv(int, wchar_t **);
                                        ^~~~~~~~~~~~~
  ```
- [x] `Py_OptimizeFlag` [cython/Cython/Compiler/FusedNode.c:4987:5](https://github.com/cython/cython/actions/runs/3673976186/jobs/6211650606#step:5:447): warning: ‘Py_OptimizeFlag’ is deprecated [-Wdeprecated-declarations]

These deprecated functions will all become failures at some point, so should be replaced, removed or otherwise fixed.


Discussion:
I checked today's [CI run](https://github.com/cython/cython/actions/runs/3673976186) which used Python 3.12 alpha 3 for the 3.12 jobs, and discovered one new deprecation (which occurred a lot!)

> warning: `‘Py_OptimizeFlag’` is deprecated

I added it to the list above.
@scoder i think #5210 doesn't fix thf issue fully, so it should stay open
Thanks. I specifically changed the commit comment to not close this ticket automatically, but Github closed it anyway. Reopening.

Resolving patch:
diff --git a/runtests.py b/runtests.py
--- a/runtests.py
+++ b/runtests.py
@@ -2541,7 +2541,7 @@ def time_stamper():
             write('\n#### %s\n' % now())
 
     thread = threading.Thread(target=time_stamper, name='time_stamper')
-    thread.setDaemon(True)  # Py2 ...
+    thread.daemon = True
     thread.start()
     try:
         yield


Test patch: