Skip to content

Commit a426e4e

Browse files
authored
remove uuid (#101)
* remove uuid * Address CI issues * More fixes * use rmtree to remove dir * ignore errors * remove new attribute from function * revert tmp dir change * remove unused import
1 parent 8fccc1d commit a426e4e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

cget/package.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import base64, copy, argparse, six
1+
import base64, copy, argparse, six, hashlib
22

33
def encode_url(url):
44
x = six.b(url[url.find('://')+3:])
@@ -30,6 +30,18 @@ def get_src_dir(self):
3030
if self.url.startswith('file://'):
3131
return self.url[7:] # Remove "file://"
3232
raise TypeError()
33+
def get_hash(self):
34+
str2hash = lambda x : hashlib.sha256(x.encode('utf-8')).hexdigest()
35+
name_h = self.name if self.name is not None else 'NoneName'
36+
name_h = str2hash(name_h)
37+
url_h = self.url if self.url is not None else 'NoneURL'
38+
url_h = str2hash(url_h)
39+
fname_h = self.fname if self.fname is not None else 'NoneFName'
40+
fname_h = str2hash(fname_h)
41+
recipe_h = self.recipe if self.recipe is not None else 'NoneRecipe'
42+
recipe_h = str2hash(recipe_h)
43+
total_h = name_h + url_h + fname_h + recipe_h
44+
return hashlib.sha256(total_h.encode('utf-8')).hexdigest()
3345

3446

3547
def fname_to_pkg(fname):

cget/prefix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os, shutil, shlex, six, inspect, click, contextlib, uuid, sys, functools
1+
import os, shutil, shlex, six, inspect, click, contextlib, sys, functools
22

33
from cget.builder import Builder
44
from cget.package import fname_to_pkg
@@ -312,7 +312,7 @@ def install(self, pb, test=False, test_all=False, generator=None, update=False,
312312
self.write_parent(pb, track=track)
313313
if update: self.remove(pb)
314314
else: return "Package {} already installed".format(pb.to_name())
315-
with self.create_builder(uuid.uuid4().hex, tmp=True) as builder:
315+
with self.create_builder(pb.pkg_src.get_hash(), tmp=True) as builder:
316316
# Fetch package
317317
src_dir = builder.fetch(pb.pkg_src.url, pb.hash, (pb.cmake != None), insecure=insecure)
318318
# Install any dependencies first

0 commit comments

Comments
 (0)