-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Provide use_compat()
for managing common compat-[pkg].R
files
#1654
Comments
This suggestion feels along the same lines as Do you have any thoughts on this @lionel-? |
See also r-lib/rlang#1401 I do think it would be useful. We didn't add it to rlang immediately because we thought we might need some kind of dependency system (i.e. |
Ah, I didn't realize this was already under way in rlang. |
yup I've been meaning to take a look at implementing a simple dependency and version system for the rlang compat files. Also it would be nice to record all the compat files used by the package in a file so that you could do A few years ago @hadley thought this wouldn't be worth the work, but since we have now more compat files than we used to, I think this might now be worth it. I especially like that compat files allow us to refine experimental APIs without causing revdep breakages. They are a good playing field for emerging ideas and some more automatic tooling would be helpful. |
Thanks for the comments, I also wasn't aware of the discussion underway in rlang. Regarding dependencies, I really like the idea of documenting dependencies on other
Options of dealing with this are:
To be honest I would lean towards option 2, since building up a sophisticated dependency system for |
Just to be clear We also have I would like something (a) more consistent and (b) with less manual work. What I don't want is a "sophisticated" dependency system, we should only consider a simple one. |
Ah - thanks for clarifying 👍
Do you think these requirements would be met by limiting the scope of Apologies if I'm a step behind here - I'm not sure if |
Random thought that we might could do:
Which |
Interesting idea. |
So we're all aware while thinking about this, two pre-existing packages deal with a similar problem: I haven't seen much about them since they first came out, though, so I don't think they much took off. One of the authors here seems to be frustrated that tools he's developed are ignored without discussion, so I thought it best to bring it up. |
I think the packages above are solving a different problem. Maybe I'd call them "compat packages"? I think the problem we are trying to solve is how we vendor |
freebase is like that, actually. It stores files that get copied into a package rather than being a dependency itself. In other words, it deals with single compat files, as well, and in fact, uses usethis-style code to do so. bplyr is what you call a compat package, though. |
Vendoring an entire package is something that @gaborcsardi does often and has tools for, IIRC. But I agree with Jenny that this is a different problem than single compat files. |
Another solution in this space is staticimports to statically import functions from another package. It uses a roxygen2-style import syntax and imports individual functions with automatic function-dependency resolution. It requires exported functions be placed in What's nice about staticiports is that, in theory, you could import |
If we're going to make this work, I think we're going to need the # ---
# src-repo: r-lib/rlang
# src-file: compat-types-check.R
# dependencies: [compat-obj-type.R]
# last-updated: 2022-08-11
# ---
#
# ## Changelog
#
# 2022-08-11:
# - Added changelog.
#
# nocov start
...
# nocov end And then I think we need some additional text at the top of the copied files to make it clear that they come from another repo, maybe just something like: # ---------------------------------------------------------------------------------
# Compatiblity file inlined from rlang/R/compat-types-check.R: do not edit by hand
# --------------------------------------------------------------------------------- Maybe we should also give the created |
Actually maybe the src file doesn't need |
Or maybe just a |
use_compat()
for managing common compat-[pkg].R
filesuse_compat()
for managing common compat-[pkg].R
files
Just re-read this for first time in a while. If you work on it @hadley, |
Naming suggestion from @lionel-:
|
Often when writing a new package I find myself simply lifting scripts like
compat-purrr.R
from the {rlang} source-code to avoid taking on more dependencies than necessary. I think formalising this process would be well worth the effort. E.g. it could be done as follows:use_compat(pkg)
would copy acompat-pkg.R
into the user'sR
directory, e.g. from the github for an existing package such as {rlang} where the 'master' version is defined, or from a dedicated repo for tidyversecompat-
files. The second option seems better to me as it would also provide a nice place to look for such files without necessarily having to go through {usethis}.use_compat()
after the 'master' version has changed could update the existingcompat-
script after prompting the user to confirm any (potentially breaking) changes.use_compat()
could also support single functions, e.g. in the case ofwithr::defer()
, which has its owncompat-defer.R
file in the {rlang} source code.Obviously the real value here would be in having such
compat-
scripts readily available. However it sees like this is already somewhat of a 'soft-supported' service from the Tidyverse, to wit,rlang/compat-vctrs.R
begins with the following line:So, perhaps the work is already largely done and the creation of
use_compat()
would mainly be a case of compiling allcompat-
files which already exist.The text was updated successfully, but these errors were encountered: