Create packages¶
For languages such as R, Python, and Julia, it is generally a good idea to write your code as a package/library. This can make it easier to install and run your code on a new computer, on a high-performance computing platform, and for others to use on their own computers.
Info
This is a simple process and entirely separate from publishing your package or making it publicly available.
It also means you can avoid using source()
in R, or adding directories to sys.path
in Python.
To create a package you need to provide some necessary information, such as a package name, and the list of the packages that your code depends on ("dependencies"). You can then use packaging tools to verify that you've correctly identified these dependencies and that your package can be successfully installed and used!
This is an important step towards ensuring your work is reproducible.
There are some great online resources that can help you get started. We list here some widely-recommended resources for specific languages.
Writing R packages¶
For R, see R Packages (2nd ed) and the devtools package.
Other useful references include:
- rOpenSci Packages: Development, Maintenance, and Peer Review;
- Writing an R package from scratch by Hilary Parker;
- How to develop good R packages by Maƫlle Salmon;
- Making your first R package by Fong Chun Chan; and
- Writing an R package from scratch by Tomas Westlake.
Info
rOpenSci offers peer review of statistical software.
Writing Python packages¶
The Python Packaging User Guide provides a tutorial on Packaging Python Projects.
Other useful references include:
-
The pyOpenSci project also provide a Python Packaging Guide. This includes information about code style, formatting, and linters.
-
This example Python project demonstrates one way of structuring a Python project as a package.
Info
pyOpenSci offers peer review of scientific software
Writing Julia Packages¶
The Julia's package manager documentation provides a guide to Creating Packages