www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How do I install a library?

reply Murilo <murilomiranda92 hotmail.com> writes:
I want to install the library DlangUI but I don't know how to do 
it. In python I just type pip <pckg> and it works, but in D I 
don't know how to do it. Can anyone help me?
Nov 08 2018
next sibling parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 11/8/18 4:46 PM, Murilo wrote:
 I want to install the library DlangUI but I don't know how to do it. In 
 python I just type pip <pckg> and it works, but in D I don't know how to 
 do it. Can anyone help me?
dlangui will be fetched if you make it a dependency of your project. When you run dub init on your project, it will ask for dependencies, just type dlangui in there. -Steve
Nov 08 2018
parent reply Murilo <murilomiranda92 hotmail.com> writes:
On Thursday, 8 November 2018 at 22:28:38 UTC, Steven 
Schveighoffer wrote:
 On 11/8/18 4:46 PM, Murilo wrote:
 I want to install the library DlangUI but I don't know how to 
 do it. In python I just type pip <pckg> and it works, but in D 
 I don't know how to do it. Can anyone help me?
dlangui will be fetched if you make it a dependency of your project. When you run dub init on your project, it will ask for dependencies, just type dlangui in there. -Steve
Thanks, I tried that but when I add the import dlangui in the beginning it doesn't work. I wanted to just type import dlangui in the beginning of the file so I can call the dlangui functions.
Nov 08 2018
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 11/8/18 5:46 PM, Murilo wrote:
 On Thursday, 8 November 2018 at 22:28:38 UTC, Steven Schveighoffer wrote:
 On 11/8/18 4:46 PM, Murilo wrote:
 I want to install the library DlangUI but I don't know how to do it. 
 In python I just type pip <pckg> and it works, but in D I don't know 
 how to do it. Can anyone help me?
dlangui will be fetched if you make it a dependency of your project. When you run dub init on your project, it will ask for dependencies, just type dlangui in there.
Thanks, I tried that but when I add the import dlangui in the beginning it doesn't work. I wanted to just type import dlangui in the beginning of the file so I can call the dlangui functions.
D uses dub and code.dlang.org to fetch dependencies (similar to python or other ecosystems). If you are using dub to build your project, just add dlangui as a dependency, and you can then import and use it. This goes in your dub.json or dub.sdl file. See documentation here: http://code.dlang.org/getting_started If you want to build the dlangui library directly and install it on your own without dub, you would need to download the source (probably from github) and build it using dub. -Steve
Nov 08 2018
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 11/8/18 6:07 PM, Steven Schveighoffer wrote:

 If you want to build the dlangui library directly and install it on your 
 own without dub, you would need to download the source (probably from 
 github) and build it using dub.
When I said without using dub, I meant without using dub to build your project. You still need to use dub to build the library. -Steve
Nov 08 2018
parent reply Murilo <murilomiranda92 hotmail.com> writes:
On Thursday, 8 November 2018 at 23:28:05 UTC, Steven 
Schveighoffer wrote:
 On 11/8/18 6:07 PM, Steven Schveighoffer wrote:

 If you want to build the dlangui library directly and install 
 it on your own without dub, you would need to download the 
 source (probably from github) and build it using dub.
When I said without using dub, I meant without using dub to build your project. You still need to use dub to build the library. -Steve
It finally worked, but I can't just compile it normally, I have to use dub run, I wish it were something simple that I just download into the folder and then use an import statement and then compile it like any other program. I wish it were as simple as using std.stdio for example.
Nov 08 2018
next sibling parent reply bachmeier <no spam.net> writes:
On Thursday, 8 November 2018 at 23:43:38 UTC, Murilo wrote:

 It finally worked, but I can't just compile it normally, I have 
 to use dub run, I wish it were something simple that I just 
 download into the folder and then use an import statement and 
 then compile it like any other program. I wish it were as 
 simple as using std.stdio for example.
