l3build
l3build copied to clipboard
Inbuilt way to load a maintainer-only build file
In my own build.lua
files I've taken to including the following lines:
local function tryrequire(m) -- from: https://stackoverflow.com/a/17878208
local ok, err = pcall(require, m)
if not ok then return nil, err end
return err
end
tryrequire("l3build-wspr.lua")
where l3build-wspr.lua
is a "secret" file in my texmf tree, not included in any package, that includes
uploadconfig = uploadconfig or {}
uploadconfig.uploader = "..."
uploadconfig.email = "..."
as well as some other personal customisations (e.g., moving the build dir away from the git repo).
I think this "personal config" idea would be good to support out of the box — wdyt? If so, I'd suggest we add tryrequire()
or similar to l3build itself.
I'm not really sure about this: as you want to build reliably on different machines, either a config file is available or it's not ... particularly for CTAN upload, if it's not about then isn't that just a hard error?
it has a potential to be abused to make system-specific test outputs, but for the particular example in the initial comment I think this could be useful, you often want to be able to clone and build and run tests eg to make a PR without having ctan upload rights so having a standard way to hide the upload details from git while still allowing cloned repositories to run l3build without error and without having to manualy generate a stub local config file might be good.
Isn't that about an interface to personal data which shouldn't be in the public git? I have a similar setting e.g. in tagpdf to load the upload info for ctan:
local ok, mydata = pcall(require, "ulrikefischerdata.lua")
if not ok then
mydata= {email="XXX",github="XXX",name="XXX"}
end
The file itself is then only on my computer(s).
OK., so something like try_local_config()
?
Why not offer something as a switch on the call, e.g., l3build --build specialbuild.lua
or -b
?
That would cover several use cases I think.
- you might want more than one kind of build file and distribute it
- you might want a private build file (in which case you just need to git ignore it (or whatever VC system you use)
that would be a bit more flexible than always loading a file if it is locally there, but of course the downside is that it needs specifying on the call.
If we go for the try_local_...
then I think it should be somehting other than "config" because that has already a different meaning in l3build. Maybe _build
or _file
I forgot I put this into the issue tracker. Looking at the date I'm not surprised I forgot.
On @FrankMittelbach's comment, I take it you mean that you could have multiple --build
options and just load them in order. I prefer not to have to set flags on the command line as when I come back after 2 yrs to do a release I will never remember what to type :) Even if there's a command line flag as well I'd prefer an equivalent method that could be used in the lua code itself.
Personally I think there's something pretty simple and neat about tryrequire
or similar. It does nothing besides require()
except silently bail out if the file is not there. No need to complicate the naming when it is so simple.
You could also argue it's too simple to bother adding — but having it inbuilt would mean it would be a bit easier to document setting up things in this way as the standard way of distributing "safe" build scripts.
yeah I guess you are right it is most certainly safer (against old age syndrom :-) and covers most likely everything that is needed in practice most of the time.
Could we just have some fixed name for a local config file? l3build-config.lua
which is read if it exists?
why not? would also make a fairly simple to use interface.
That’s probably the best solution — no extra complication to any interfaces and a sensible default.
except that I would suggest to name it l3build-local-config.lua
and in the documentation explicitly mention that one should make sure that it is not ending up in a public repository via .gitignore
or the like if it contains private data (that may be obvious but ... I don't think it hurts to explicitly remind people)
Or maybe it should be a . file, eg .l3build-local-config.lua