Creating Package Problem with dependencies

I am trying to write my code to be in packages, and am having some problems. I have used PkgTemplates to create the package. There seem to be a number of problems that may be related.

Which command writes the package name in ~.julia\environments\v1.6\Project.toml? This does not seem to be working.

The [deps] section of the Package (~.julia\dev\SignalProcessing) Project.toml file does not update automatically. I put the following in manually.

[deps]
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

When starting a fresh Julia session and trying to use the template, I get:

julia> using SignalProcessing
[ Info: Precompiling SignalProcessing [be4cc790-dfbe-46ff-92ed-31160d9fa9b4]
┌ Warning: Package SignalProcessing does not have Statistics in its dependencies:
│ - If you have SignalProcessing checked out for development and have
│   added Statistics as a dependency but haven't updated your primary
│   environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with SignalProcessing
└ Loading Statistics into SignalProcessing from project dependency, future warnings for SignalProcessing are suppressed.

julia> 

I did review the package section in “Hands On Desigh Patterns and Best Prctices in Julia” and the blog by Chris.

With the environment v1.6 activated, issue
pkg> dev "~/.julia/dev/SignalProcessing"
This adds an entry for that package.

As a general note, it is best to keep the v1.6 environment “clean.” Anything you add there will be visible everywhere.

To add dependencies to SignalProcessing, activate that environment
pkg> activate "~/.julia/dev/SignalProcessing"
and
pkg> add Statistics

1 Like

Issuing the command gives me the following

(@v1.6) pkg> dev "~/.julia/dev/SignalProcessing"
ERROR: Unable to parse `~/.julia/dev/SignalProcessing` as a package.

and sorry if this should be obvious, but what do the commands
pkg> activate "~/.julia/dev/SignalProcessing"
and
pkg> add Statistics
actually do? Do they update the Project.toml file or something else?

I have added the using commands at the top of the SignalProcessing.jl file as shown below, so presumably these commands do something different.

module SignalProcessing

using FFTW, DSP
import Statistics: mean
include("SignalIntegrate.jl")
include("window.jl")
include("impactvalue.jl")

using Reexport
@reexport using .SignalIntegrate, .Impact, .Windows

end

The julia Pkg always act over an activated julia environment. The activate command tells Pkg which environment to use. By default when a new julia section is started (by using just a julia command in a terminal for instance) the activated environment is the global one according to the julia version (In your case v1.6)

Yes, it will add the given package to the current activated environment. Here, adding means to include the package information into the Project.toml and Manifest.toml of the that environment

Well, using/import commands are for loading code, and its actions do not have any effect on the environment state. But, it have common concepts with the previous subject. The code loading system use the information stored in the Project.toml and Manifest.toml files, of the activated environment, to know what packages to load and which versions.

Packages and environments tend to be confusing at first (if you come from a language that does not have them). There really is now way around reading the docs.

As it so happens, I am teaching this stuff right now (talk about the one-eyed leading the blind!). So the material at

https://lhendricks.org/econ890/julia/outline.html

and

may be helpful.

1 Like