diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 77cf4f1b..a3988e2c 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -129,6 +129,8 @@ jobs: run: bash bin/build_sdist.sh - name: Test source distribution + env: + RELEASE_BUILD: "true" run: bash bin/test_sdist.sh - name: Store artifacts diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 38ab2f97..15ecfd8b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -121,6 +121,8 @@ jobs: run: bash bin/build_sdist.sh - name: Test source distribution + env: + RELEASE_BUILD: "true" run: bash bin/test_sdist.sh - name: Store artifacts diff --git a/MANIFEST.in b/MANIFEST.in index d9b2a44d..5fcba451 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,5 @@ include README.md recursive-include src/pyqasm *.py *.pyx -include src/pyqasm/py.typed \ No newline at end of file +include src/pyqasm/py.typed + +exclude tests/* \ No newline at end of file diff --git a/bin/build_sdist.sh b/bin/build_sdist.sh index 62ab9497..dac5951f 100755 --- a/bin/build_sdist.sh +++ b/bin/build_sdist.sh @@ -19,6 +19,10 @@ set -x # current working directory TARGET_PATH="${1:-$(pwd)}" +# Reset the uncommitted changes which may have been made +git reset --hard HEAD +git clean -xdf + # Create a temporary dir, XXXXX will be replaced by a random string # of 5 chars to make the directory unique TEMP_ENV_DIR=$(mktemp -d -t build_env_XXXXX) diff --git a/bin/cibw/pre_build.sh b/bin/cibw/pre_build.sh index c48df491..c3a23b80 100755 --- a/bin/cibw/pre_build.sh +++ b/bin/cibw/pre_build.sh @@ -23,6 +23,10 @@ echo "Running pre_build.sh" # Script has an argument which is the project path project=$1 +# Reset any uncommitted changes which may have been made +git reset --hard HEAD +git clean -xdf + # Upgrade pip python -m pip install --upgrade pip diff --git a/bin/test_sdist.sh b/bin/test_sdist.sh index 2666da04..6d804b6e 100755 --- a/bin/test_sdist.sh +++ b/bin/test_sdist.sh @@ -30,6 +30,28 @@ SCRIPT_DIR="$TARGET_PATH/bin" "$SCRIPT_DIR/install_wheel_extras.sh" "$TARGET_PATH/dist" --type sdist --extra cli --extra test +# Print the installed version +python -c "import pyqasm; print('Installed pyqasm version:', pyqasm.__version__)" + +# Verify the installed version if release build +if [[ ${RELEASE_BUILD:-false} == "true" ]]; then + echo "Testing release build version" + + # get version from importlib + IMPORTLIB_VERSION=$(python -c "import importlib.metadata; print(importlib.metadata.version('pyqasm'))") + echo "Importlib version: $IMPORTLIB_VERSION" + + # get version from __version__ + VERSION_ATTRIBUTE=$(python -c "import pyqasm; print(pyqasm.__version__)") + echo "Version attribute: $VERSION_ATTRIBUTE" + + # check if the versions are the same + if [[ $IMPORTLIB_VERSION != $VERSION_ATTRIBUTE ]]; then + echo "Versions do not match" + exit 1 + fi +fi + # Run the tests on the installed source distribution pytest "$TARGET_PATH/tests" diff --git a/pyproject.toml b/pyproject.toml index 4ea0a31a..26dbd32f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pyqasm" -version = "0.2.0" +version = "0.2.1-alpha" description = "Python toolkit providing an OpenQASM 3 semantic analyzer and utilities for program analysis and compilation." authors = [{name = "qBraid Development Team"}, {email = "contact@qbraid.com"}] readme = "README.md" @@ -45,6 +45,7 @@ lint = ["black", "isort>=6.0.0", "pylint", "mypy", "qbraid-cli>=0.8.5"] docs = ["sphinx>=7.3.7,<8.2.0", "sphinx-autodoc-typehints>=1.24,<3.1", "sphinx-rtd-theme>=2.0.0,<4.0.0", "docutils<0.22", "sphinx-copybutton"] [tool.setuptools_scm] +version_scheme = "no-guess-dev" write_to = "src/pyqasm/_version.py" [tool.setuptools.package-data]