File tree Expand file tree Collapse file tree 3 files changed +60
-3
lines changed
contrib/package/nix/partftpy Expand file tree Collapse file tree 3 files changed +60
-3
lines changed Original file line number Diff line number Diff line change 4
4
fetchurl ,
5
5
setuptools ,
6
6
} :
7
+ let
8
+ pinData = lib . importJSON ./pin.json ;
9
+ in
7
10
8
11
buildPythonPackage rec {
9
12
pname = "partftpy" ;
10
- version = "0.4.0" ;
13
+ inherit ( pinData ) version ;
11
14
pyproject = true ;
12
15
13
16
src = fetchurl {
14
- url = "https://github.com/9001/partftpy/releases/download/v0.4.0/partftpy-0.4.0.tar.gz" ;
15
- hash = "sha256-5Q2zyuJ892PGZmb+YXg0ZPW/DK8RDL1uE0j5HPd4We0=" ;
17
+ inherit ( pinData ) url hash ;
16
18
} ;
17
19
18
20
build-system = [ setuptools ] ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "url" : " https://github.com/9001/partftpy/releases/download/v0.4.0/partftpy-0.4.0.tar.gz" ,
3
+ "version" : " 0.4.0" ,
4
+ "hash" : " sha256-5Q2zyuJ892PGZmb+YXg0ZPW/DK8RDL1uE0j5HPd4We0="
5
+ }
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+
3
+ # Update the Nix package pin
4
+ #
5
+ # Usage: ./update.sh
6
+
7
+ import base64
8
+ import json
9
+ import hashlib
10
+ import sys
11
+ from pathlib import Path
12
+
13
+ OUTPUT_FILE = Path ("pin.json" )
14
+ TARGET_ASSET = lambda version : f"partftpy-{ version } .tar.gz"
15
+ HASH_TYPE = "sha256"
16
+ LATEST_RELEASE_URL = "https://api.github.com/repos/9001/partftpy/releases/latest"
17
+
18
+
19
+ def get_formatted_hash (binary ):
20
+ hasher = hashlib .new ("sha256" )
21
+ hasher .update (binary )
22
+ asset_hash = hasher .digest ()
23
+ encoded_hash = base64 .b64encode (asset_hash ).decode ("ascii" )
24
+ return f"{ HASH_TYPE } -{ encoded_hash } "
25
+
26
+
27
+ def remote_release_pin ():
28
+ import requests
29
+
30
+ response = requests .get (LATEST_RELEASE_URL ).json ()
31
+ version = response ["tag_name" ].lstrip ("v" )
32
+ asset_info = [a for a in response ["assets" ] if a ["name" ] == TARGET_ASSET (version )][0 ]
33
+ download_url = asset_info ["browser_download_url" ]
34
+ asset = requests .get (download_url )
35
+ formatted_hash = get_formatted_hash (asset .content )
36
+
37
+ result = {"url" : download_url , "version" : version , "hash" : formatted_hash }
38
+ return result
39
+
40
+
41
+ def main ():
42
+ result = remote_release_pin ()
43
+
44
+ print (result )
45
+ json_result = json .dumps (result , indent = 4 )
46
+ OUTPUT_FILE .write_text (json_result )
47
+
48
+
49
+ if __name__ == "__main__" :
50
+ main ()
You can’t perform that action at this time.
0 commit comments