PPTX.jl icon indicating copy to clipboard operation
PPTX.jl copied to clipboard

trying to use artifacts

Open ig-or opened this issue 9 months ago • 11 comments

A few very simple changes are proposed, the purpose is to be able to use a PackageCompiler.jl / make pptx file from inside the Julia app on Windows. It also addresses https://github.com/ASML-Labs/PPTX.jl/issues/15 at some point. In short, all the templates are part of the artifact now. The exact location of the artifact is an open question, though.. https://julialang.slack.com/archives/C67EFTEF3/p1715193409165059

ig-or avatar May 08 '24 20:05 ig-or

Thanks for this contribution!

I think you forgot to add using Artifacts in src/PPTX.jl, which is causing the currently failing build pipelines.

May I also ask how you uploaded the artifact to github?

matthijscox-asml avatar May 09 '24 11:05 matthijscox-asml

Because ZipReader works on Vector{UInt8} you could also bake in the data from the default template instead of using artifacts.

include_dependency(joinpath(TEMPLATE_DIR, "no-slides.pptx"))
include_dependency(joinpath(TEMPLATE_DIR, "tableStyles.xml"))
const default_template_data = read(joinpath(TEMPLATE_DIR, "no-slides.pptx"))
const default_table_style_data = read(joinpath(TEMPLATE_DIR, "tableStyles.xml"))

This way reading the template files would happen during precompile.

nhz2 avatar May 09 '24 18:05 nhz2

@nhz2 , this might be possible but I'm not sure how this will work with package compiler. When I tried PPTX as a part of the compiled app, TEMPLATE_DIR was pointing on the folder were the PPTX "was compiled". IMHO package compiler is not very good with "assets" but it's OK with artifacts.

ig-or avatar May 09 '24 19:05 ig-or

@matthijscox-asml , about "how you uploaded the artifact to github?" As I was told in Julia Slack channel, I made a fake package release (on my Github account) and added the artifact file as an assert to this release. You probably would like to change the artifact file location.

ig-or avatar May 09 '24 19:05 ig-or

This should work with package compiler because the reading from the path won't happen at run time. Though you will also need to edit https://github.com/ASML-Labs/PPTX.jl/blob/64435fe29a9e50c366be5f8067f8e6b4199a8f30/src/write.jl#L144 and https://github.com/ASML-Labs/PPTX.jl/blob/64435fe29a9e50c366be5f8067f8e6b4199a8f30/src/write.jl#L70 to accept Vector{UInt8}

nhz2 avatar May 09 '24 19:05 nhz2

@nhz2 thanks for the explanation!

ig-or avatar May 09 '24 19:05 ig-or

This should work with package compiler because the reading from the path won't happen at run time.

But as I understand it, when you define the path at compile time, the compiled library won't be relocatable anymore, right?

matthijscox-asml avatar May 13 '24 08:05 matthijscox-asml

Yes, a package isn't relocatable if it uses a string path at runtime that was defined at compile time. One solution is to use https://github.com/JuliaPackaging/RelocatableFolders.jl or Artifacts to allow the path to change to point to the correct folder. The other option is to not read the template files at runtime.

nhz2 avatar May 13 '24 13:05 nhz2

Can somebody have a look at the conflicts?

ig-or avatar May 13 '24 20:05 ig-or

Can somebody have a look at the conflicts? @ig-or you can just take the new changes, @nhz2 made a small update where he already included one template file during compilation

matthijscox-asml avatar May 15 '24 06:05 matthijscox-asml

Sorry for the delay. Lets see how it goes now..

ig-or avatar May 22 '24 18:05 ig-or