ghdl 0.4.8__tar.gz → 0.4.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ghdl
3
- Version: 0.4.8
3
+ Version: 0.4.9
4
4
  Summary: Binary Manager for Github Releases
5
5
  Author-email: Imran Khan <imran@khan.ovh>
6
6
  License: GNU AFFERO GENERAL PUBLIC LICENSE
@@ -4,10 +4,10 @@
4
4
 
5
5
  Usage:
6
6
  ghdl
7
- ghdl (-f <repo> | --force <repo>)
8
7
  ghdl [-n | --dry-run]
9
8
  ghdl (-h | --help)
10
9
  ghdl (-v | --version)
10
+ ghdl [-n] (-f <repo> | --force <repo>)
11
11
 
12
12
  Options:
13
13
  -h --help Show this screen.
@@ -1,3 +1,3 @@
1
- __version__ = "0.4.8"
1
+ __version__ = "0.4.9"
2
2
 
3
3
  from ghdl.main import main, set_dry, set_single
@@ -31,10 +31,9 @@
31
31
 
32
32
  (setv record.asset-filter (get info "asset_filter"))
33
33
 
34
- (if (not (in "name" info))
35
- (setv record.name
36
- (-> record.repo (.split "/") (get 1)))
37
- (setv record.name (get info "name")))
34
+ (if (in "name" info)
35
+ (setv record.name (get info "name"))
36
+ (setv record.name (-> record.repo (.split "/") (get 1))))
38
37
 
39
38
  (setv record.release-filter (.get info "release_filter" None))
40
39
 
@@ -30,7 +30,7 @@
30
30
  (for [[asset url] url_data]
31
31
  (when (f asset)
32
32
  (return url))))
33
-
33
+
34
34
  (if (isinstance asset-filter str)
35
35
  (do
36
36
  (setv pattern (re.compile asset-filter re.IGNORECASE))
@@ -71,7 +71,7 @@
71
71
  (setv record.toUpdate? False))))
72
72
 
73
73
 
