digitalmars.D.learn - rdmd and D equivalent for PYTHONPATH?
- Chris Piker (26/26) Mar 16 2021 Hi D
- Chris Piker (15/19) Mar 16 2021 Sorry to reply to myself, but I found something that will run
- user1234 (9/25) Mar 16 2021 You can use local a specific local version too, for example the
- Chris Piker (23/31) Mar 17 2021 Very handy example. Unfortunately it means that paths are
- user1234 (4/10) Mar 17 2021 You can use a local registry too. That should work but ten the
- Mike Parker (7/10) Mar 17 2021 The ability to use D source modules “script style” is something
- Chris Piker (20/30) Mar 17 2021 Sure will, thanks for the invite to contribute in a specific way.
- Imperatorn (3/8) Mar 17 2021 You probably already know this, just sharing:
- Chris Piker (6/16) Mar 17 2021 Hey, that looks nice. I'm trying to get away from python as the
- Tobias Pankrath (18/25) Mar 17 2021 For scripts this could be a good way, but it does not really work
- Chris Piker (24/36) Mar 17 2021 I tried that route, and it's not too bad, but I have C library
Hi D I've writing little test scripts using rdmd to understand what various functions are really doing (ex: .take(5)). I'm up to the point where I need to write sample code to understand mir-algorithm a little better, but of course the library is not installed on my system. So two related questions: 1) After a "git clone" and "dub build" I'm left with redistributables that need to be put ... somewhere. But where? I tried this: cp -r -p source/mir /usr/local/include cp -p libmir-algorithm.a /usr/local/lib but no joy. So where can I install libs so that rdmd will find them? 2) On a related topic, is there an environment variable I can set (similar to PYTHONPATH, MATLABPATH, IDL_PATH, etc.) or a config file I can alter that will add to the module include path? I tried: at the top of the file, but that just hung rdmd and nothing ran. Note: I'm aware of dub. This isn't a question about dub. I'm making scripts for local use, not redistributable binaries, so I would like to "install" mir-algorithm and similar libraries for my rdmd scripts to use. Thanks for the help,
Mar 16 2021
On Wednesday, 17 March 2021 at 03:43:22 UTC, Chris Piker wrote:Note: I'm aware of dub. This isn't a question about dub. I'm making scripts for local use, not redistributable binaries, so I would like to "install" mir-algorithm and similar libraries for my rdmd scripts to use.Sorry to reply to myself, but I found something that will run the scripts, though it still doesn't make use of local libraries. /+ dub.sdl: dependency "mir-algorithm" version="~>1.0" +/ import mir.ndslice ... Since dub seems to work a bit better as the "interpreter" then rdmd (assuming you're connected to the Internet) why is this not promoted here: https://tour.dlang.org/tour/en/welcome/run-d-program-locally instead of rdmd? Thanks,
Mar 16 2021
On Wednesday, 17 March 2021 at 04:34:07 UTC, Chris Piker wrote:On Wednesday, 17 March 2021 at 03:43:22 UTC, Chris Piker wrote:You can use local a specific local version too, for example the git repository /+ dub.sdl: dependency "mir-algorithm" path="/home/x/repositories/mir/mir-algorithm" +/ In addition with --nodeps, no internet is required.Note: I'm aware of dub. This isn't a question about dub. I'm making scripts for local use, not redistributable binaries, so I would like to "install" mir-algorithm and similar libraries for my rdmd scripts to use.Sorry to reply to myself, but I found something that will run the scripts, though it still doesn't make use of local libraries. /+ dub.sdl: dependency "mir-algorithm" version="~>1.0" +/ import mir.ndslice ... Since dub seems to work a bit better as the "interpreter" then rdmd (assuming you're connected to the Internet)
Mar 16 2021
On Wednesday, 17 March 2021 at 06:07:01 UTC, user1234 wrote:You can use local a specific local version too, for example the git repository /+ dub.sdl: dependency "mir-algorithm" path="/home/x/repositories/mir/mir-algorithm" +/ In addition with --nodeps, no internet is required.Very handy example. Unfortunately it means that paths are embedded in scripts, which is usually a bad idea. I'm still looking for environment variables or config files that affect dub's module include path. Is there dub variable to give a general path for all dependencies? Since dub can read environment variables, this may be a way to get a top-level module directory known to scripts without hard coding paths. Also, what do people do when generating .deb or .rpm packages for D libraries? They must reference some local library path in a general fashion (I would think). The only module paths I see referenced in: /etc/dmd.conf are for phobos and the runtime import. I guess I could just add another one there. Not sure if gdc also uses that file.
Mar 17 2021
On Wednesday, 17 March 2021 at 07:13:31 UTC, Chris Piker wrote:On Wednesday, 17 March 2021 at 06:07:01 UTC, user1234 wrote:You can use a local registry too. That should work but ten the dep version must be set to "*". See https://dub.pm/commandline.html#add-local[...]Very handy example. Unfortunately it means that paths are embedded in scripts, which is usually a bad idea. [...]
Mar 17 2021
On Wednesday, 17 March 2021 at 07:13:31 UTC, Chris Piker wrote:Very handy example. Unfortunately it means that paths are embedded in scripts, which is usually a bad idea.The ability to use D source modules “script style” is something that has grown organically over time largely as a convenience. I doubt anyone is using it heavily enough to have tested the boundaries, In your exploration of those boundaries, please take note of what you discover so they can potentially be expanded where possible.
Mar 17 2021
On Wednesday, 17 March 2021 at 09:34:21 UTC, Mike Parker wrote:On Wednesday, 17 March 2021 at 07:13:31 UTC, Chris Piker wrote:Sure will, thanks for the invite to contribute in a specific way. D looks to be a good replacement for split Python/C development though I don't want to drag all my python baggage in here. I'm trying to understand the D way of doing things before suggesting changes. Interpreted languages like Python MATLAB, IDL are the norm in my field. So anything that makes D easier to use for "quick-and-dirty" data analysis tasks would make it more palatable to the casual programmers I interact with. I general dub seems fantastic! I was stunned yesterday by a three-line vibe.d test script I ran that produced a compiled running web-server. So, if I could do the equivalent of: dub add-path via an environment variable (not a permanent change under ~/.dub), or have some environment variable that tells dub where to read a "system-level" local-packages.json file and merge it's paths in with any personal settings, that would likely handle our internal code sharing needs.Very handy example. Unfortunately it means that paths are embedded in scripts, which is usually a bad idea.The ability to use D source modules “script style” is something that has grown organically over time largely as a convenience. I doubt anyone is using it heavily enough to have tested the boundaries, In your exploration of those boundaries, please take note of what you discover so they can potentially be expanded where possible.
Mar 17 2021
On Wednesday, 17 March 2021 at 19:33:26 UTC, Chris Piker wrote:On Wednesday, 17 March 2021 at 09:34:21 UTC, Mike Parker wrote:You probably already know this, just sharing: https://atilaoncode.blog/2020/02/19/want-to-call-c-from-python-use-d/[...]Sure will, thanks for the invite to contribute in a specific way. [...]
Mar 17 2021
On Wednesday, 17 March 2021 at 20:13:49 UTC, Imperatorn wrote:On Wednesday, 17 March 2021 at 19:33:26 UTC, Chris Piker wrote:Hey, that looks nice. I'm trying to get away from python as the front end language, but I do have a fair bit of C code running around and there are a lot of python users. Thanks for the tip :)On Wednesday, 17 March 2021 at 09:34:21 UTC, Mike Parker wrote:You probably already know this, just sharing: https://atilaoncode.blog/2020/02/19/want-to-call-c-from-python-use-d/[...]Sure will, thanks for the invite to contribute in a specific way. [...]
Mar 17 2021
On Wednesday, 17 March 2021 at 19:33:26 UTC, Chris Piker wrote:So, if I could do the equivalent of: dub add-path via an environment variable (not a permanent change under ~/.dub), or have some environment variable that tells dub where to read a "system-level" local-packages.json file and merge it's paths in with any personal settings, that would likely handle our internal code sharing needs.For scripts this could be a good way, but it does not really work with most dub packages: 1. put all your dependencies into a single location, like /home/<you>/dstuff 2. add -I /home/<you>/dstuff to your call to rdmd/dmd (or put into /etc/dmd.conf 3. add -i (lowercase) to your call of rdmd/dmd 4. profit -i automatically adds all modules that are imported to the compilation, i.e. all your dependencies are compiled together with your code, when they are needed. It searches for them where -I points to. To make this work the dependencies must have the correct project layout, e.g. sources should be in the top-level project directory and not in a subdirectory source. This rules out most dub packages :/
Mar 17 2021
On Wednesday, 17 March 2021 at 20:24:19 UTC, Tobias Pankrath wrote:For scripts this could be a good way, but it does not really work with most dub packages: 1. put all your dependencies into a single location, like /home/<you>/dstuff 2. add -I /home/<you>/dstuff to your call to rdmd/dmd (or put into /etc/dmd.conf 3. add -i (lowercase) to your call of rdmd/dmd 4. profitI tried that route, and it's not too bad, but I have C library dependencies so I start getting shebangs that look like this: -L-ldas2.3 -L-lexpat -L-lssl -L-lfftw3 So kinda messy, though the rdmd -i option is nice. Since the dub packages have the linker info builtin, it seemed better to use this instead: and to assist with finding local packages, throw in some sort of local search path via an environment variable reference in the dub.sdl section. If everyone used the same environment variable in dub.sdl comment it could become a defacto standard for scripts, similar to PYTHONPATH or MATLABPATH, though not nearly as fundamental.To make this work the dependencies must have the correct project layout, e.g. sources should be in the top-level project directory and not in a subdirectory source. This rules out most dub packages :/Yea, this seemed strange to me. I'd think that a group would want the compiler's module lookup semantics to match the common package layout scheme and vice-versa. But since I'm new around here I'll just assume that the mismatch came about for a reason. The dub designers were probably trying to solve some problem that I'm unaware of.
Mar 17 2021