Beginner question: precompiling local modules

I am still pretty new to Julia, so I do not know if this question is cogent. My workflow generally looks like making a bunch of smaller functions packaged into bundles. In Julia, the way to do this at first seems to be the module system, but it looks like you can’t precompile modules. Failing that, I’d make a bunch of local personal packages, but that only seems to be possible if they’re a git project, which I don’t necessarily want. Is there a way to do what I’m thinking of, or is this just not how Julia wants you to work?

A local dev package does not need to be managed by git. As long as you have something structured like a package (having the Project.toml file with the necessary metadata and the src folder), you can go to your pkg prompt and type dev PATH_TO_FOLDER.

(testpkg) pkg> generate MyPackage # create an empty package with the necessary structure

(testpkg) pkg> add ./MyPackage/ # this indeed does not work for the reason you mentioned
ERROR: Did not find a git repository at `MyPackage/`, perhaps you meant `Pkg.develop`?

(testpkg) pkg> dev ./MyPackage/ # works fine
   Resolving package versions...
    Updating `/tmp/testpkg/Project.toml`
  [d6775135] + MyPackage v0.1.0 `MyPackage`
    Updating `/tmp/testpkg/Manifest.toml`
  [d6775135] + MyPackage v0.1.0 `MyPackage`

julia> using MyPackage # seems to precompile
[ Info: Precompiling MyPackage [d6775135-1b9a-4058-9fc1-6e67b52696a1]

julia> MyPackage.greet()
Hello World!

You are right that the version management seems closely intertwined with git. I am curious what other options there are.

Just out of curiosity, why do you prefer to avoid git? Is it because you prefer another version control system or because you prefer to avoid version control systems altogether?

1 Like

Thank you so much for this answer! I don’t prefer another version control system, but sometimes I am working on small personal projects which don’t need an entire version control system. Maybe that’s a little bit silly, I do not know.

1 Like