It's a good idea to pin all of your wheels dependencies to a specific version for building the executables, to ensure they'll work after any upstream changes.
When building the wheels of your project, pyaket sets the environment variable PYAKET_RELEASE to 1 for detecting whether
importosimportrunpyfrompathlibimportPathfromhatchling.metadata.plugin.interfaceimportMetadataHookInterfaceclassPyaketHook(MetadataHookInterface):defupdate(self,metadata:dict)->None:repository=Path(__file__).parent# Get the version from the main packagecontext=runpy.run_path(repository/"package"/"__init__.py")version=metadata["version"]=context["__version__"]# Trick to replace all list items in placedefpatch(items:list[str])->None:for(x,item)inenumerate(items):if(os.environ.get("PYAKET_RELEASE","0")=="1"):item=item.replace("~=","==")item=item.replace(">=","==")items[x]=item# Patch all normal and optional dependencieslist(map(patch,metadata.get("optional-dependencies",{}).values()))patch(metadata.get("dependencies",{}))
This doesn't fully guarantee a locked environment as dependencies of dependencies might not be pinned. A better way is to send a uv.lock file, but it kills iterative development.
Todo: Improve and find a method without such drawbacks