Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--web-bundle for v2 CLI: fix #1002 and allow overrides #1132

Merged
merged 4 commits into from
Feb 4, 2024

Conversation

bryango
Copy link
Contributor

@bryango bryango commented Dec 19, 2023

This PR is split off from #1131. See #1131 for relevant discussions on the web bundle interface.

  1. Fixes Provide options for V2 cli to override the default bundle_url #1002: It enables us to override the default web bundle for the v2 CLI tectonic -X new and tectonic -X init, with the usual --web-bundle flag
  2. Allows overrides: It allows user overrides of the --web-bundle by specifying it multiple times. The last specification of --web-bundle wins.
  3. tectonic -X build is special as it never reads from the global config, but only from the local Tectonic.toml file, for maximal reproducibility. In this case, the global --web-bundle option, if specified, is ignored with a warning.

For a horrible example,

tectonic \
  --web-bundle "https://this-url-gets-overridden-1" \
  -X \
  --web-bundle "https://this-url-gets-overridden-2" \
  new \
  --web-bundle "https://this-url-gets-overridden-3" \
  --web-bundle "https://this-url-is-actually-used"

Copy link

codecov bot commented Dec 19, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (c64e524) 46.28% compared to head (61eb46a) 46.34%.

Files Patch % Lines
src/bin/tectonic/main.rs 91.66% 1 Missing ⚠️
src/bin/tectonic/v2cli.rs 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1132      +/-   ##
==========================================
+ Coverage   46.28%   46.34%   +0.06%     
==========================================
  Files         171      171              
  Lines       65099    65121      +22     
==========================================
+ Hits        30129    30181      +52     
+ Misses      34970    34940      -30     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bryango
Copy link
Contributor Author

bryango commented Dec 19, 2023

Whoops, I should write tests, but I don't know how to... 😿
Update: I learned and have written extensive tests. Rust is an addictive language!

@doronbehar
Copy link

Whoops, I should write tests, but I don't know how to... 😿

You may want to do that after upstream approves the intentions of the PR.

I have a question: Is it possible to implement the following behavior:

tectonic --web-bundle <URL1> document.tex # Uses URL1
tectonic --web-bundle <URL1> --web-bundle <URL2> document.tex # Uses URL2
tectonic --web-bundle <URL1> -X build # Uses URL1
tectonic --web-bundle <URL1> -X build --web-bundle <URL2> # Uses URL2
tectonic --web-bundle <URL1> -X --web-bundle <URL2> build # Uses URL2

This way, the PR would help a lot both Nixpkgs' situation, and all other users. For Nix users, this would allow to wrap Tectonic with --add-flags (see this), and for other users it'd allow to simply add a shell alias such as:

alias tectonic='tectonic --web-bundle=<URL that matches my biber version>'

With the above described behavior to be able to override the web-bundle, a no-Nix user won't need to unalias the tectonic alias, and Nix users won't need to use the tectonic-unwrapped derivation. This is the ideal solution IMO to the issue, that is the least intrusive.

@doronbehar
Copy link

@bryango this seems to get into great shape! Considering you have added extensive tests, do you think it should be ready for inclusion in Nixpkgs? Along with an additional makeWrapper argument --add-flags?

@bryango
Copy link
Contributor Author

bryango commented Dec 22, 2023

Hi @doronbehar! Thank you very much for following along! I like your previous suggestions very much and have been trying to implement them.

do you think it should be ready for inclusion in Nixpkgs? Along with an additional makeWrapper argument --add-flags?

This is the eventual goal! I think I finally got everything working, but I am not entirely satisfied about the current resolution. The code feels a bit too hacky... I will try to improve it a bit more, and after some more testing, I think it would be good to go into nixpkgs! But it might take some time 🥺

@bryango bryango changed the title --web-bundle for v2 CLI, fixes #1002 and allows overrides --web-bundle for v2 CLI: fix #1002 and allow overrides Dec 22, 2023
@bryango bryango force-pushed the cli-web-bundle branch 4 times, most recently from 60c9aeb to 4ccac89 Compare December 23, 2023 10:04
`config.rs` is refactored such that `test-bundle://` is interpreted as
the valid web-bundle for offline testing.
In particular, we now allow `-X` to _not_ be the first cli argument.
This makes way for common options such as `--web-bundle` to be specified
_before_ the `-X` flag.
@bryango bryango force-pushed the cli-web-bundle branch 2 times, most recently from 6107941 to 21069ff Compare December 23, 2023 14:27
- Promote `--web-bundle` to a top level option, in v1 & v2 CLI.

- Allow `--web-bundle` to be specified in any position in v2 CLI.
  This makes use of `clap::Arg::global`.

- Allow user overrides of `--web-bundle` by specifying it multiple
  times, and the last specification wins over the previous ones.
  This makes use of `clap::Arg::overrides_with`.

By design, `tectonic -X build` is special as it never reads from the
global config, but only from the local `Tectonic.toml` file, to ensure
maximal reproducibility across different environments. Therefore, for
`-X build`, the global `--web-bundle` option, if specified, is ignored
with a warning `tt_note`.
@bryango bryango force-pushed the cli-web-bundle branch 2 times, most recently from e9a60e3 to 2c74050 Compare December 23, 2023 16:50
@bryango
Copy link
Contributor Author

bryango commented Jan 3, 2024

@pkgw @doronbehar @rm-dr Happy new year! I think this is the best I can do, and it's ready for review. The changes may look large and scattered, but in fact half of them are test changes. It is easy to review commit by commit: https://github.com/tectonic-typesetting/tectonic/pull/1132/commits

  • Each commit is "bite-sized" and has a clear objective stated in its message.
  • The package is buildable at every commit and passes cargo test.
  • The first few commits are refactors of the current behavior, and the latter ones add new --web-bundle options.

Going through the history, maybe @Sinofine @CraftSpider would be interested in taking a look?

@pkgw
Copy link
Collaborator

pkgw commented Feb 4, 2024

Sorry for taking to long to review this ☹️

Upon first read I wasn't a fan of the changes to allow -X later in the command line, but I am guessing that the motivation there is to make it possible to set up some kind of alias mytectonic = tectonic --web-bundle=https://...../ and Things Will Work. So, that seems reasonable.

Likewise I don't love having the -X build command accept a non-functional --web-bundle argument, but the homogeneity also helps with the above.

So I'm going to go ahead and merge this. Sorry again for the lack of responsiveness.

@pkgw pkgw merged commit 50fc7eb into tectonic-typesetting:master Feb 4, 2024
28 checks passed
@pkgw pkgw mentioned this pull request Feb 4, 2024
@bryango
Copy link
Contributor Author

bryango commented Feb 5, 2024

Thank you very much for merging this!

Upon first read I wasn't a fan of the changes to allow -X later in the command line, but I am guessing that the motivation there is to make it possible to set up some kind of alias mytectonic = tectonic --web-bundle=https://...../ and Things Will Work. So, that seems reasonable.

The current solution is indeed ugly, but once v2 CLI has fully taken over, this would hopefully look a bit better!

So I'm going to go ahead and merge this. Sorry again for the lack of responsiveness.

Please there is no need to apologize! It is already hard enough to work in academics, let alone maintaining many open source codebases where users like me are constantly blabbing for features 😆 Thank you very much for doing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide options for V2 cli to override the default bundle_url
3 participants