Skip to content

Commit ca629ca

Browse files
committed
The first part of the hash should be the path to the tools executable
Signed-off-by: Pedro Algarvio <[email protected]>
1 parent f26edcf commit ca629ca

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/ptscripts/parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,20 @@ def requirements_hash(self) -> str:
119119
Returns a sha256 hash of the requirements.
120120
"""
121121
requirements_hash = hashlib.sha256()
122+
# The first part of the hash should be the path to the tools executable
123+
requirements_hash.update(sys.argv[0].encode())
124+
# The second, TOOLS_VIRTUALENV_CACHE_SEED env variable, if set
122125
hash_seed = os.environ.get("TOOLS_VIRTUALENV_CACHE_SEED", "")
123126
requirements_hash.update(hash_seed.encode())
127+
# Third, any custom pip cli argument defined
124128
if self.pip_args:
125129
for argument in self.pip_args:
126130
requirements_hash.update(argument.encode())
131+
# Forth, each passed requirement
127132
if self.requirements:
128133
for requirement in sorted(self.requirements):
129134
requirements_hash.update(requirement.encode())
135+
# And, lastly, any requirements files passed in
130136
if self.requirements_files:
131137
for fpath in sorted(self.requirements_files):
132138
with _cast_to_pathlib_path(fpath).open("rb") as rfh:

0 commit comments

Comments
 (0)