JuliaBesties / BestieTemplate.jl

Template for Julia Programming Language packages using the copier engine.
http://JuliaBesties.github.io/BestieTemplate.jl/
Mozilla Public License 2.0
43 stars 9 forks source link

how to use `dev`:ed version of BestieTemplate.jl? #434

Open lucaferranti opened 1 month ago

lucaferranti commented 1 month ago

Description

This is probably be missing something trivial, anyway

  1. I did ]dev BestieTemplate
  2. I did some changes in the questions under copier folder
  3. On a fresh Julia session, after using BestieTemplate; BestieTemplate.generate("Something.jl") it was still using the old version of the question, instead of my modified version. I also tried to manually force precompilation with Base.compilecache(Base.identify_package("BestieTemplate")) but it did not seem to help.

So my question is, after I ]dev BestieTemplate what is the recommended workflow to test changes I do in the yaml files and use the dev'ed version of the package?

lucaferranti commented 1 month ago

without knowing any better about copier internals, I see a method

function generate(dst_path, data::Dict = Dict(); kwargs...)
  generate("https://github.com/abelsiqueira/BestieTemplate.jl", dst_path, data; kwargs...)
end

which hardcodes the source. I also noticed that despite I deved the package, it seems it is nevertheless using the latest release, because e.g. it has default indentation of 2.

Maybe copier uses the latest release from the repo by default?

abelsiqueira commented 1 month ago

There is another generate (being called by that one) that accepts the source path as argument. You can give the local path. I also set up some dev debug tools: https://abelsiqueira.com/BestieTemplate.jl/dev/91-developer/#Testing-local-changes-to-the-template

abelsiqueira commented 1 month ago

Answering the other questions:

lucaferranti commented 1 month ago

how can I get the interactive questionnaire to work in debug mode?

I did a simple dummy change

diff --git a/copier/essential.yml b/copier/essential.yml
index 3be1880..021984d 100644
--- a/copier/essential.yml
+++ b/copier/essential.yml
@@ -37,7 +37,7 @@ JuliaMinVersion:

 License:
   type: str
-  help: Package license (You need an OSI license to register. You can suggest new licenses in the issues)
+  help: Package license  lalallalallal (You need an OSI license to register. You can suggest new licenses in the issues)
   choices:
     - Apache-2.0
     - GPL-3.0

then with the package deved I did the following

julia> using BestieTemplate;
    CondaPkg Found dependencies: /home/lferrant/.julia/environments/v1.10/CondaPkg.toml
    CondaPkg Found dependencies: /home/lferrant/.julia/packages/PythonCall/flx5V/CondaPkg.toml
    CondaPkg Found dependencies: /home/lferrant/.julia/dev/BestieTemplate/CondaPkg.toml
    CondaPkg Dependencies already up to date
    CondaPkg Found dependencies: /home/lferrant/.julia/environments/v1.10/CondaPkg.toml
    CondaPkg Found dependencies: /home/lferrant/.julia/packages/PythonCall/flx5V/CondaPkg.toml
    CondaPkg Found dependencies: /home/lferrant/.julia/dev/BestieTemplate/CondaPkg.toml
    CondaPkg Dependencies already up to date

julia> Dbg = BestieTemplate.Debug;

