Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5779779
single source of truth for version identifier
ahnaf-tahmid-chowdhury Sep 24, 2024
104dfb0
Follow PyPA compliant
ahnaf-tahmid-chowdhury Sep 27, 2024
cb849ee
move version file to root-level
ahnaf-tahmid-chowdhury Sep 27, 2024
0ce318c
add get_version_info function
ahnaf-tahmid-chowdhury Sep 27, 2024
0eff6a4
Merge remote-tracking branch 'upstream/develop' into version
ahnaf-tahmid-chowdhury Oct 3, 2024
dd6e579
Merge remote-tracking branch 'upstream/develop' into version
ahnaf-tahmid-chowdhury Oct 16, 2024
23b93e3
add export config
ahnaf-tahmid-chowdhury Oct 16, 2024
31e3692
remove version file
ahnaf-tahmid-chowdhury Oct 16, 2024
d6be0ff
Ensure the version string matches a standard format
ahnaf-tahmid-chowdhury Oct 16, 2024
8bc99cd
set fetch depth to zero
ahnaf-tahmid-chowdhury Oct 16, 2024
2eb6c93
Merge branch 'develop' into version
shimwell Jan 11, 2025
5219406
add hash
ahnaf-tahmid-chowdhury Jan 12, 2025
d4b37cf
Add more log
ahnaf-tahmid-chowdhury Jan 12, 2025
160bf43
clang format
ahnaf-tahmid-chowdhury Jan 12, 2025
2b47355
Find git at the beginning
ahnaf-tahmid-chowdhury Jan 12, 2025
923f84a
add VERSION_COMMIT_COUNT
ahnaf-tahmid-chowdhury Jan 19, 2025
07c65a3
Increment release number for dev versions
ahnaf-tahmid-chowdhury Jan 23, 2025
940c571
Merge remote-tracking branch 'upstream/develop' into version
ahnaf-tahmid-chowdhury Jan 23, 2025
21594d6
Move versioning to a separate file, as suggested by @gonuke
ahnaf-tahmid-chowdhury Jan 26, 2025
14e678f
add more info
ahnaf-tahmid-chowdhury Jan 26, 2025
075f92b
Merge remote-tracking branch 'upstream/develop' into version
ahnaf-tahmid-chowdhury Jan 26, 2025
dc28e2a
Update cmake/Modules/GetVersionFromGit.cmake
ahnaf-tahmid-chowdhury Jan 27, 2025
e2a64d7
Update cmake/Modules/GetVersionFromGit.cmake
ahnaf-tahmid-chowdhury Jan 27, 2025
1603dc5
add more variables
ahnaf-tahmid-chowdhury Jan 27, 2025
9dc344e
Update cmake/Modules/GetVersionFromGit.cmake
ahnaf-tahmid-chowdhury Jan 29, 2025
efc43ba
Merge branch 'develop' into version
ahnaf-tahmid-chowdhury Feb 17, 2025
a2942f6
Don't use PROJECT_ variable names
paulromano Feb 20, 2025
727a0ae
Get rid of unused variables
paulromano Feb 20, 2025
8440b2c
Fix fetch-depth
paulromano Feb 20, 2025
8ddcb06
Set fetch-depth to 0 as before
paulromano Feb 20, 2025
ece247a
Update cmake/Modules/GetVersionFromGit.cmake
paulromano Feb 21, 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
25 changes: 21 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
project(openmc C CXX)

# Set version numbers
set(OPENMC_VERSION_MAJOR 0)
set(OPENMC_VERSION_MINOR 15)
set(OPENMC_VERSION_RELEASE 1)
# Read the version information from version.txt
file(READ "tools/version.txt" VERSION_STRING)

# Strip any whitespace
string(STRIP "${VERSION_STRING}" VERSION_STRING)

# Match version format and capture the main version part
if(VERSION_STRING MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)(-[^ ]+)?$")
set(VERSION_NO_SUFFIX "${CMAKE_MATCH_1}")
else()
message(FATAL_ERROR "Invalid version format in version.txt: ${VERSION_STRING}")
endif()

# Set OpenMC version
string(REPLACE "." ";" VERSION_LIST "${VERSION_NO_SUFFIX}")
list(GET VERSION_LIST 0 OPENMC_VERSION_MAJOR)
list(GET VERSION_LIST 1 OPENMC_VERSION_MINOR)
list(GET VERSION_LIST 2 OPENMC_VERSION_RELEASE)
set(OPENMC_VERSION ${OPENMC_VERSION_MAJOR}.${OPENMC_VERSION_MINOR}.${OPENMC_VERSION_RELEASE})
message(STATUS "OpenMC version: ${OPENMC_VERSION}")

# Generate version.h
configure_file(include/openmc/version.h.in "${CMAKE_BINARY_DIR}/include/openmc/version.h" @ONLY)

# Setup output directories
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = [
{name = "The OpenMC Development Team", email = "[email protected]"},
]
description = "OpenMC"
version = "0.15.1-dev"
dynamic = ["version"]
requires-python = ">=3.10"
license = {file = "LICENSE"}
classifiers = [
Expand Down Expand Up @@ -58,6 +58,9 @@ Documentation = "https://docs.openmc.org"
Repository = "https://github.com/openmc-dev/openmc"
Issues = "https://github.com/openmc-dev/openmc/issues"

[tool.setuptools.dynamic]
version = {file = "tools/version.txt"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this file need locating elsewhere, perhaps in the source code. I'm not sure but perhaps that helps when packaging as I don't think the tools folder is included in the packaging (e.g. conda)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is only required at build time. If it is necessary at runtime, we can put it in the root dir.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that openmc-feedstock uses a specific release tar file, which includes all the folders, including the tools folder.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for answering this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert, but this doesn't feel like a tools sort of thing. To me it feels like a top level file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing it this way means openmc.__version__ still works due to how __version__ is populated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have stored this file in the tools directory because it is only required during build time. Python's wheel uses it to create the wheel, and CMake uses it to generate the version.h file. Additionally, we can use this file for other purposes. I placed it in that folder to keep the root directory clean. However, if necessary, we can move it to the root directory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to agree that this is more of a root-level file.


[tool.setuptools.packages.find]
include = ['openmc*', 'scripts*']
exclude = ['tests*']
Expand Down
1 change: 1 addition & 0 deletions tools/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.15.1-dev
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably beyond the scope of this PR alone, but this isn't PyPA compliant. It should be: 0.15.1.devN (Probably dev1?). Also you accidentally incremented a major release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setuptools will handle the task for us, so we can continue using the legacy format.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something setuptools does because it's nice to do; not because it has to. I think changing to PyPA compliant is a small change that would reduce the risk of something breaking in the future. (Honestly I don't think many people would even notice beyond some of the core devs.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyPA does allow -dev but probably better to use a dot since it's perferred

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. TIL.