Using Printf


#1

I am trying to make a package work on 0.6 and 0.7.

A warning told me to add “using Printf”
Another warning told me to add this to the dependancies, but I don’t know how.
I just added Printf as dependency, but a) this doesn’t exist on 0.6 and b) I get the following message:

(v0.7) pkg> resolve
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
ERROR: The following package names could not be resolved:
 * Printf (de0858da-6303-5e67-8744-51eddeeeb8d7 in manifest but not in project)
Please specify by known `name=uuid`.

Any idea?


#2

If you have a REQUIRE-style package you should not add Printf to dependencies, just add using Printf to your code.
When you have a Project.toml style package you need to have Printf in [deps].


#3

So I should just ignore the following warning?

(v0.7) pkg> precompile
Precompiling project...
Precompiling ModiaMath
[ Info: Recompiling stale cache file /home/ufechner/.julia/compiled/v0.7/ModiaMath/QuMbN.ji for ModiaMath [052f3798-2c4b-580c-9af4-6e8cb4bca120]
┌ Warning: Package ModiaMath does not have Printf in its dependencies:
│ - If you have ModiaMath checked out for development and have
│   added Printf 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 ModiaMath
└ Loading Printf into ModiaMath from project dependency, future warnings for ModiaMath are suppressed.


#4

Ok, I am using now:

@static if VERSION >= v"0.7.0-DEV.2005" @eval using Printf end

Now I don’t get any warning any more. Is this a good solution?


#5

using Compat.Printf


#6

So that also works with 0.6?
And do I have to add Compat to the REQUIRES file?


#7

Yes, yes.


#8

Thanks! :slight_smile: