Skip to content

Commit

Permalink
Merge pull request #1450 from kuzudb/version-number-fix
Browse files Browse the repository at this point in the history
Get version from CMakeLists for Python build
  • Loading branch information
mewim committed Apr 6, 2023
2 parents 59e05d1 + 4163f7d commit a2f042f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions scripts/pip-package/package_tar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ tar -cf sdist.tar \
--exclude="./*.sh" .
rm -rf sdist && mkdir sdist
tar -xf sdist.tar -C ./sdist
(cd ./sdist; python3 setup.py egg_info)
rm -rf sdist.tar

# Create tar.gz for PyPI
Expand Down
17 changes: 14 additions & 3 deletions scripts/pip-package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
requirements = f.read().splitlines()


def _get_kuzu_version():
cmake_file = os.path.join(base_dir, 'kuzu-source', 'CMakeLists.txt')
with open(cmake_file) as f:
for line in f:
if line.startswith('project(Kuzu VERSION'):
return line.split(' ')[2].strip()


kuzu_version = os.environ['PYTHON_PACKAGE_VERSION'] if 'PYTHON_PACKAGE_VERSION' in os.environ else _get_kuzu_version()
print("The version of this build is %s" % kuzu_version)


class CMakeExtension(Extension):
def __init__(self, name: str, sourcedir: str = "") -> None:
super().__init__(name, sources=[])
Expand Down Expand Up @@ -55,9 +67,8 @@ def build_extension(self, ext: CMakeExtension) -> None:
deploy_target)
env_vars['CMAKE_OSX_DEPLOYMENT_TARGET'] = deploy_target


build_dir = os.path.join(ext.sourcedir, 'kuzu-source')

# Clean the build directory.
subprocess.run(['make', 'clean'], check=True, cwd=build_dir)

Expand All @@ -81,7 +92,7 @@ def run(self):


setup(name='kuzu',
version=os.environ['PYTHON_PACKAGE_VERSION'] if 'PYTHON_PACKAGE_VERSION' in os.environ else '0.0.1',
version=kuzu_version,
install_requires=[],
ext_modules=[CMakeExtension(
name="kuzu", sourcedir=base_dir)],
Expand Down

0 comments on commit a2f042f

Please sign in to comment.