Skip to content
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

Get version from CMakeLists for Python build #1450

Merged
merged 1 commit into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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