Drop the hard `Pkg` dependency
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Đọc khai báo dependency và using Pkg trong src/FileIO.jl, sau đó kiểm tra các vị trí gọi đã deprecated trong src/deprecated.jl:50-67 và đường dẫn loading đang được sử dụng trong src/loadsave.jl:203. issue đưa ra hai phương án, vì vậy trước tiên hãy xác nhận maintainers muốn đi theo hướng nào. Công việc được xem là hoàn tất khi dependency không cần thiết được loại bỏ mà không làm hỏng đường dẫn không deprecated được hỗ trợ, và hành vi deprecated được xử lý theo phương án đã chọn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
FileIO declares Pkg in [deps] and does using Pkg in src/FileIO.jl, but no non-deprecated code path uses it. Every Pkg.* call site (src/deprecated.jl:50-67) lives in the legacy add_loader/add_saver methods that are already marked # TODO: delete this method in FileIO v2. Since FileIO sits near the root of a large part of the ecosystem's dependency graph, every downstream package inherits Pkg into its closure and pays for it at using time.
The dependency dates to 0336017 (June 2019, the REQUIRE → Project.toml migration), when Pkg.installed() and Pkg.add were used to detect and install missing backends. Both uses are long gone; the live path loads backends with Base.require in src/loadsave.jl:203, which is pure Base.
The registry fallback is nearly unreachable
The remaining block resolves a package name to a UUID by scanning the installed registries, across three version-dependent branches. It only runs when Base.identify_package returns nothing — i.e. the package isn't a direct dep of the active project — but the PkgId it builds is then handed to Base.require, which needs the package in the load path anyway.
So it can only help when the package is an indirect dep: in the manifest, not a direct dep. Otherwise it either finds nothing or finds a UUID that fails at require later. That's a lot of machinery, plus a stdlib in every downstream closure, for a case callers can handle by passing name => uuid — which the non-deprecated API already asks for.
Option A — lazy load (non-breaking, 1.x)
Drop using Pkg and the [deps] entry; load on demand inside the deprecated method, which has already emitted a depwarn by that point:
const PKG_UUID = UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f")
_load_pkg() = Base.require(Base.PkgId(PKG_UUID, "Pkg"))
and access Pkg.API.Context() etc. through the returned module. Identical behaviour for anyone on the deprecated path; everyone else stops paying.
Option B — delete the lookup (v2)
Resolve via Base.identify_package and Main only, and when both fail throw something actionable:
throw(ArgumentError("could not resolve package \"$pkgname\" from the active environment; " *
"pass it as a Module or as `\"$pkgname\" => uuid`"))
- Ngôn ngữ chính
- Julia
- Star
- 228
- Fork
- 83
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của JuliaIO/FileIO.jl
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
-
Add SVGZ formatĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Reintroduce stacktrace trimmingĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
-
Register BioJulia types ?Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
Tất cả issue của JuliaIO/FileIO.jl
Issue tương tự
-
Overload == for ZGroupĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
question
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
brown-ccv/Chamber.jl#272 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
JuliaAstro/SolarPosition.jl#143 ·
-
distributions
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
JuliaBayes/Wren.jl#404 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
JuliaAI/MLJTransforms.jl#113 ·
Maintainer thường phản hồi trong vòng 1 ngày