@@ -130,20 +130,30 @@ def run(self):
130130
131131def _sqlglot_requirement ():
132132 """Pin sqlglot to the matching version so resolvers keep the two packages in lockstep."""
133- pkg_info = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "PKG-INFO" )
134- if os .path .isfile (pkg_info ):
135- # Building from an sdist: no git metadata; the released version is frozen in PKG-INFO.
136- with open (pkg_info , encoding = "utf-8" ) as fd :
137- version = next (
138- (line .split (":" , 1 )[1 ].strip () for line in fd if line .startswith ("Version:" )), ""
133+ try :
134+ pkg_info = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "PKG-INFO" )
135+ if os .path .isfile (pkg_info ):
136+ # Building from an sdist: no git metadata; the released version is frozen in PKG-INFO.
137+ with open (pkg_info , encoding = "utf-8" ) as fd :
138+ version = next (
139+ (line .split (":" , 1 )[1 ].strip () for line in fd if line .startswith ("Version:" )),
140+ "" ,
141+ )
142+ else :
143+ from setuptools_scm import get_version
144+
145+ version = get_version (
146+ root = ".." ,
147+ relative_to = __file__ ,
148+ local_scheme = "no-local-version" ,
149+ fallback_version = "0.0.0" ,
139150 )
140- else :
141- from setuptools_scm import get_version
151+ except Exception as e :
152+ print (f"sqlglotc: failed to determine the sqlglot version to pin, skipping it: { e } " )
153+ version = ""
142154
143- version = get_version (root = ".." , relative_to = __file__ , local_scheme = "no-local-version" )
144-
145- # Dev builds have no matching sqlglot release on PyPI, so skip the pin.
146- return [] if not version or ".dev" in version else [f"sqlglot=={ version } " ]
155+ # Dev and fallback (no git metadata) builds have no matching sqlglot release on PyPI.
156+ return [] if version in ("" , "0.0.0" ) or ".dev" in version else [f"sqlglot=={ version } " ]
147157
148158
149159setup (
0 commit comments