-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
Allow packages to easily retrieve their version #1501
Conversation
I think this should just look at the Project file of the package itself, not of the project/manifest of the active environment which seems like a very roundabout way of getting to the place where the version actually was defined. So something like (using JuliaLang/julia#33128) and with error checking project_data = Pkg.TOML.parsefile(joinpath(pkgdir(@__MODULE__), "Project.toml"))
return VersionNumber(project_data["version"]) This seems to encourage having a bunch of dead code around though. |
Codecov Report
@@ Coverage Diff @@
## master #1501 +/- ##
==========================================
+ Coverage 87.27% 87.29% +0.02%
==========================================
Files 25 25
Lines 5383 5393 +10
==========================================
+ Hits 4698 4708 +10
Misses 685 685
Continue to review full report at Codecov.
|
How can we locate the path of the package when in sub-module? I'm under the impression you meant |
I agree this will leave dead code around for a while. This however is better then forgetting to remove a deprecation when you do a version bump |
This should only be used at top level so the result ends up in the precompile file and so that no runtime parsing of the project file is needed. |
Code should be ready to go |
While this is better, it seems like if we're going to officially support this, we should it right and record the tree hash and version number at the time something was loaded, rather than this, which can become out of sync after loading. |
pkg_dir = pkgdir(__module__) | ||
|
||
if pkg_dir !== nothing | ||
project_data = TOML.parsefile(Types.projectfile_path(pkg_dir)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it makes sense to re-compile when the version in Project.toml is changed?
project_data = TOML.parsefile(Types.projectfile_path(pkg_dir)) | |
toml_path = Types.projectfile_path(pkg_dir) | |
include_dependency(toml_path) | |
project_data = TOML.parsefile(toml_path) |
Based upon suggestions here: JuliaLang/Pkg.jl#1501
I believe Please feel free to reopen if not, just a tidyup close |
Allows for packages to codify their own deprecations for future revisions. I example of deprecating the return type of a function: