THRIFT-4717: fix up make clean with autoconf
diff --git a/lib/py/Makefile.am b/lib/py/Makefile.am
index 5861858..46e4405 100644
--- a/lib/py/Makefile.am
+++ b/lib/py/Makefile.am
@@ -40,13 +40,19 @@
 install-exec-hook:
 	$(PYTHON) setup.py install --root=$(DESTDIR) --prefix=$(PY_PREFIX) $(PYTHON_SETUPUTIL_ARGS)
 
-clean-local:
-	$(RM) -r build
-
 check-local: all py3-test
 	$(PYTHON) test/thrift_json.py
 	$(PYTHON) test/test_sslsocket.py
 
+clean-local:
+	$(RM) -r build
+	find . -type f \( -iname "*.pyc" \) | xargs rm -f
+	find . -type d \( -iname "__pycache__" -or -iname "_trial_temp" \) | xargs rm -rf
+
+dist-hook:
+	find $(distdir) -type f \( -iname "*.pyc" \) | xargs rm -f
+	find $(distdir) -type d \( -iname "__pycache__" -or -iname "_trial_temp" \) | xargs rm -rf
+
 EXTRA_DIST = \
 	CMakeLists.txt \
 	MANIFEST.in \