diff --git a/lxm3/xm_cluster/packaging/archive_builder.py b/lxm3/xm_cluster/packaging/archive_builder.py index b45e10e..562047f 100644 --- a/lxm3/xm_cluster/packaging/archive_builder.py +++ b/lxm3/xm_cluster/packaging/archive_builder.py @@ -1,4 +1,5 @@ import datetime +import filecmp import glob import os import shutil @@ -74,9 +75,13 @@ def create_python_archive( if not os.path.exists(target_file): shutil.copy(src, target_file) else: - raise ValueError( - "Additional resource overwrites existing file: %s", src - ) + # Trying to override a file in the archive, + # check if the file contents are the same + if not filecmp.cmp(src, target_file): + # Raise if contents differ + raise ValueError( + "Additional resource overwrites existing file: %s", src + ) if os.path.exists(os.path.join(tmpdir, "bin")): console.log('Removing "bin/" directory as these are not yet portable.') diff --git a/tests/packaging_test.py b/tests/packaging_test.py index 34ccc6e..dd6b7bf 100644 --- a/tests/packaging_test.py +++ b/tests/packaging_test.py @@ -36,6 +36,32 @@ def test_package_python(self, pkg_fun): ) self.assertIsInstance(executable, xm_cluster.Command) + # @parameterized.parameters((cluster._package_python_package,)) + # def test_package_python_resource_overwrites(self, pkg_fun): + # resource = xm_cluster.Fileset( + # files={ + # os.path.join( + # _HERE, "testdata/test_pkg/py_package/main.py" + # ): "py_package/main.py", + # } + # ) + # spec = xm_cluster.PythonPackage( + # entrypoint=xm_cluster.ModuleName("py_package.main"), + # path=os.path.join(_HERE, "testdata/test_pkg"), + # resources=[resource], + # ) + + # tmpdir = self.create_tempdir().full_path + # store = artifacts.LocalArtifactStore(tmpdir, "test") + # pkg_fun( + # spec, + # xm.Packageable( + # spec, + # xm_cluster.Local().Spec(), + # ), + # store, + # ) + def test_package_default_pip_args(self): spec = xm_cluster.PythonPackage( entrypoint=xm_cluster.ModuleName("py_package.main"),