julia> Dbg.dbg_generate(data_choice=:ask)
/home/lferrant/.julia/environments/v1.10/.CondaPkg/env/lib/python3.11/site-packages/copier/vcs.py:201: DirtyLocalWarning: Dirty template changes included automatically.
  warn(

It did create a library PkgDebugBestie1 but it did not ask me anything interactively. It also prints a wanring about dirty template, which I'm not sure what it refers to. Note I did not cut the stacktrace at warn( that's everything that was printed.

lucaferranti commented 1 month ago

Also, not sure if it's a bug or me misusing the command, but it seems that data_choice=:none throws atm

julia> Dbg.dbg_generate(data_choice=:none)
ERROR: Python: ValueError: Question "PackageOwner" is required
Python stacktrace:
 [1] _ask
   @ copier.main ~/.julia/environments/v1.10/.CondaPkg/env/lib/python3.11/site-packages/copier/main.py:502
 [2] run_copy
   @ copier.main ~/.julia/environments/v1.10/.CondaPkg/env/lib/python3.11/site-packages/copier/main.py:817
 [3] run_copy
   @ copier.main ~/.julia/environments/v1.10/.CondaPkg/env/lib/python3.11/site-packages/copier/main.py:1146
 [4] __exit__
   @ copier.main ~/.julia/environments/v1.10/.CondaPkg/env/lib/python3.11/site-packages/copier/main.py:228
 [5] run_copy
   @ copier.main ~/.julia/environments/v1.10/.CondaPkg/env/lib/python3.11/site-packages/copier/main.py:1145
Stacktrace:
  [1] pythrow()
    @ PythonCall.Core ~/.julia/packages/PythonCall/flx5V/src/Core/err.jl:92
  [2] errcheck
    @ ~/.julia/packages/PythonCall/flx5V/src/Core/err.jl:10 [inlined]
  [3] pycallargs(f::PythonCall.Core.Py, args::PythonCall.Core.Py, kwargs::PythonCall.Core.Py)
    @ PythonCall.Core ~/.julia/packages/PythonCall/flx5V/src/Core/builtins.jl:222
  [4] pycall(::PythonCall.Core.Py, ::String, ::Vararg{Any}; kwargs::@Kwargs{defaults::Bool, quiet::Bool, vcs_ref::String})
    @ PythonCall.Core ~/.julia/packages/PythonCall/flx5V/src/Core/builtins.jl:237
  [5] pycall
    @ ~/.julia/packages/PythonCall/flx5V/src/Core/builtins.jl:233 [inlined]
  [6] Py
    @ ~/.julia/packages/PythonCall/flx5V/src/Core/Py.jl:357 [inlined]
  [7] copy(src_path::String, dst_path::String, data::Dict{…}; kwargs::@Kwargs{…})
    @ BestieTemplate.Copier ~/.julia/dev/BestieTemplate/src/Copier.jl:30
  [8] copy
    @ ~/.julia/dev/BestieTemplate/src/Copier.jl:28 [inlined]
  [9] _copy(src_path::String, dst_path::String, data::Dict{…}; kwargs::@Kwargs{…})
    @ BestieTemplate ~/.julia/dev/BestieTemplate/src/api.jl:40
 [10] _copy
    @ ~/.julia/dev/BestieTemplate/src/api.jl:6 [inlined]
 [11] generate(src_path::String, dst_path::String, data::Dict{…}; kwargs::@Kwargs{…})
    @ BestieTemplate ~/.julia/dev/BestieTemplate/src/api.jl:82
 [12] generate
    @ ~/.julia/dev/BestieTemplate/src/api.jl:75 [inlined]
 [13] dbg_generate(dst_path::String, _data::Dict{Any, Any}; data_choice::Symbol, kwargs::@Kwargs{})
    @ BestieTemplate.Debug ~/.julia/dev/BestieTemplate/src/debug/helper.jl:73
 [14] dbg_generate
    @ ~/.julia/dev/BestieTemplate/src/debug/helper.jl:66 [inlined]
 [15] top-level scope
    @ REPL[4]:1
 [16] top-level scope
    @ none:1
abelsiqueira commented 1 month ago

The dbg_ functions use defaults=true, which don't ask questions, which breaks with :none. The following works:

BestieTemplate.Debug.dbg_generate(data_choice=:none, defaults=false)
BestieTemplate.Debug.dbg_generate(defaults=false) # might be enough

I'm not committed to anything in the Debug section, so feel free to make suggestions.

abelsiqueira commented 1 month ago

The dirty warning comes from copier. It's dirty in the git sense.