3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-11 21:50:52 +00:00

Fix ModuleNotFoundError by removing dynamic version loading from pyproject.toml

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-06-26 23:42:02 +00:00
parent f7e89fcbeb
commit d789a17898
3 changed files with 19 additions and 64 deletions

View file

@ -4,6 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "z3-solver"
version = "4.15.3.0"
description = "an efficient SMT solver library"
readme = "README.txt"
requires-python = ">=3.8"
@ -33,7 +34,6 @@ classifiers = [
dependencies = [
"importlib-resources; python_version < '3.9'"
]
dynamic = ["version"]
[project.urls]
Homepage = "https://github.com/Z3Prover/z3"
@ -51,5 +51,4 @@ z3 = ["lib/*", "include/*.h", "include/c++/*.h"]
[tool.setuptools.data-files]
bin = ["bin/*"]
[tool.setuptools.dynamic]
version = {attr = "z3_version.__version__"}

View file

@ -116,27 +116,22 @@ def _clean_native_build():
rmtree(BUILD_DIR)
def _z3_version():
# Import version from z3_version module for consistency
try:
from z3_version import get_version
return get_version()
except ImportError:
# Fallback to original implementation
post = os.getenv('Z3_VERSION_SUFFIX', '')
if RELEASE_DIR is None:
fn = os.path.join(SRC_DIR, 'scripts', 'mk_project.py')
if os.path.exists(fn):
with open(fn) as f:
for line in f:
n = re.match(r".*set_version\((.*), (.*), (.*), (.*)\).*", line)
if not n is None:
return n.group(1) + '.' + n.group(2) + '.' + n.group(3) + '.' + n.group(4) + post
return "?.?.?.?"
else:
version = RELEASE_METADATA[0]
if version.count('.') == 2:
version += '.0'
return version + post
# Get version from project metadata
post = os.getenv('Z3_VERSION_SUFFIX', '')
if RELEASE_DIR is None:
fn = os.path.join(SRC_DIR, 'scripts', 'mk_project.py')
if os.path.exists(fn):
with open(fn) as f:
for line in f:
n = re.match(r".*set_version\((.*), (.*), (.*), (.*)\).*", line)
if not n is None:
return n.group(1) + '.' + n.group(2) + '.' + n.group(3) + '.' + n.group(4) + post
return "?.?.?.?"
else:
version = RELEASE_METADATA[0]
if version.count('.') == 2:
version += '.0'
return version + post
def _configure_z3():
global IS_SINGLE_THREADED
@ -335,6 +330,7 @@ class bdist_wheel(_bdist_wheel):
setup(
# Most configuration is now in pyproject.toml
# Keep only setup.py-specific configuration
version=_z3_version(),
setup_requires = SETUP_REQUIRES,
include_package_data=True,
package_data={

View file

@ -1,40 +0,0 @@
"""
Version detection for z3-solver package.
"""
import os
import re
def get_version():
"""Get the z3 version from the source tree."""
post = os.getenv('Z3_VERSION_SUFFIX', '')
# Determine where the source directory is located
ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
SRC_DIR_LOCAL = os.path.join(ROOT_DIR, 'core')
SRC_DIR_REPO = os.path.join(ROOT_DIR, '..', '..', '..')
SRC_DIR = SRC_DIR_LOCAL if os.path.exists(SRC_DIR_LOCAL) else SRC_DIR_REPO
# Check if we're using a release directory
RELEASE_DIR = os.environ.get('PACKAGE_FROM_RELEASE', None)
if RELEASE_DIR is None:
fn = os.path.join(SRC_DIR, 'scripts', 'mk_project.py')
if os.path.exists(fn):
with open(fn) as f:
for line in f:
n = re.match(r".*set_version\((.*), (.*), (.*), (.*)\).*", line)
if not n is None:
return n.group(1) + '.' + n.group(2) + '.' + n.group(3) + '.' + n.group(4) + post
return "4.15.3.0" + post # fallback version
else:
RELEASE_METADATA = os.path.basename(RELEASE_DIR).split('-')
if RELEASE_METADATA[0] == 'z3' and len(RELEASE_METADATA) >= 4:
RELEASE_METADATA.pop(0)
version = RELEASE_METADATA[0]
if version.count('.') == 2:
version += '.0'
return version + post
return "4.15.3.0" + post # fallback version
# Make version available at module level
__version__ = get_version()