74
- (defn check-single [repo]
74
+ (defn skip-single [repo]
75
75
  (as-> Config.single it
76
76
  (and it (!= repo it))))
77
77
 
@@ -88,7 +88,7 @@
88
88
 
89
89
 
90
90
  (defn :async fetch-remote-local-metadata-1 [record client]
91
- (when (check-single record.repo) (return))
91
+ (when (skip-single record.repo) (return))
92
92
  (when (and record.pin (not (= (platform.machine) record.pin))) (return))
93
93
 
94
94
  (await (add-remote-metadata record client))
@@ -98,7 +98,7 @@
98
98
 
99
99
  (defn process-loop [records]
100
100
  (for [record records]
101
- (when (check-single record.repo) (continue))
101
+ (when (skip-single record.repo) (continue))
102
102
  (when (and record.pin (not (= (platform.machine) record.pin))) (continue))
103
103
 
104
104
  (when record.toUpdate?
@@ -142,6 +142,7 @@
142
142
  (setv Config.dry-run True))
143
143
 
144
144
 
145
+ ;; If a repo is deleted from config, then running this just deletes entry from DB
145
146
  (defn set-single [repo]
146
147
  (local-db.delete-row repo)
147
148
  (setv Config.single repo))
@@ -20,13 +20,13 @@
20
20
  (-> timestring (dateutil.parser.parse) (.strftime "%s") (int)))
21
21
 
22
22
 
23
- (defn find-matching-release [resp release-filter]
23
+ (defn find-matching-release [resp record]
24
+ (setv pattern (re.compile record.release-filter))
24
25
  (for [release resp]
25
- (setv name (get release "name"))
26
- (setv pattern (re.compile release-filter))
27
- (when (bool (re.search pattern name))
26
+ (when (and (bool (re.search pattern (get release "name")))
27
+ (= (get release "prerelease") record.pre-release?))
28
28
  (return release)))
29
- (print f"No matching release found for: {release-filter}")
29
+ (print f"No matching release found for: {record.release-filter}")
30
30
  (raise NoMatchingReleaseException))
31
31
 
32
32
 
@@ -37,7 +37,7 @@
37
37
  (setv resp (.json (await (client.get api :headers headers))))
38
38
  (cond
39
39
  record.pre-release? (get resp 0)
40
- record.release-filter (find-matching-release resp record.release-filter)
40
+ record.release-filter (find-matching-release resp record)
41
41
  True resp))
42
42
 
43
43
 
@@ -1,6 +1,5 @@
1
1
  LICENSE
2
2
  MANIFEST.in
3
- README.org
4
3
  pyproject.toml
5
4
  bin/ghdl
6
5
  bin/ghdl-delete-repo
@@ -1,10 +1,10 @@
1
1
  [project]
2
2
  name = "ghdl"
3
- version = "0.4.8"
4
3
  description = "Binary Manager for Github Releases"
5
4
  authors = [{name = "Imran Khan", email = "imran@khan.ovh"}]
6
5
  license = {file = "LICENSE"}
7
6
  requires-python = ">=3.8,<3.13"
7
+ dynamic = ["version"]
8
8
  dependencies = [
9
9
  "xtract ==0.1a3",
10
10
  "xdg >=4.0.1",
@@ -20,6 +20,9 @@ dependencies = [
20
20
  script-files = ["bin/ghdl", "bin/ghdl-delete-repo"]
21
21
  include-package-data = true
22
22
 
23
+ [tool.setuptools.dynamic]
24
+ version = {attr = "ghdl.__version__"}
25
+
23
26
  [tool.uv]
24
27
  prerelease = "if-necessary-or-explicit"
25
28
  python-downloads = "never"
ghdl-0.4.8/README.org DELETED
@@ -1,173 +0,0 @@
1
- *** GHDL
2
-
3
- Download and keep self-contained executables from Github Releases updated.
4
-
5
- *** Install
6
-
7
- #+begin_src sh
8
- pip install ghdl
9
- #+end_src
10
-
11
- Additionally, it requires your system to have sqlite, libmagic and tools relevant to archives like tar, gzip, unzip etc. installed.
12
-
13
- *** About
14
-
15
- More and more projects are doing self-contained multi-platform/architecture binary releases at github. While distro provided packages remain the best idea, they are not a portable/zero-maintenance solution. If you hop between machines running on different hardware/OS/architecture, it's convenient to just download binaries directly.
16
-
17
- But doing so and keeping them updated manually is tedious. With this tool you can automate the task by encapsulating the logic in a config file which you can then carry aroud, maybe even hook up to a cron and forget.
18
-
19
- *** Config
20
-
21
- The config file should be provided at =~/.config/ghdl/config=. It looks like:
22
-
23
- #+begin_src hy
24
- (repo "containers/crun"
25
- :asset-filter "static")
26
- #+end_src
27
-
28
- When you run ghdl, it will download the asset with "static" in its name, extract the archive if needed, find the binary, and place it in =~/.local/bin/= (by default). And next time you run ghdl it won't be downloaded again, unless upstream releases new version in-between.
29
-
30
- **** Options
31
-
32
- These are the options you can specify:
33
-
34
- ***** =:asset-filter= (required)
35
-
36
- A regular expression that can uniquely identify an asset from a list of them in the latest _release_ section of the target repo. Matching is done case-insensitively.
37
-
38
- ***** =:name=
39
-
40
- Name the binary will be saved as. Default is to infer it from repo name, so when the repo is "containers/crun" the name will by default be "crun".
41
-
42
- ***** =:basename-glob=
43
-
44
- When asset is an archive, ghdl automatically extracts it. But it needs to know which file to install, as there are usually multiple files in the archive. By default it can filter out only binaries using libmagic, and by default it looks for a binary that matches "=*{name}*=" glob pattern which almost always works (=name= is what's described above). So in practice, you will likely need to set this very rarely. For example, below you could omit it because the binary is named "devd" which is matched by the glob "\ast{}devd\ast{}" anyway:
45
-
46
- #+begin_src hy
47
- (repo "cortesi/devd"
48
- :basename-glob "devd" ;; Not necessary
49
- :asset-filter "linux64")
50
- #+end_src
51
-
52
- And in the following case, again the binary name "kompose-linux-amd64" is already covered by glob "\ast{}kompose\ast{}":
53
-
54
- #+begin_src hy
55
- (repo "kubernetes/kompose"
56
- :basename-glob "kompose*" ;; Not necessary
57
- :asset-filter "linux-amd64.*gz$")
58
- #+end_src
59
-
60
- Sometimes the default is too broad. For example, in case of repo "=github/hub=" the binary is named just "hub" which isn't a problem, but the glob "\ast{}hub\ast{}" matches not just the binary but some other doc file too. Except that's where libmagic comes in and filters out all non-application mimetypes.
61
-
62
- #+begin_src hy
63
- (repo "github/hub"
64
- :basename-glob "hub" ;; Again not necessary
65
- :asset-filter "linux-amd64")
66
- #+end_src
67
-
68
- So in practice, it's probably going to be exceedingly rare when this setting will be called for action.
69
-
70
- ***** =:strip=
71
-
72
- Whether to run strip on the downloaded binary or not, default is True. But you may need to set it to =False= sometimes, e.g. say for appimages:
73
-
74
- #+begin_src hy
75
- (repo "neovim/neovim"
76
- :url-filter "appimage$"
77
- :strip False)
78
- #+end_src
79
-
80
- Stripping can reduce the size of binaries considerably (here the /bin/strip is invoked without argument), but this might not be without trade-off. I have once seen a distro turn off stripping for Golang binaries citing strange behaviour. I have never encountered any problem myself though, so I am keeping this True by default.
81
-
82
- ***** =:prerelease=
83
-
84
- You can also choose to live in the edge, some packages for some reason choose to release as pre-release only anyway (so far).
85
-
86
- #+begin_src hy
87
- (repo "borkdude/babashka"
88
- :name "bb"
89
- :asset-filter "static"
90
- :prerelease True)
91
- #+end_src
92
-
93
- ***** =:pin=
94
-
95
- Sometimes you might want to pin a particular repo to a particular architecture as that's all they support in github releases. Here pinning can be useful to create portable configuration, as ghdl simply won't do anything when run on anything different. For example,
96
-
97
- #+begin_src hy
98
- (repo "LukeChannings/deno-arm64"
99
- :name "deno"
100
- :pin "aarch64"
101
- :asset-filter "deno")
102
- #+end_src
103
-
104
- As this is an aarch64 specific project, pinning ensures the recipe won't even be run on say x86_64, so you are spared of the failure message.
105
-
106
- ***** =:release-filter=
107
-
108
- Some projects release multiple unrelated kind of artefacts under same repo. While we still can't have multiple entries for same repo in ghdl, if you want to filter a particular kind of release amidst many, this is helpful. For example ~biomejs/biome~ repo releases VSCode Extension and CLI under same repo, if we just want the CLI, we need to first find the matching release:
109
-
110
- #+begin_src hy
111
- (repo "biomejs/biome"
112
- :release-filter "\\bCLI\\b" ;; regex with word boundary
113
- :asset-filter f"linux-x64") ;; this will now look into the release found by :release-filter
114
- #+end_src
115
-
116
- **** Advanced Configuration
117
-
118
- The goal is to eventually define something that hopefully can continue to work cross-platform. So ghdl config file is actually Hy code, which means one can do whatever they can in python, and some useful python modules (=re=, =platform= etc.) are loaded already:
119
-
120
- #+begin_src hy
121
- (setv my-os (platform.system)
122
- my-arch (platform.machine))
123
-
124
- (setv arch-pattern
125
- (cond (= my-arch "x86_64") "(?:x86[-_]64|x64|amd64|64bit)"
126
- (= my-arch "aarch64") "(?:arm|aarch)64"))
127
-
128
- ;; Many golang projects follow this pattern
129
- (setv os-arch f"{my-os}[-_.]{arch-pattern}")
130
-
131
- ;; Many rust projects follow this pattern
132
- (setv rust f"{my-arch}.*?{my-os}")
133
-
134
- ;; Finally define the repos
135
- (repo "caddyserver/caddy"
136
- :asset-filter f"{os-arch}.*gz")
137
-
138
- (repo "sharkdp/bat"
139
- :asset-filter rust)
140
- #+end_src
141
-
142
- If that seems ugly or inadequate, =:asset-filter= can also be a function (of type =String -> Bool=):
143
-
144
- #+begin_src hy
145
- (repo "smallhadroncollider/taskell"
146
- :asset-filter
147
- (fn [asset]
148
- (and
149
- (in (str.replace (platform.machine) "_" "-") asset)
150
- (in (str.lower (platform.system)) asset)
151
- (str.endswith asset ".gz"))))
152
- #+end_src
153
-
154
- **** Additional Config
155
-
156
- You really should user your own API token if possible. Unauthorized API is only limited to 60 calls per hour, so if you have more than 60 repos you need to use a token anyway.
157
-
158
- #+begin_src hy
159
- (config
160
- :location "~/.local/bin/"
161
- :token "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
162
- #+end_src
163
-
164
- **** Sample config
165
-
166
- The repo contains a [[file:./sample-config][sample config]] file as an example where I am tracking 140+ projects (as of writing this). Most of them has been well behaved and consistent since creating ghdl.
167
-
168
- *** TODO/Limitation/Ideas
169
-
170
- - Some programs use same repo to release different parts of project (e.g. dnote does it for server and cli), ghdl can choose one of them, but not multiple at the same time.
171
- - Some projects include multiple binaries. That's not yet supported, though is probably simple to add.
172
- - Windows/MacOS doesn't work yet (so much for cross-platform), although fix should be simple; I just don't know various xdg path equivalents in it nor do I have motivation or means to test. However one needs to have tar, gzip etc. in the path which means the likes of msys2, git bash, WSL or whatever, and in those it just might work ootb.
173
- - Downloads from github could be slow in some parts of the world, nothing could done about that apart from maybe switching to an external downloader (like aria2) from current pure python one.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes