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

Adds py_require() function #1706

Merged
merged 60 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
3576166
Adds py_require() function
edgararuiz Dec 30, 2024
9766d73
Initial work on `get_or_create_venv()`, `uv_binary()`
t-kalinowski Jan 2, 2025
86c4af7
redirect output to file
t-kalinowski Jan 2, 2025
b2f81bf
Restores "replace" to py_require(), and makes both error and regular …
edgararuiz Jan 3, 2025
5577d58
Addresses feedback
edgararuiz Jan 7, 2025
4b24553
Adds exclamation mark to contraint check
edgararuiz Jan 7, 2025
7ef5ad7
Switches to using declared script dependencies
edgararuiz Jan 7, 2025
eff4af3
Removes "replace" and messages, add exclude_newer
edgararuiz Jan 8, 2025
c5708b1
Expands use of set, removes partial matching, simplifies code further
edgararuiz Jan 8, 2025
dac7af7
Renames 'omit' to 'remove', simplifies code further
edgararuiz Jan 9, 2025
d120b16
Makes get_python_reqs() output the default arg values for get_or_crea…
edgararuiz Jan 9, 2025
0273f8f
Switches error output of get_create_venv() based on interactive(), ad…
edgararuiz Jan 9, 2025
59d72af
Adds two more tests, aligns var setting better, adds test reset helpe…
edgararuiz Jan 10, 2025
712b445
initial snapshot tests prototype
t-kalinowski Jan 10, 2025
1d2324d
Switches to using setdiff() for 'remove' action
edgararuiz Jan 10, 2025
b094493
simplify snapshotting approach
t-kalinowski Jan 11, 2025
c7bbc59
support attaching internal namespace in snapshots
t-kalinowski Jan 13, 2025
ef4e2fc
initial "requirements are unsatisfiable" error msg impl.
t-kalinowski Jan 13, 2025
bea217d
Starts adding new tests, defaults get_or_create_venv() args to use wh…
edgararuiz Jan 13, 2025
74703fa
Uses processx+cli to display spinner, but only on interactive with RS…
edgararuiz Jan 15, 2025
b4e004a
Switches to using poll_io
edgararuiz Jan 15, 2025
f4e6c2a
Adds switching between quoting and not quoting based on using process…
edgararuiz Jan 15, 2025
f9f5b9e
Adds conditional quoting for python versions too, adds process kill s…
edgararuiz Jan 15, 2025
1b9e56f
Some code simplification, improvements to error msg
edgararuiz Jan 16, 2025
61b7359
Small fix
edgararuiz Jan 16, 2025
849d514
New py_require() print output
edgararuiz Jan 16, 2025
3c9ddc1
Adds quick step to run get_or_create_venv(), removes no-cache
edgararuiz Jan 17, 2025
33644e5
fix segfault in `py_activate_virtualenv()`
t-kalinowski Jan 17, 2025
146ac2a
Adds new_venv_path()
edgararuiz Jan 17, 2025
e1b87ac
Adds is_uv_environment() and adds environment change setp to py_requi…
edgararuiz Jan 17, 2025
843d08f
Fails if already initialized and user passes Python version
edgararuiz Jan 17, 2025
7159d90
Adds conditional for config, in case get_or_create_venv() fails, conf…
edgararuiz Jan 18, 2025
6b4d6e0
Updates snapshot to use new output, calls testthat::test_that directl…
edgararuiz Jan 20, 2025
6bdf2b3
Addresses all but one warnings/notes
edgararuiz Jan 20, 2025
61e3a42
Adds documentation to py_require()
edgararuiz Jan 20, 2025
05d5afa
Improves tryCatch for uv_binary()
edgararuiz Jan 20, 2025
a19bf50
Sets cache directory to subfulder in r-reticulate cache directory, an…
edgararuiz Jan 20, 2025
b66f478
Adds wrapper for py_require inside py_install, and displays warning i…
edgararuiz Jan 20, 2025
a00ed24
Merges some functions, removes unused functions, cleans up names, inc…
edgararuiz Jan 20, 2025
cc2238f
adds entry to pkgdown.yml
edgararuiz Jan 21, 2025
365c63c
Add Windows uv binary installer
edgararuiz Jan 21, 2025
f395131
Safer way to remove leading line break
edgararuiz Jan 21, 2025
e9bfe8a
Removes leading return carriage
edgararuiz Jan 21, 2025
16308b9
Adds extra error read for Windows
edgararuiz Jan 21, 2025
e4d0786
Adds simple tests for py_require. Trying to confirm that we'll get th…
edgararuiz Jan 22, 2025
eff5f55
uv_binary() test now works on Windows
edgararuiz Jan 22, 2025
31980dd
Switches simple tests to r_session() to make sure GHA interprates py_…
edgararuiz Jan 22, 2025
32531a8
Merge branch 'main' into main
edgararuiz Jan 22, 2025
75ea707
Adds routines to flatten requirement history into a single line
edgararuiz Jan 22, 2025
35be263
Fixes header in table print out
edgararuiz Jan 22, 2025
ef2d1ef
Simplifies py_require() code
edgararuiz Jan 22, 2025
6c32cba
Adds cli version of printout
edgararuiz Jan 23, 2025
06edfe0
Fixes print output lack of colons, and updates snapshot with new tabl…
edgararuiz Jan 23, 2025
e41352a
Adds error if package attempts to set exclude_newer
edgararuiz Jan 23, 2025
f999f4c
Cleans up print output code
edgararuiz Jan 23, 2025
4645b5e
Adds test for multiple py_require calls from a package
edgararuiz Jan 23, 2025
1f60d77
Removes py_reqs_use_cli()
edgararuiz Jan 23, 2025
8ab04a0
Inserts steps 13 into versions vignette
edgararuiz Jan 23, 2025
dcedf62
Merge branch 'rstudio:main' into main
edgararuiz Jan 24, 2025
89dfda1
Restores project ID
edgararuiz Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Suggests:
cli,
rmarkdown,
pillar,
processx,
testthat
LinkingTo: Rcpp
RoxygenNote: 7.3.2
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ S3method(print,python.builtin.list)
S3method(print,python.builtin.module)
S3method(print,python.builtin.object)
S3method(print,python.builtin.tuple)
S3method(print,python_requirements)
S3method(py_str,default)
S3method(py_str,python.builtin.bytearray)
S3method(py_str,python.builtin.dict)
Expand Down Expand Up @@ -190,6 +191,7 @@ export(py_module_available)
export(py_none)
export(py_numpy_available)
export(py_repr)
export(py_require)
export(py_run_file)
export(py_run_string)
export(py_save_object)
Expand Down
8 changes: 8 additions & 0 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ py_discover_config <- function(required_module = NULL, use_environment = NULL) {
else
e
})

uv_python <- uv_get_or_create_env()
if(!is.null(uv_python)) {
return(
python_config(uv_python)
)
}

if (!inherits(python, "error"))
try(return(python_config(python, required_module)))

Expand Down
21 changes: 21 additions & 0 deletions R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,27 @@ py_install <- function(packages,
{
check_forbidden_install("Python packages")

if (is_python_initialized() &&
is_uv_reticulate_managed_env(py_exe()) &&
is.null(envname)) {
if (!is.null(python_version)) {
stop(
"Python version requirements cannot be ",
"changed after Python has been initialized"
)
}
warning(
"An 'uv' virtual environment managed by 'reticulate' is currently in use.\n",
"To add more packages to your current session, call `py_require()` instead\n",
"of `py_install()`. Running:\n ",
paste0(
"`py_require(", paste0(sprintf("\"%s\"", packages), collapse = ", "), ")`"
)
)
py_require(packages)
return(invisible())
}

# if 'envname' was not provided, use the 'active' version of Python
if (is.null(envname)) {

Expand Down
Loading
Loading