Merge pull request #18746 from olupton:fix-repeated-builds

PiperOrigin-RevId: 586723814
This commit is contained in:
jax authors 2023-11-30 10:47:45 -08:00
commit dab6379995

View File

@ -103,10 +103,19 @@ def _get_cmdclass(pkg_source_path):
class _build_py(build_py_orig):
def run(self):
if _release_version is None:
this_file_in_build_dir = os.path.join(self.build_lib, pkg_source_path,
os.path.basename(__file__))
# super().run() only copies files from source -> build if they are
# missing or outdated. Because _write_version(...) modifies the copy of
# this file in the build tree, re-building from the same JAX directory
# would not automatically re-copy a clean version, and _write_version
# would fail without this deletion. See google/jax#18252.
if os.path.isfile(this_file_in_build_dir):
os.unlink(this_file_in_build_dir)
super().run()
if _release_version is None:
_write_version(os.path.join(self.build_lib, pkg_source_path,
os.path.basename(__file__)))
_write_version(this_file_in_build_dir)
class _sdist(sdist_orig):
def make_release_tree(self, base_dir, files):