Multiple modules in single package

question

#1

I found that a rather short function I use in the unit tests of a package would be useful somewhere else. If I don’t want to make a separate package for it, is it possible to put it in a separate module in the same package?

Simply putting it in src/MiniModule.jl in the same package does not make using MiniModule find it it.


#2

It would need to be a submodule, I think. To get it using MyPkg.MiniModule ain’t so bad.


#3

That’s unfortunate: MiniModule is not really related to MyPkg, other than being useful in its unit tests.

It seems that, there is an implicit 1:1 mapping between modules and packages for many things.


#5

How would you want it to be accessible? As soon as you think about that, it sounds like a julia package.

Packages con be small and minimal. What is the exact issue you are worried about?


#6

Making a package for <10 LOC. But I see your point.


#7

You can also do push!(LOAD_PATH, @__DIR__) in src/Module.jl to make MiniModule findable. Then users can do using Module; using MiniModule


#8

At least if registered it does put additional burden on METADATA maintainers (and on Tamas too).


#9

There was some discussion on this topic here: https://github.com/JuliaLang/Juleps/issues/8

I’m really hoping to see this feature before 1.0; I don’t think having to use a separate git repository for every chunk of code that forms a standalone module is really scalable for huge projects.