diff --git a/lib/SConscript b/lib/SConscript
index 4627621..21f3d99 100644
--- a/lib/SConscript
+++ b/lib/SConscript
@@ -18,8 +18,9 @@ env = mypaintlib_env
 # I have given up. Scons just can't get the dependencies right with those
 # code generators. Let's give scons a "normal" c++ project to dependency-scan.
 swig_opts = '-DHAVE_GEGL' if env['enable_gegl'] else ''
-if env.Execute('swig -Wall -o mypaintlib_wrap.cpp -noproxydel -python -c++ %s mypaintlib.i' % swig_opts):
-    Exit(1)
+if not env.GetOption('clean'):
+    if env.Execute('swig -Wall -o mypaintlib_wrap.cpp -noproxydel -python -c++ %s mypaintlib.i' % swig_opts):
+        Exit(1)
 env.Clean('.', 'mypaintlib_wrap.cpp')
 env.Clean('.', 'mypaintlib.py')
 env.Clean('.', Glob('*.o'))
