DSPy: The framework for programming—not prompting—language models
Python
Fix/push versions v2 (#1985)
Hanna Moazam30990975ac9d
diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.ymlindex bc3e8b284..ef9a43fac 100644--- a/.github/workflows/build_and_release.yml+++ b/.github/workflows/build_and_release.yml@@ -23,6 +23,7 @@ jobs:name: pypipermissions:id-token: write # IMPORTANT: mandatory for trusted publishing+ contents: writesteps:- uses: actions/checkout@v4- name: Set up Python 3.9@@ -30,7 +31,7 @@ jobs:with:python-version: "3.9"- name: Install dependencies- run: python3 -m pip install setuptools wheel twine semver packaging+ run: python3 -m pip install --upgrade setuptools wheel twine semver packaging- name: Get correct version for TestPyPI releaseid: check_versionrun: |@@ -41,11 +42,11 @@ jobs:echo "Version to be used for TestPyPI release: $NEW_VERSION"echo "::set-output name=version::$NEW_VERSION"- name: Update version in setup.py- run: sed -i '/#replace_package_version_marker/{n;s/version="[^"]*"/version="${{ steps.check_version.outputs.version }}"/;}' setup.py+ run: sed -i '/#replace_package_version_marker/{n;s/__version__="[^"]*"/__version__="${{ steps.check_version.outputs.version }}"/;}' ./dspy/__metadata__.py- name: Update version in pyproject.tomlrun: sed -i '/#replace_package_version_marker/{n;s/version="[^"]*"/version="${{ steps.check_version.outputs.version }}"/;}' pyproject.toml- name: Update package name in setup.py- run: sed -i '/#replace_package_name_marker/{n;s/name="[^"]*"/name="dspy-ai-test"/;}' setup.py+ run: sed -i '/#replace_package_name_marker/{n;s/__name__="[^"]*"/__name__="dspy-ai-test"/;}' ./dspy/__metadata__.py- name: Update package name in pyproject.tomlrun: sed -i '/#replace_package_name_marker/{n;s/name="[^"]*"/name="dspy-ai-test"/;}' pyproject.toml- name: Build a binary wheel@@ -62,6 +63,7 @@ jobs:name: pypipermissions:id-token: write # IMPORTANT: mandatory for trusted publishing+ contents: writesteps:- uses: actions/checkout@v4- name: Set up Python 3.9@@ -69,34 +71,59 @@ jobs:with:python-version: "3.9"- name: Install dependencies- run: python3 -m pip install setuptools wheel twine+ run: python3 -m pip install --upgrade setuptools wheel twine- name: Update version in setup.py (dspy)- run: sed -i '/#replace_package_version_marker/{n;s/version="[^"]*"/version="${{ needs.extract-tag.outputs.version }}"/;}' setup.py+ run: sed -i '/#replace_package_version_marker/{n;s/__version__="[^"]*"/__version__="${{ needs.extract-tag.outputs.version }}"/;}' ./dspy/__metadata__.py- name: Update version in pyproject.tomlrun: sed -i '/#replace_package_version_marker/{n;s/version="[^"]*"/version="${{ needs.extract-tag.outputs.version }}"/;}' pyproject.toml# Publish to dspy- name: Update package name in setup.pyrun: |- sed -i '/#replace_package_name_marker/{n;s/name="[^"]*"/name="dspy"/;}' setup.py+ sed -i '/#replace_package_name_marker/{n;s/__name__="[^"]*"/__name__="dspy"/;}' ./dspy/__metadata__.py- name: Update package name in pyproject.tomlrun: sed -i '/#replace_package_name_marker/{n;s/name="[^"]*"/name="dspy"/;}' pyproject.toml+ # Remove pyproject.toml temporarily to avoid conflicts+ - name: Temporarily remove pyproject.toml+ run: mv pyproject.toml pyproject.toml.bak- name: Build a binary wheelrun: python3 setup.py sdist bdist_wheel- name: Publish distribution 📦 to PyPI (dspy)uses: pypa/gh-action-pypi-publish@release/v1 # This requires a trusted publisher to be setup in pypiwith:attestations: false- # Publish to dspy-ai+ # Publish to dspy-ai- name: Update version in setup.py (dspy-ai)run: sed -i '/#replace_package_version_marker/{n;s/version="[^"]*"/version="${{ needs.extract-tag.outputs.version }}"/;}' ./dspy/.internal_dspyai/setup.py- name: Update package name in setup.pyrun: sed -i '/#replace_package_name_marker/{n;s/name="[^"]*"/name="dspy-ai"/;}' ./dspy/.internal_dspyai/setup.py- name: Update dspy dependency version in setup.pyrun: |- sed -i '/#replace_dspy_version_marker/{n;s/dspy==[^"]*/dspy>=${{ needs.extract-tag.outputs.version }}/;}' ./dspy/.internal_dspyai/setup.py+ sed -i '/#replace_dspy_version_marker/{n;s/dspy>=[^"]*/dspy>=${{ needs.extract-tag.outputs.version }}/;}' ./dspy/.internal_dspyai/setup.py- name: Build a binary wheelrun: python3 ./dspy/.internal_dspyai/setup.py sdist bdist_wheel- name: Publish distribution 📦 to PyPI (dspy-ai)uses: pypa/gh-action-pypi-publish@release/v1 # This requires a trusted publisher to be setup in pypiwith:- attestations: false\ No newline at end of file+ attestations: false+ # Restore pyproject.toml+ - name: Restore pyproject.toml+ run: mv pyproject.toml.bak pyproject.toml+ - uses: stefanzweifel/git-auto-commit-action@v5 # auto commit changes to main+ with:+ commit_message: Update versions+ create_branch: true+ branch: release-${{ needs.extract-tag.outputs.version }}+ - name: Checkout main branch+ run: |+ git fetch origin+ git checkout main+ - name: Configure git user+ run: |+ git config --global user.email "[email protected]"+ git config --global user.name "Github Actions"+ - name: Merge release branch into main+ run: |+ git merge --no-ff release-${{ needs.extract-tag.outputs.version }}+ - name: Push changes to main+ run: |+ git push origin main\ No newline at end of filediff --git a/.prettierignore b/.prettierignorenew file mode 100644index 000000000..6d2eaaa41--- /dev/null+++ b/.prettierignore@@ -0,0 +1 @@+.github/\ No newline at end of filediff --git a/dspy/__init__.py b/dspy/__init__.pyindex fea48caca..49fb5f944 100644--- a/dspy/__init__.py+++ b/dspy/__init__.py@@ -24,6 +24,14 @@ from dspy.dsp.colbertv2 import ColBERTv2configure = settings.configurecontext = settings.context+from .__metadata__ import (+ __name__,+ __version__,+ __description__,+ __url__,+ __author__,+ __author_email__+)import dspy.telepromptdiff --git a/dspy/__metadata__.py b/dspy/__metadata__.pynew file mode 100644index 000000000..93793d44d--- /dev/null+++ b/dspy/__metadata__.py@@ -0,0 +1,8 @@+#replace_package_name_marker+__name__="dspy"+#replace_package_version_marker+__version__="2.5.43"+__description__="DSPy"+__url__="https://github.com/stanfordnlp/dspy"+__author__="Omar Khattab"+__author_email__="[email protected]"\ No newline at end of filediff --git a/pyproject.toml b/pyproject.tomlindex 40359586b..28fbcb7c6 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -3,10 +3,12 @@ requires = ["setuptools>=40.8.0", "wheel"]build-backend = "setuptools.build_meta"[project]+# Do not add spaces around the '=' sign for any of the fields+# preceeded by a marker comment as it affects the publish workflow.#replace_package_name_marker-name = "dspy"+name="dspy"#replace_package_version_marker-version = "2.5.43"+version="2.5.43"description = "DSPy"readme = "README.md"authors = [{ name = "Omar Khattab", email = "[email protected]" }]diff --git a/setup.py b/setup.pyindex dace8c814..c2a993194 100644--- a/setup.py+++ b/setup.py@@ -1,4 +1,5 @@from setuptools import find_packages, setup+import os# Read the content of the README filewith open("README.md", encoding="utf-8") as f:@@ -8,20 +9,25 @@ with open("README.md", encoding="utf-8") as f:with open("requirements.txt", encoding="utf-8") as f:requirements = f.read().splitlines()+metadata = {}+here = os.path.abspath(os.path.dirname(__file__))+with open(os.path.join(here, "dspy", "__metadata__.py"), "r", encoding="utf-8") as f:+ exec(f.read(), metadata)+f.close()++setup(- #replace_package_name_marker- name="dspy",- #replace_package_version_marker- version="2.5.43",- description="DSPy",+ name=metadata["__name__"],+ version=metadata["__version__"],+ description=metadata["__description__"],+ url=metadata["__url__"],+ author=metadata["__author__"],+ author_email=metadata["__author_email__"],long_description=long_description,long_description_content_type="text/markdown",- url="https://github.com/stanfordnlp/dspy",- author="Omar Khattab",- author_email="[email protected]",license="MIT License",packages=find_packages(include=["dspy.*", "dspy"]),- python_requires=">=3.9",+ python_requires=">=3.9",install_requires=requirements,extras_require={