rdmd and D equivalent for PYTHONPATH?

Tobias Pankrath tobias+dlang at pankrath.net
Wed Mar 17 20:24:19 UTC 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 :/



More information about the Digitalmars-d-learn mailing list