From 07594193e7bceefe0a87b865ac528b9841f665d9 Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Tue, 11 Jun 2024 10:02:20 +0200 Subject: [PATCH 1/2] Package driver as pure-python wheel for easier installation --- bin/dist-functions | 2 +- bin/make-dist | 2 +- setup.py | 19 +++++++++---------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/bin/dist-functions b/bin/dist-functions index 50c2943e3..a4fd229b1 100644 --- a/bin/dist-functions +++ b/bin/dist-functions @@ -121,6 +121,6 @@ function setup { ARGS="$*" rm -rf ${DIST} 2> /dev/null - set_metadata_and_setup "neo4j-driver" "True" ${ARGS} # Legacy package; can be removed in 2.0 + set_metadata_and_setup "neo4j-driver" "True" ${ARGS} --sdist # Legacy package; can be removed in 2.0 set_metadata_and_setup "neo4j" "False" ${ARGS} } diff --git a/bin/make-dist b/bin/make-dist index 1ce5161d9..2d300e3a9 100755 --- a/bin/make-dist +++ b/bin/make-dist @@ -11,5 +11,5 @@ then exit 1 else source "${ROOT}/bin/dist-functions" - setup "${VERSION}" --sdist + setup "${VERSION}" fi diff --git a/setup.py b/setup.py index 314629181..3499197dc 100644 --- a/setup.py +++ b/setup.py @@ -58,8 +58,7 @@ """ + readme -@contextmanager -def changed_package_name(new_name): +def change_project_name(new_name): with open("pyproject.toml", "a+") as fd: fd.seek(0) pyproject = tomlkit.parse(fd.read()) @@ -68,16 +67,16 @@ def changed_package_name(new_name): fd.seek(0) fd.truncate() tomlkit.dump(pyproject, fd) + return old_name - yield - with open("pyproject.toml", "a+") as fd: - fd.seek(0) - pyproject = tomlkit.parse(fd.read()) - pyproject["project"]["name"] = old_name - fd.seek(0) - fd.truncate() - tomlkit.dump(pyproject, fd) +@contextmanager +def changed_package_name(new_name): + old_name = change_project_name(new_name) + try: + yield + finally: + change_project_name(old_name) with changed_package_name(package): From 629cb67b964cc0ff3631ef15a78baa24defd0a06 Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Tue, 11 Jun 2024 10:21:31 +0200 Subject: [PATCH 2/2] Fix: upload the built wheel on release --- bin/release | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/bin/release b/bin/release index 2c3d69af9..9d73b036e 100755 --- a/bin/release +++ b/bin/release @@ -24,13 +24,25 @@ for PACKAGE in "neo4j-driver" "neo4j"; do NORMALIZED_PACKAGE="$(normalize_dist_name "$PACKAGE")" if check_file "${DIST}/${NORMALIZED_PACKAGE}-${VERSION}.tar.gz" then - TWINE_ARGS="${TWINE_ARGS} ${DIST}/${NORMALIZED_PACKAGE}-${VERSION}.tar.gz" + TWINE_ARGS="${TWINE_ARGS} ${DIST}/${NORMALIZED_PACKAGE}-${VERSION}.tar.gz" elif check_file "${DIST}/${PACKAGE}-${VERSION}.tar.gz"; then - TWINE_ARGS="${TWINE_ARGS} ${DIST}/${PACKAGE}-${VERSION}.tar.gz" + TWINE_ARGS="${TWINE_ARGS} ${DIST}/${PACKAGE}-${VERSION}.tar.gz" else - echo "Distribution file for ${PACKAGE} not found" - exit 1 + echo "Source distribution file for ${PACKAGE} not found" + exit 1 fi done +NORMALIZED_PACKAGE="$(normalize_dist_name "neo4j")" +if check_file "${DIST}/${NORMALIZED_PACKAGE}-${VERSION}-py3-none-any.whl" +then + TWINE_ARGS="${TWINE_ARGS} ${DIST}/${NORMALIZED_PACKAGE}-${VERSION}-py3-none-any.whl" +elif check_file "${DIST}/${PACKAGE}-${VERSION}-py3-none-any.whl"; then + TWINE_ARGS="${TWINE_ARGS} ${DIST}/${PACKAGE}-${VERSION}-py3-none-any.whl" +else + echo "Wheel distribution file for ${PACKAGE} not found" + exit 1 +fi + + twine upload ${TWINE_ARGS}