# code removed, as it is replaced by the code of my posting below.
Well, not yet pushed to github, but when I execute nimble in the gintro directory it does indeed work.
If you don't know what it is: It is nimble install for https://github.com/StefanSalewski/nim-gi with new name gintro suggested by Araq.
But a few questions remain:
Currently I have to type "nimble prepair" followed by "nimble install". I guess some users may prefer to type only "nimble install". So I tried the before install hook. but that does not work, the hook seems to be not executed. What "nimble prepair" does: It generates all the modules like gtk.nim, glib.nim, pango.nim ... into the gintro directory. That dir is initially empty. If that is done, then "nimble install" installs that files into ~/.nimble/pkgs/gintro-0.1.0/gintro
That is fine, and after that I can place my applications everywhere, use imports like gintro/gtk and I can compile them. Great.
Next question: mode = Whatif as mentioned in nimscript module would make debugging easier, but I got it not working, Whatif symbol was undefined.
Next: In ~/.nimble/pkgs/gintro-0.1.0/gintro I get all the generated modules, and that modules partly import each other. Currently the modules still use plain import, for example gtk.nim uses import glib, gobject. Seems still to work. Should I fix that to import gintro/glib, gintro/gobject?
Next: What shall I do with the example files from the tutorial in examples directory?
Next: listFiles() seems to give not plain file names, but directory prefix, which is difficult to remove. Is there a better way.
Well, the dependency check for gtk developer files are still missing, I will add that tomorrow. And some more checks and cleanup when possible.
Given all the git clone, maybe use submodules and git submodule update --init --recursive.
This way you can also use a specific version/tag/branch of the imported lib instead of master
It's nice that it works, but it seems the wrong idea :-). Instead of
exec("git clone https://github.com/ngtk3/nim-gdk_pixbuf")
Use
requires "nim-gdk_pixbuf"
That means more nimble packages to write, but in general a github project should have a nimble file.
Thanks for your suggestion Araq, but as I already told Mr mratsim, the ngtk3 files are only needed for the install process, they are never used later by the users of gintro package and they are deleted after install of gintro. I could put the nim files from ngtk3 into s subdirectory inside the new gintro package, that would avoid the exec(gitclone). But I do not see the benefit. You are right, I could try to make a real nimble package from the old ngtk3 repositories -- I would have to find a top level package name for the files then which is not so easy, maybe salewskinimgtk320 or so. But no one beside me has used the low level GTK3 3.20 modules until now, and now where the high level module begins to work, I think no one will care for the old module any more. (That does not mean that it would not make sense to use them, as they are created by c2nim, they have nearly no bugs, and using them is not that difficult, when one knows how GTK3 is generally used from C.)
My most serious problem is the need for "nimble prepair" currently. Most users will just try "nimble install" and that will fail of course. I just found an nimble issue related to the before hook, see https://github.com/nim-lang/nimble/issues/280. So my fear is, that a plain "nimble install" will not be able indeed. I think I have to ask dom96.
[EDIT]
Araq pointed out that I need indeed only glib, gobject and gir modules from legacy gntk3 for bootstrapping, so I cleaned up gintro.nimble file. But that changes NOTHING for ALL my other remarks, it only saves some internet bandwidth for the install process!
Well, this is the cleaned up version. We do check for dev packages on ubuntu, check if tmp dir already exists and delete tmp dir when done. Problem with mode = Whatif was that Whatif is a pure enum, issue is posted. The modules still import each other directly, without the gintro prefix. Seems to work fine, I hope that is indeed intended and desired.
I can install my local package fine with "nimble prepare", "nimble install". From bug
https://github.com/nim-lang/nimble/issues/280
I think I can not avoid that nimble prepare. But I am still not sure if "nimble prepare" will work for remote packages at all!
$ ls -lt
total 36
-rw-r--r-- 1 stefan stefan 1530 Jul 7 17:40 gintro.nimble
drwxr-xr-x 1 stefan stefan 210 Jul 7 17:36 gintro
drwxr-xr-x 1 stefan stefan 48 Jul 7 12:35 tests
drwxr-xr-x 1 stefan stefan 80 Jul 7 12:29 examples
-rw-r--r-- 1 stefan stefan 25629 Jul 6 15:27 README.adoc
-rw-r--r-- 1 stefan stefan 1071 Jul 6 15:26 LICENSE
$ cat gintro.nimble
# Package
version = "0.1.0"
author = "Stefan Salewski"
description = "High level GObject-Introspection based GTK3 bindings"
license = "MIT"
skipDirs = @["tests"]
# Dependencies
requires "nim >= 0.17.0"
when defined(nimdistros):
import distros
if detectOs(Ubuntu) or detectOs(Debian):
foreignDep "libgtk-3-dev"
elif detectOs(Gentoo):
foreignDep "gtk+" # can we specify gtk3?
#else: we don't know the names for all the other distributions
# foreignDep "openssl"
import ospaths
proc prep =
let this = thisDir()
let td = getTempDir()
cd(td)
let wd = "gintrosalewski"
if dirExists(wd):
quit("gintro: tmp directory already exists!")
mkDir(wd)
cd(wd)
mkDir("ngtk3")
cd("ngtk3")
exec("git clone https://github.com/ngtk3/nim-glib")
exec("git clone https://github.com/ngtk3/nim-gobject")
exec("git clone https://github.com/ngtk3/nim-gir")
cpFile(this / "tests" / "gen.nim", td / wd / "gen.nim")
cpFile(this / "tests" / "combinatorics.nim", td / wd / "combinatorics.nim")
cpFile("nim-glib/src/glib.nim", td / wd / "glib.nim")
cpFile("nim-gobject/src/gobject.nim", td / wd / "gobject.nim")
cpFile("nim-gir/src/gir.nim", td / wd / "gir.nim")
cd(td)
cd(wd)
exec("nim c gen.nim")
mkDir("nim_gi")
exec(td / wd / "gen")
let mods = listFiles("nim_gi")
for i in mods:
let j = i[7 .. ^1]
cpFile(i, this / "gintro" / j)
cd(td)
rmDir(wd) # cleanup
task prepare, "preparing gintro":
#before install:
echo "preparing gintro"
prep()