Unfortunately your stuck with Dub if you want to use D. It's an awful experience compared to Python and other scripting languages, so I understand what you're saying, but most people around here think Dub is the way to go.
Nov 08 2018
next sibling parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Thu, Nov 08, 2018 at 11:51:39PM +0000, bachmeier via Digitalmars-d-learn
wrote:
 On Thursday, 8 November 2018 at 23:43:38 UTC, Murilo wrote:
 
 It finally worked, but I can't just compile it normally, I have to
 use dub run, I wish it were something simple that I just download
 into the folder and then use an import statement and then compile it
 like any other program. I wish it were as simple as using std.stdio
 for example.
Unfortunately your stuck with Dub if you want to use D. It's an awful experience compared to Python and other scripting languages, so I understand what you're saying, but most people around here think Dub is the way to go.
It's not true that you're stuck with dub. And I'm not among the people who think dub is the way to go (though it's true that that's a minority opinion around here). Where I have a choice, my own D projects do not use dub. I have one project that uses dub because it's based on vibe.d, but I mostly avoid needing to use dub by creating an empty dub project in a subdirectory whose sole purpose is to declare a dependency on vibe.d. Then I build that once with dub, and outside in my real project I just link directly to the produced artifacts. (The exact path(s) to the dub products can be extracted from the output of `dub -v`. This can probably be automated and translated into your build system of choice, though I haven't quite gone that far yet.) Then I don't need to use dub except when upgrading the dub-dependent library. I find dub almost completely unusable for normal development, because: (1) it requires network access, (2) it's dog-slow compared to how fast the actual D compiler runs (it tries to do dependency updating every single time it runs, even when all you've done is to change 1 line in your code), (3) it either does not support incremental builds, or else is so bad at doing it that it takes about just as long as a full build from scratch; (4) it's not configurable enough to meet my build needs -- e.g., it's completely unable to handle my current Android project that involves compiling Java code, D code, GLSL code, and cross-compiling / linking / building an APK, plus compile and link an X11 test driver on the host PC, which involves invoking a different (non-cross) compiler with different libraries and a different set of source files -- dub's build spec simply isn't capable of expressing the level of configurability required to do all of this; (5) it imposes a source tree hierarchy that conflicts with what I need (Android SDK's APK tools expect a particular directory structure that does not fit into dub's model). While I appreciate the amount of effort it took to develop and deploy dub, I am sorry to say that it falls far short of my expectations and I can't see myself using it in any meaningful sense in the foreseeable future. Using it as a dependency puller for vibe.d is about as far as I will go, unfortunately. Many of dub's limitations, AFAICT, are inherent to its design and architecture, so I don't see any easy way to fix these problems either, short of rewriting it from scratch (and I have no inclination to take on something that big at this time). Atila Neves has also created his own D-based build system that reportedly is much superior to dub. You might want to look into that as well. T -- INTEL = Only half of "intelligence".
Nov 08 2018
next sibling parent reply bachmeier <no spam.net> writes:
On Friday, 9 November 2018 at 00:18:28 UTC, H. S. Teoh wrote:
 It's not true that you're stuck with dub.  And I'm not among 
 the people who think dub is the way to go (though it's true 
 that that's a minority opinion around here).  Where I have a 
 choice, my own D projects do not use dub.

 I have one project that uses dub because it's based on vibe.d, 
 but I mostly avoid needing to use dub by creating an empty dub 
 project in a subdirectory whose sole purpose is to declare a 
 dependency on vibe.d. Then I build that once with dub, and 
 outside in my real project I just link directly to the produced 
 artifacts. (The exact path(s) to the dub products can be 
 extracted from the output of `dub -v`. This can probably be 
 automated and translated into your build system of choice, 
 though I haven't quite gone that far yet.)  Then I don't need 
 to use dub except when upgrading the dub-dependent library.
This is still a build system though. It might have advantages over Dub, but I think the OP wants to avoid build systems altogether. Someone coming from a scripting language wants to add import foo; to their program and not think about package foo further. There's no obvious reason it can't be done that way in D, but the C/C++ foundation of this community leads to a mindset that it's wrong, because you need to be able to set all kinds of configuration options, guarantee reproducible builds, etc. All of which are of no importance to someone using D as a scripting language.
Nov 08 2018
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Friday, 9 November 2018 at 01:18:51 UTC, bachmeier wrote:
 There's no obvious reason it can't be done that way in D
It is trivial, really. Just download the files to your import path and `dmd -i`. Only hard part is the modules need to be arranged such that dmd -i will find it... and the dub package layout isn't compatible with it... lol. But my libs are :P We could probably write a downloader that reads module declarations and arranges them in an installed libs folder. Very simplified "install library" thing whose initial setup could set the dmd conf stuff so it just works (or wraps dmd slightly to add -I and -i to build it)...
Nov 09 2018
next sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Fri, Nov 09, 2018 at 05:38:18PM +0000, Adam D. Ruppe via Digitalmars-d-learn
wrote:
 On Friday, 9 November 2018 at 01:18:51 UTC, bachmeier wrote:
 There's no obvious reason it can't be done that way in D
It is trivial, really. Just download the files to your import path and `dmd -i`. Only hard part is the modules need to be arranged such that dmd -i will find it... and the dub package layout isn't compatible with it... lol. But my libs are :P We could probably write a downloader that reads module declarations and arranges them in an installed libs folder. Very simplified "install library" thing whose initial setup could set the dmd conf stuff so it just works (or wraps dmd slightly to add -I and -i to build it)...
Do it! That would be a welcome convenience for importing 3rd party code where the full machinery of dub isn't necessary. T -- If creativity is stifled by rigid discipline, then it is not true creativity.
Nov 09 2018
prev sibling parent bachmeier <no spam.net> writes:
On Friday, 9 November 2018 at 17:38:18 UTC, Adam D. Ruppe wrote:

 But my libs are :P
I'm aware. That's why I use your libraries but Dub not so much.
Nov 11 2018
prev sibling parent Gary Willoughby <dev nomad.uk.net> writes:
On Friday, 9 November 2018 at 00:18:28 UTC, H. S. Teoh wrote:
 It's not true that you're stuck with dub.  And I'm not among 
 the people who think dub is the way to go (though it's true 
 that that's a minority opinion around here).  Where I have a 
 choice, my own D projects do not use dub.
Me neither, I think it's a lot of work for little benefit and doesn't seem all that easy to use either. I rather use rdmd using -I flags.
Nov 09 2018
prev sibling parent reply aberba <karabutaworld gmail.com> writes:
On Thursday, 8 November 2018 at 23:51:39 UTC, bachmeier wrote:
 On Thursday, 8 November 2018 at 23:43:38 UTC, Murilo wrote:

 It finally worked, but I can't just compile it normally, I 
 have to use dub run, I wish it were something simple that I 
 just download into the folder and then use an import statement 
 and then compile it like any other program. I wish it were as 
 simple as using std.stdio for example.
Unfortunately your stuck with Dub if you want to use D. It's an awful experience compared to Python and other scripting languages, so I understand what you're saying, but most people around here think Dub is the way to go.
Stop bashing dub. Its completely fine for me. I don't get what OP mean by "simple" but: dub init add package name dub run ... doesn't look "not simple" to me.
Nov 10 2018
parent greatsam4sure <greatsam4sure gmail.com> writes:
On Saturday, 10 November 2018 at 20:04:21 UTC, aberba wrote:
 On Thursday, 8 November 2018 at 23:51:39 UTC, bachmeier wrote:
 On Thursday, 8 November 2018 at 23:43:38 UTC, Murilo wrote:

 It finally worked, but I can't just compile it normally, I 
 have to use dub run, I wish it were something simple that I 
 just download into the folder and then use an import 
 statement and then compile it like any other program. I wish 
 it were as simple as using std.stdio for example.
Unfortunately your stuck with Dub if you want to use D. It's an awful experience compared to Python and other scripting languages, so I understand what you're saying, but most people around here think Dub is the way to go.
Stop bashing dub. Its completely fine for me. I don't get what OP mean by "simple" but: dub init add package name dub run ... doesn't look "not simple" to me.
It will pay some of us if you explain more on how to us dub. To me dub is too difficult to us and is not user friendly. It is not every body who is interested in Dlang is in a country with strong internet connection. A tutorial on how to use dub will really help. I don't need a link as i have gone through them but did not help me. How i wish dlang tools will be as simple and user friendly as the language itself.
Nov 10 2018
prev sibling next sibling parent Steven Schveighoffer <schveiguy gmail.com> writes:
On 11/8/18 6:43 PM, Murilo wrote:
 On Thursday, 8 November 2018 at 23:28:05 UTC, Steven Schveighoffer wrote:
 On 11/8/18 6:07 PM, Steven Schveighoffer wrote:

 If you want to build the dlangui library directly and install it on 
 your own without dub, you would need to download the source (probably 
 from github) and build it using dub.
When I said without using dub, I meant without using dub to build your project. You still need to use dub to build the library.
It finally worked, but I can't just compile it normally, I have to use dub run, I wish it were something simple that I just download into the folder and then use an import statement and then compile it like any other program. I wish it were as simple as using std.stdio for example.
It's actually not a bad idea to be able to "install" libraries like you have your compiler installed. It could be done with the infrastructure that's there already. Would be cool for playing around with toy projects without having to initialize a dub project. There is the ability to include the dub file in the source file itself, but that may be too complex for your taste. For most people who want to have their projects depend on others, there is the need to specify the projects, how they should be built, and what versions, etc. Which is why dub is used to build most things. -Steve
Nov 08 2018
prev sibling parent Dennis <dkorpel gmail.com> writes:
On Thursday, 8 November 2018 at 23:43:38 UTC, Murilo wrote:
 It finally worked, but I can't just compile it normally, I have 
 to use dub run, I wish it were something simple that I just 
 download into the folder and then use an import statement and 
 then compile it like any other program. I wish it were as 
 simple as using std.stdio for example.
Whenever you import a module from a folder somewhere else than your project, you need to pass the location to the compiler with the -I flag. The reason std.stdio works from everywhere is because if you go to <D-installation-folder>/windows/bin/sc.ini (assuming you use Windows and dmd), you will find: [Environment] DFLAGS="-I% P%\..\..\src\phobos" "-I% P%\..\..\src\druntime\import" This will add the -I flag with the phobos location by default. If you run: dub --verbose --force You will see how dub invokes the compiler. If you look at the compiler flags, you will likely find something like this: -I..\..\..\AppData\Roaming\dub\packages\<package name>\source What you could do is locate the package, move it to a folder of your choice, and add an import to that location to your sc.ini. The Gtkd UI-framework actually prescribes such a global install: https://github.com/gtkd-developers/GtkD/wiki/Installing-on-Windows I don't know how comfortable you are doing this, it may be easier to just use dub like it's intended. This could actually be a neat feature of dub: a global install of a dependency.
Nov 08 2018
prev sibling parent reply Murilo <murilomiranda92 hotmail.com> writes:
Hi guys, thank you for helping me out here, there is this 
facebook group for the D language, here we can help and teach 
each other. It is called Programming in D. Please join. 
https://www.facebook.com/groups/662119670846705/?ref=bookmarks
Dec 09 2018
parent reply Seb <seb wilzba.ch> writes:
On Monday, 10 December 2018 at 00:18:52 UTC, Murilo wrote:
 Hi guys, thank you for helping me out here, there is this 
 facebook group for the D language, here we can help and teach 
 each other. It is called Programming in D. Please join. 
 https://www.facebook.com/groups/662119670846705/?ref=bookmarks
Please stop this spam.
Dec 10 2018
parent Murilo <murilomiranda92 hotmail.com> writes:
On Tuesday, 11 December 2018 at 07:25:49 UTC, Seb wrote:
 On Monday, 10 December 2018 at 00:18:52 UTC, Murilo wrote:
 Hi guys, thank you for helping me out here, there is this 
 facebook group for the D language, here we can help and teach 
 each other. It is called Programming in D. Please join. 
 https://www.facebook.com/groups/662119670846705/?ref=bookmarks
Please stop this spam.
It is not spam, I really created this group, it has 80 members now, I would like more members so we could help each other there rather than here, facebook is a better communication tool than this mailing list. But since you asked me to stop then I will stop.
Dec 11 2018