From 3347847df6534ae321e55262ed64cb1034862556 Mon Sep 17 00:00:00 2001 From: Ruizhi Yu Date: Tue, 4 Jun 2024 07:49:28 +0800 Subject: [PATCH] Release/0.0.4 (#85) * feat: enable Solverz version peek * update publish-to-pypi.yml --- .github/workflows/publish-to-pypi.yml | 8 ++++---- Solverz/__init__.py | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index efec1d7..d65217f 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -4,7 +4,7 @@ on: push jobs: build: - name: Build distribution 📦 + name: Build distribution runs-on: ubuntu-latest steps: @@ -29,7 +29,7 @@ jobs: publish-to-pypi: name: >- - Publish Python 🐍 distribution 📦 to PyPI + Publish Python distribution to PyPI if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes needs: - build @@ -46,12 +46,12 @@ jobs: with: name: python-package-distributions path: dist/ - - name: Publish distribution 📦 to PyPI + - name: Publish distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1 github-release: name: >- - Sign the Python 🐍 distribution 📦 with Sigstore + Sign the Python distribution with Sigstore and upload them to GitHub Release needs: - publish-to-pypi diff --git a/Solverz/__init__.py b/Solverz/__init__.py index f284f7f..1d9d2ee 100644 --- a/Solverz/__init__.py +++ b/Solverz/__init__.py @@ -11,3 +11,11 @@ from Solverz.utilities.profile import count_time from Solverz.variable.ssymbol import Var, AliasVar from Solverz.model.basic import Model + +from importlib.metadata import version, PackageNotFoundError + +try: + __version__ = version("Solverz") +except PackageNotFoundError: + # package is not installed + pass