Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include file path when generating file hash #4821

Merged
merged 17 commits into from
Jun 10, 2024
4 changes: 4 additions & 0 deletions conda_build/os_utils/liefldd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,10 @@ def __call__(self, *args, **kw):
if not data:
break
sha1.update(data)
# update with file name, if its a different
# file with the same contents, we don't want
# to treat it as cached
sha1.update(arg.encode("utf-8"))
timkpaine marked this conversation as resolved.
Show resolved Hide resolved
arg = sha1.hexdigest()
if isinstance(arg, list):
newargs.append(tuple(arg))
Expand Down
8 changes: 8 additions & 0 deletions tests/test-recipes/split-packages/_test-file-hash/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
echo "int main() {}" > main.c
mkdir -p $PREFIX/bin
$CC main.c -o $PREFIX/bin/_file_hash

echo "int foo() {return 2;}" > foo.c
echo "int foo(); int bar() {return foo()*2;}" > bar.c
$CC -shared foo.c -o libupstream.so
$CC -shared bar.c -o libdownstream.so -L$PWD -lupstream '-Wl,-rpath,$ORIGIN'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
python:
- 3.10
- 3.11
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mkdir -p $SP_DIR/_py_file_hash
cp libdownstream.so $SP_DIR/_py_file_hash/
cp libupstream.so $SP_DIR/_py_file_hash/

30 changes: 30 additions & 0 deletions tests/test-recipes/split-packages/_test-file-hash/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package:
name: _file_hash-split
version: 0.0.1

build:
number: 0
skip: True # [not linux64]
error_overlinking: true

requirements:
build:
- {{ compiler('c') }}
host:
run:

outputs:
- name: py-file-hash
script: install-py.sh
requirements:
build:
- {{ compiler('c') }}
host:
- python
run:
- python

- name: _file_hash
requirements:
build:
- {{ compiler('c') }}
22 changes: 21 additions & 1 deletion tests/test_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package_has_file,
)

from .utils import add_mangling, metadata_dir
from .utils import add_mangling, metadata_dir, subpackage_path


@pytest.mark.skipif(
Expand Down Expand Up @@ -156,6 +156,26 @@ def test_menuinst_validation_fails_bad_json(testing_config, caplog, tmp_path):
assert "JSONDecodeError" in captured_text


def test_file_hash(testing_config, caplog, tmp_path):
"check that the post-link check caching takes the file path into consideration"
recipe = Path(subpackage_path, "_test-file-hash")
recipe_tmp = tmp_path / "test-file-hash"
shutil.copytree(recipe, recipe_tmp)

variants = {"python": ["3.11", "3.12"]}
testing_config.ignore_system_config = True
testing_config.activate = True

with caplog.at_level(logging.INFO):
api.build(
str(recipe_tmp),
config=testing_config,
notest=True,
variants=variants,
activate=True,
)


@pytest.mark.skipif(on_win, reason="rpath fixup not done on Windows.")
def test_rpath_symlink(mocker, testing_config):
if on_linux:
Expand Down
Loading