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

Add support for per workspace member locks #1094

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

davfsa
Copy link
Contributor

@davfsa davfsa commented May 19, 2024

This functionality can be enabled by setting tools.rye.workspace.per_member_lock to true

Added a test for the new functionality as well as one for workspaces on its own (as there didn't seem to be any).

Closes #615


This is my first ever rust pr, so any feedback is welcome and appreciated! If anything needs to be changed, "allow edits by maintainers" is on, or post a comment and I'll change the pr accordingly

This functionality can be enabled by setting `tools.rye.workspace.per_member_lock` to `true`
@davfsa
Copy link
Contributor Author

davfsa commented May 19, 2024

The windows test failures are a bit confusing.

Failure 1: (link)

It seems like uv functions differently in linux/macos and windows. Its reinstalling both workspace members even tho only one of them changed.

Failure 2: (link) Fixed by decf6f9

Ordering seems to be different in windows, (not only in that failure, but all through the test results). A #[cfg(unix)] block would not work here, as there would be too much duplicate code.

The first issue is uv specific, so an update there might be necessary to make it properly consistent

@davfsa
Copy link
Contributor Author

davfsa commented May 19, 2024

Managed to fix the first failure (decf6f9) at the expense of a little bit of overhead that comes from the sorting. I am not sure if its worth it to have reproducible tests in all platforms or not.

The second issue is a lot more weird and I find what is determining whether to re-install the project or not in uv. Ill keep investigating

@davfsa
Copy link
Contributor Author

davfsa commented May 19, 2024

I have no clue how to debug the last failure. I created a Windows 10 VM to run the tests in and was not even able to reproduce the same failures when running the cargo test or when playing around with uv/rye to attempt to reproduce it installing the editable that was not edited

Rye test Windows 10 VM results
PS C:\Users\davfsa\rye> cargo insta test --workspace --all-features
    Finished `test` profile [unoptimized + debuginfo] target(s) in 9.00s
     Running unittests src\main.rs (target\debug\deps\rye-d897b6fbf5b1da1b.exe)

running 26 tests
test config::config_tests::test_default_requires_python ... ok
test config::config_tests::test_default_license ... ok
test config::config_tests::test_default_build_system ... ok
test config::config_tests::test_default_toolchain ... ok
test config::config_tests::test_force_rye_managed ... ok
test config::config_tests::test_global_python ... ok
test config::config_tests::test_http_proxy_url ... ok
test config::config_tests::test_https_proxy_url ... ok
test config::config_tests::test_sources_default_inclusion ... ok
test config::config_tests::test_load_config ... ok
test config::config_tests::test_use_uv ... ok
test lock::test_make_relativec_url ... ok
test platform::test::test_read_python_version ... ok
test sources::py::test_get_download_url ... ok
test utils::test_command_output::test_command_output_defaults ... ok
test utils::test_command_output::test_command_output_from_quiet_and_verbose ... ok
test config::config_tests::test_venv_mark_sync_ignore ... ok
test utils::test_expand_env_vars::test_expand_env_vars_no_expansion ... ok
test utils::test_expand_env_vars::test_expand_env_vars_with_expansion ... ok
test utils::test_format_requirement::test_format_requirement_file_path ... ok
test utils::test_format_requirement::test_format_requirement_simple ... ok
test utils::test_format_requirement::test_format_requirement_complex ... ok
test utils::test_quiet_exit_display ... ok
test config::config_tests::test_default_author ... ok
test utils::test_is_inside_git_work_tree::test_is_inside_git_work_tree_true ... ok
test utils::test_is_inside_git_work_tree::test_is_inside_git_work_tree_false ... ok

test result: ok. 26 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.07s

     Running tests\test-list.rs (target\debug\deps\test_list-8143112581ab1f2f.exe)

running 2 tests
Initializing new virtualenv in C:\Users\davfsa\AppData\Local\Temp\.rye-tests---lDUovd\project\.venv
Python version: [email protected]
Initializing new virtualenv in C:\Users\davfsa\AppData\Local\Temp\.rye-tests---kYfuZM\project\.venv
Python version: [email protected]
Added jinja2>=3.1.2 as regular dependency
Added jinja2>=3.1.2 as regular dependency
Reusing already existing virtualenv
Generating production lockfile: \\?\C:\Users\davfsa\AppData\Local\Temp\.rye-tests---lDUovd\project\requirements.lock
Reusing already existing virtualenv
Generating production lockfile: \\?\C:\Users\davfsa\AppData\Local\Temp\.rye-tests---kYfuZM\project\requirements.lock
Generating dev lockfile: \\?\C:\Users\davfsa\AppData\Local\Temp\.rye-tests---lDUovd\project\requirements-dev.lock
Generating dev lockfile: \\?\C:\Users\davfsa\AppData\Local\Temp\.rye-tests---kYfuZM\project\requirements-dev.lock
Installing dependencies
Building file:///C:/Users/davfsa/AppData/Local/Temp/.rye-tests---lDUovd/project
░░░░░░░░░░░░░░░░░░░░ [0/1] Fetching packages...                                                                         Installing dependencies
   Built file:///C:/Users/davfsa/AppData/Local/Temp/.rye-tests---lDUovd/project                                         Built 1 editable in 918ms
Resolved 2 packages in 2ms
Downloaded 2 packages in 32ms
Installed 3 packages in 54ms
 + jinja2==3.1.2
 + markupsafe==2.1.3
 + my-project==0.1.0 (from file:///C:/Users/davfsa/AppData/Local/Temp/.rye-tests---lDUovd/project)
   Built file:///C:/Users/davfsa/AppData/Local/Temp/.rye-tests---kYfuZM/project                                         Built 1 editable in 935ms
Resolved 2 packages in 2ms
Downloaded 2 packages in 25ms
Installed 3 packages in 13ms
 + jinja2==3.1.2
 + markupsafe==2.1.3
 + my-project==0.1.0 (from file:///C:/Users/davfsa/AppData/Local/Temp/.rye-tests---kYfuZM/project)
Done!
test test_basic_list ... ok
test test_list_not_rye_managed ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 5.45s

     Running tests\test_add.rs (target\debug\deps\test_add-df3afaa621f8a707.exe)

running 5 tests
test test_add_flask ... ok
test test_add_flask_dotenv ... ok
test test_add_flask_wrong_venv_exported ... ok
test test_add_explicit_version_or_url ... ok
test test_add_from_find_links ... ok

test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 19.46s

     Running tests\test_cli.rs (target\debug\deps\test_cli-33bf92fbc788a2da.exe)

running 1 test
test test_dotenv ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.69s

     Running tests\test_config.rs (target\debug\deps\test_config-fe1176a18e93d2be.exe)

running 6 tests
test test_config_incompatible_format_and_show_path ... ok
test test_config_save_missing_folder ... ok
test test_config_empty ... ok
test test_config_get_set_multiple ... ok
test test_config_show_path_and_any_action ... ok
test test_config_show_path ... ok

test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.15s

     Running tests\test_init.rs (target\debug\deps\test_init-3194eec11e47d65d.exe)

running 4 tests
test test_init_lib_and_script_incompatible ... ok
test test_init_lib ... ok
test test_init_default ... ok
test test_init_script ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 5.63s

     Running tests\test_publish.rs (target\debug\deps\test_publish-a6621253289184e7.exe)

running 1 test
building my-project
* Creating isolated environment: venv+uv...
* Using external uv from C:\Users\davfsa\rye\target\debug\rye-test-dir\home\uv\0.1.42\uv.EXE
* Installing packages in isolated environment:
  - hatchling
* Getting build dependencies for sdist...
* Building sdist...
* Building wheel from sdist
* Creating isolated environment: venv+uv...
* Using external uv from C:\Users\davfsa\rye\target\debug\rye-test-dir\home\uv\0.1.42\uv.EXE
* Installing packages in isolated environment:
  - hatchling
* Getting build dependencies for wheel...
* Building wheel...
Successfully built my_project-0.1.0.tar.gz and my_project-0.1.0-py3-none-any.whl
test test_publish_outside_project ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 3.57s

     Running tests\test_ruff.rs (target\debug\deps\test_ruff-b66af89dd162de94.exe)

running 1 test
test test_lint_and_format ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.73s

     Running tests\test_self.rs (target\debug\deps\test_self-91aa4c57a6d8c47b.exe)

running 2 tests
test test_self_uninstall ... ignored
test test_version ... ok

test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.08s

     Running tests\test_sync.rs (target\debug\deps\test_sync-89e7b53413c4a286.exe)

running 6 tests
test test_add_and_sync_no_auto_sync ... ok
test test_add_autosync ... ok
test test_empty_sync ... ok
test test_autosync_remember ... ok
test test_workspace_sync ... ok
test test_workspace_sync_with_per_member_lock ... ok

test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 40.43s

     Running tests\test_test.rs (target\debug\deps\test_test-50d4783574730dc9.exe)

running 1 test
test test_basic_tool_behavior ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 4.91s

     Running tests\test_toolchain.rs (target\debug\deps\test_toolchain-c0651c68b340059a.exe)

running 1 test
Downloading [email protected]
Checking checksum
Unpacking
Downloaded [email protected]
test test_fetch ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 39.08s

     Running tests\test_tools.rs (target\debug\deps\test_tools-c87e10f39cfec1f0.exe)

running 1 test
test test_basic_tool_behavior ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 3.09s

     Running tests\test_version.rs (target\debug\deps\test_version-db1a0ce8e43598a2.exe)

running 2 tests
test test_version_show ... ok
test test_version_bump ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.32s

info: no snapshots to review

@davfsa
Copy link
Contributor Author

davfsa commented May 20, 2024

Decided to disable both tests in windows because I have no clue what is going on (cant even reproduce locally). I kept my project ordering change, because it seems like every other pathlike output in rye is sorted too.


EDIT: The last failure looks like not something this PR could have caused. I have seen a similar instance of events like it other prs in this repo, so it might just need a CI rerun Finally a green CI!

davfsa added 3 commits May 20, 2024 10:39
- Have a virtual and non-virtual project and ensure that only one is used
  - This has the "side effect" that the windows CI inconsistencies should no longer occur
- Use glob for members matching
- Remove redundant pyproject toml edits
@yc-wang00
Copy link

I like it. It looks exactly like what I need! When is this PR going to be merged?

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.

Feature: allow to generate requirements.lock for each modules in a workspace
2 participants