Is there advice for structuring a small project? I see that Pkg generate creates a src/ directory, and other things suggest a test/ directory. Is this all written up somewhere?
So far, I’ve made a projects that have a handful of files with various functions, which may include(“func_file.jl”) as needed. They have a few scripts that actually run the show, and drive the computation. Maybe another one that generates the necessary images.
I’m excited about the Pkg environments, but I wasn’t sure if there was some best practice I should be following.
I’d read through the Pkg section of the documentation. I’m still learning to use it but the utility in using it for a personal project is similar to that of creating a package in R or using pipenv in python to maintain a consistent versioned environment.
src is for your main functionality definitions, it contains a module of the project name.
The LICENSE is your package license, which can be MIT/Apache 2.0/etc.
The REQUIRE is similar to the Project.toml now, you can just use Project.toml instead
you should have runtest.jl to let Julia test your code. And appveyor.yml is for windows CI (continuous integration) which will run your tests in test dir on windows. .travis.yml is for travis CI which run tests on OS X and Linux system
.gitignore is what you will need to make your repo clean, make sure those files won’t be upload to your repo.
Finally you will probably want to write a README.md to help people understand what you are doing.
And you might need a example folder to run your examples (like tests).
Minimum requirement is just a Project.toml and a src, if you don’t want to write any tests and set up CI.
just pick up what you need according to their functionality above
A lot of the above advice is for packages. But from the OP’s description of their project, I think a slightly different structure is in order. For instance, the “scripts” should probably go in a bin directory. I also like to set JULIA_LOAD_PATH to be $PWD/src: (I do this using direnv), which allows me to have module files in my src directory. (Alternatively, this directory could be called modules – in any case, it would be nice to have a standard name for it.)
Thanks, yeah, I wonder how much differs between a small project and a package for release.
I like the idea of having a bin directory. I might start moving the scripts that actually do the work into there, and keep the functions in src. Someday, I’ll write some tests.
The other useful hack I came up with was
file_dir = dirname(@__FILE__)
cd("$file_dir/..")
using Pkg
Pkg.activate(".")
so that when I ctrl-enter in Juno, it puts me locally. I suppose I could make a macro for that instead of copying across projects files?