-
Notifications
You must be signed in to change notification settings - Fork 14
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
Improve handling of git info in version number #348
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
91c5590
Workaround for https://github.com/pypa/pip/issues/13093
Luthaf 434b488
Improve handling of git info in version number
Luthaf eb502fd
Explicitly set MACOSX_DEPLOYMENT_TARGET when building wheels
Luthaf c0440da
Explain how to update the version of metatensor{-torch} we pull from …
Luthaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* text=auto | ||
featomic/include/featomic.h eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.1.0 | ||
0.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Parse a `_version_` number, and store its components in `_major_` `_minor_` | ||
# `_patch_` and `_rc_` | ||
function(parse_version _version_ _major_ _minor_ _patch_ _rc_) | ||
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)(-rc)?([0-9]+)?" _ "${_version_}") | ||
|
||
if(${CMAKE_MATCH_COUNT} EQUAL 3) | ||
set(${_rc_} "" PARENT_SCOPE) | ||
elseif(${CMAKE_MATCH_COUNT} EQUAL 5) | ||
set(${_rc_} ${CMAKE_MATCH_5} PARENT_SCOPE) | ||
else() | ||
message(FATAL_ERROR "invalid version string ${_version_}") | ||
endif() | ||
|
||
set(${_major_} ${CMAKE_MATCH_1} PARENT_SCOPE) | ||
set(${_minor_} ${CMAKE_MATCH_2} PARENT_SCOPE) | ||
set(${_patch_} ${CMAKE_MATCH_3} PARENT_SCOPE) | ||
endfunction() | ||
|
||
if (CMAKE_VERSION VERSION_LESS "3.17") | ||
# CMAKE_CURRENT_FUNCTION_LIST_DIR was added in CMake 3.17 | ||
set(CMAKE_CURRENT_FUNCTION_LIST_DIR "${CMAKE_CURRENT_LIST_DIR}") | ||
endif() | ||
|
||
# Get the time of the last modification since the last tag/release, and a hash | ||
# of the latest commit/full state of a dirty repository | ||
function(git_version_info _output_n_commits_ _output_git_hash_) | ||
set(_script_ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../scripts/git-version-info.py") | ||
|
||
if (EXISTS "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/git_version_info") | ||
# When building from a tarball, the script is executed and the result | ||
# put in this file | ||
file(STRINGS "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/git_version_info" _file_content_) | ||
list(GET _file_content_ 0 _n_commits_) | ||
list(GET _file_content_ 1 _git_hash_) | ||
|
||
elseif (EXISTS "${_script_}") | ||
# When building from a checkout, we'll need to run the script | ||
find_package(Python COMPONENTS Interpreter REQUIRED) | ||
execute_process( | ||
COMMAND "${Python_EXECUTABLE}" "${_script_}" "featomic-torch-v" | ||
RESULT_VARIABLE _status_ | ||
OUTPUT_VARIABLE _stdout_ | ||
ERROR_VARIABLE _stderr_ | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_FUNCTION_LIST_DIR} | ||
) | ||
|
||
if (NOT ${_status_} EQUAL 0) | ||
message(WARNING | ||
"git-version-info.py failed, version number might be wrong:\nstdout: ${_stdout_}\nstderr: ${_stderr_}") | ||
set(${_output_} 0 PARENT_SCOPE) | ||
return() | ||
endif() | ||
|
||
if (NOT "${_stderr_}" STREQUAL "") | ||
message(WARNING "git-version-info.py gave some errors, version number might be wrong:\nstdout: ${_stdout_}\nstderr: ${_stderr_}") | ||
endif() | ||
|
||
string(REPLACE "\n" ";" _lines_ ${_stdout_}) | ||
list(GET _lines_ 0 _n_commits_) | ||
list(GET _lines_ 1 _git_hash_) | ||
else() | ||
message(FATAL_ERROR "could not update git version information") | ||
endif() | ||
|
||
string(STRIP ${_n_commits_} _n_commits_) | ||
set(${_output_n_commits_} ${_n_commits_} PARENT_SCOPE) | ||
|
||
string(STRIP ${_git_hash_} _git_hash_) | ||
set(${_output_git_hash_} ${_git_hash_} PARENT_SCOPE) | ||
endfunction() | ||
|
||
|
||
# Take the version declared in the package, and increase the right number if we | ||
# are actually installing a developement version from after the latest git tag | ||
function(create_development_version _version_ _output_) | ||
git_version_info(_n_commits_ _git_hash_) | ||
|
||
parse_version(${_version_} _major_ _minor_ _patch_ _rc_) | ||
if(${_n_commits_} STREQUAL "0") | ||
# we are building a release, leave the version number as-is | ||
if("${_rc_}" STREQUAL "") | ||
set(${_output_} "${_major_}.${_minor_}.${_patch_}" PARENT_SCOPE) | ||
else() | ||
set(${_output_} "${_major_}.${_minor_}.${_patch_}-rc${_rc_}" PARENT_SCOPE) | ||
endif() | ||
else() | ||
# we are building a development version, increase the right part of the version | ||
if("${_rc_}" STREQUAL "") | ||
math(EXPR _minor_ "${_minor_} + 1") | ||
set(${_output_} "${_major_}.${_minor_}.0-dev${_n_commits_}+${_git_hash_}" PARENT_SCOPE) | ||
else() | ||
math(EXPR _rc_ "${_rc_} + 1") | ||
set(${_output_} "${_major_}.${_minor_}.${_patch_}-rc${_rc_}-dev${_n_commits_}+${_git_hash_}" PARENT_SCOPE) | ||
endif() | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should maybe document somewhere what to do when lifting the metatensor version.
Including updating the hashes etc...
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.
I mean, if you update the version number above and not this, then CMake will yell at you. But yeah, we should add documentation around this!
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.
I added some comments in the CMakeLists.txt, should be good for now!