--- Lib/distutils/command/install_lib.py.orig 2018-04-29 22:47:33 UTC +++ Lib/distutils/command/install_lib.py @@ -168,10 +168,14 @@ class install_lib(Command): ext = os.path.splitext(os.path.normcase(py_file))[1] if ext != PYTHON_SOURCE_EXTENSION: continue - if self.compile: - bytecode_files.append(py_file + "c") - if self.optimize > 0: - bytecode_files.append(py_file + "o") + + pyc_file = py_file + "c" + if self.compile and os.path.isfile(pyc_file): + bytecode_files.append(pyc_file) + + pyo_file = py_file + "o" + if self.optimize > 0 and os.path.isfile(pyo_file): + bytecode_files.append(pyo_file) return bytecode_files