Structure for a small project?


#1

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.


#2

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.


#3

There is a package called PkgDev, but it is still under development. In v0.6 time, it will generate you the following

Example
├── LICENSE.md
├── .gitignore
├── .travis.yml
├── README.md
├── REQUIRE
├── appveyor.yml
├── src
│   └── Example.jl
└── test
    └── runtests.jl

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


#4

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.)