Description: Fix build sequence for Debian
 This fix allows performing setup actions such as cleaning without importing
 printcore dependencies.
 .
 It restricts the Cython call to build-time and not every time the setup.py
 file is called.
Forwarded: not-needed
Author: Rock Storm <rockstorm@gmx.com>

--- a/setup.py
+++ b/setup.py
@@ -19,18 +19,22 @@
 import glob
 from setuptools import setup
 from setuptools import find_packages
+from setuptools import extension
+from setuptools.command.build_ext import build_ext as build_ext_orig
 
 try:
     from Cython.Build import cythonize
-    extensions = cythonize("printrun/gcoder_line.pyx")
-    from Cython.Distutils import build_ext
+    # extensions = cythonize("printrun/gcoder_line.pyx")
+    # from Cython.Distutils import build_ext
+    extensions = [extension.Extension("printrun.gcoder_line",
+                                      ["printrun/gcoder_line.c"])]
 except ImportError as e:
     print("WARNING: Failed to cythonize: %s" % e)
     # Debug helper: uncomment these:
     # import traceback
     # traceback.print_exc()
     extensions = None
-    build_ext = None
+    # build_ext = None
 
 
 with open('README.md') as f:
@@ -64,6 +68,15 @@
     data_files.append((f'share/{locale}', glob.glob(f'{locale}/*.mo')))
 
 
+class build_ext (build_ext_orig):
+
+    def run(self):
+        try:
+            cythonize("printrun/gcoder_line.pyx")
+        except NameError as e:
+            print("WARNING: Failed to cythonize: %s" % e)
+        super().run()
+
 setup(
     name="Printrun",
     version=__version__,
@@ -79,7 +92,8 @@
     ext_modules=extensions,
     python_requires=">=3.6",
     install_requires=install_requires,
-    setup_requires=["Cython"],
+    # setup_requires=["Cython"],
+    cmdclass = {"build_ext": build_ext},
     classifiers=[
         "Environment :: X11 Applications :: GTK",
         "Intended Audience :: End Users/Desktop",
