Skip to content

Commit

Permalink
Python: Add version string & wheel build command (#1985)
Browse files Browse the repository at this point in the history
* add version string & wheel build command

* Update Python version in CI script

---------

Co-authored-by: Georgy Evtushenko <[email protected]>
  • Loading branch information
leofang and gevtushenko committed Jul 16, 2024
1 parent 99e7d60 commit cb7e845
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ci/update_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ done
major="$1"
minor="$2"
patch="$3"
pymajor="0"
pyminor="1"

if [ -z "$major" ] || [ -z "$minor" ] || [ -z "$patch" ]; then
echo "Usage: $0 [--dry-run] <major> <minor> <patch>"
Expand All @@ -34,6 +36,7 @@ CUB_CMAKE_VERSION_FILE="cub/cub/cmake/cub-config-version.cmake"
LIBCUDACXX_CMAKE_VERSION_FILE="libcudacxx/lib/cmake/libcudacxx/libcudacxx-config-version.cmake"
THRUST_CMAKE_VERSION_FILE="thrust/thrust/cmake/thrust-config-version.cmake"
CUDAX_CMAKE_VERSION_FILE="cudax/lib/cmake/cudax/cudax-config-version.cmake"
PYCUDA_VERSION_FILE="python/cuda/cuda/cooperative/_version.py"

# Calculated version codes
new_cccl_version=$((major * 1000000 + minor * 1000 + patch)) # MMMmmmppp
Expand Down Expand Up @@ -99,6 +102,8 @@ update_file "$CUDAX_CMAKE_VERSION_FILE" "set(cudax_VERSION_MAJOR \([0-9]\+\))" "
update_file "$CUDAX_CMAKE_VERSION_FILE" "set(cudax_VERSION_MINOR \([0-9]\+\))" "set(cudax_VERSION_MINOR $minor)"
update_file "$CUDAX_CMAKE_VERSION_FILE" "set(cudax_VERSION_PATCH \([0-9]\+\))" "set(cudax_VERSION_PATCH $patch)"

update_file "$PYCUDA_VERSION_FILE" "^__version__ = \"\([0-9.]\+\)\"" "__version__ = \"$pymajor.$pyminor.$major.$minor.$patch\""

if [ "$DRY_RUN" = true ]; then
echo "Dry run completed. No changes made."
else
Expand Down
1 change: 1 addition & 0 deletions python/cuda/cuda/cooperative/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

import cuda.cooperative.experimental
from cuda.cooperative._version import __version__
7 changes: 7 additions & 0 deletions python/cuda/cuda/cooperative/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# This file is generated by ci/update_version.sh
# Do not edit this file manually.
__version__ = "0.1.2.6.0"
19 changes: 17 additions & 2 deletions python/cuda/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import os
import glob
import shutil

from setuptools import Command, setup, find_packages, find_namespace_packages
from setuptools.command.build_py import build_py
from wheel.bdist_wheel import bdist_wheel


project_path = os.path.abspath(os.path.dirname(__file__))
Expand All @@ -17,13 +19,25 @@
['libcudacxx', 'include'],
['thrust', 'thrust']
]
with open(os.path.join(project_path, 'cuda', 'cooperative', '_version.py')) as f:
exec(f.read())
ver = __version__
del __version__


class CustomBuildCommand(build_py):
def run(self):
self.run_command('package_cccl')
build_py.run(self)


class CustomWheelBuild(bdist_wheel):

def run(self):
self.run_command('package_cccl')
super().run()


class PackageCCCLCommand(Command):
description = 'Generate additional files'
user_options = []
Expand All @@ -46,7 +60,7 @@ def run(self):

setup(
name="cuda-cooperative",
version="0.1.0", # TODO Read from CCCL version
version=ver,
description="Experimental Core Library for CUDA Python",
author="NVIDIA Corporation",
classifiers=[
Expand All @@ -68,7 +82,8 @@ def run(self):
},
cmdclass={
'package_cccl': PackageCCCLCommand,
'build_py': CustomBuildCommand
'build_py': CustomBuildCommand,
'bdist_wheel': CustomWheelBuild,
},
include_package_data=True
)

0 comments on commit cb7e845

Please sign in to comment.