Hi, all. I have several .jl files. I want to pack them into a local module and install it into my environment via pkg. How can I make it?
There are some instructions on how to create a package in this documentation: 5. Creating Packages · Pkg.jl
For the more basic structure of a module
that is the base of a package, you can read the Julia documentation: Modules · The Julia Language
Start with creating a project:
julia -e "using Pkg; Pkg.generate("My_Project)")"
cd My_Project
julia
This will create a small directory tree, including a Project.toml in the first level, which is what keep tracks of dependencies. In the src
directory will be My_Project.jl
as a Hello, World.
Edit this to bring in your .jl
files, which should all be functions
using Pkg
Pkg.activate(@__DIR__)
Pkg.add("DataFrames")
using My_Project
check_julia_version()
add_dependencies()
display_readme()
Edit My_Project.jl
include("src/utils.jl")
# etc
utils.jl
and each other should end with
export with_commas, with_percent # etc
Stay flat and bring everything into My_Project
and avoid using macros in function definitions; reserve them for scripts. Otherwise, you will fall into circular dependency hell.