Skip to content

Commit

Permalink
Update update_sha256.py
Browse files Browse the repository at this point in the history
  • Loading branch information
aradfarahani authored Mar 1, 2025
1 parent 86afba9 commit 15d7c36
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions scripts /update_sha256.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import requests
import yaml

# Function to read version from the VERSION file
def read_version_from_file(version_file="VERSION"):
with open(version_file, "r") as file:
return file.read().strip()

# Function to calculate SHA256 checksum of a file
def calculate_sha256(file_path):
sha256_hash = hashlib.sha256()
Expand All @@ -19,23 +24,26 @@ def download_source(url, dest_path):
f.write(chunk)
print(f"Downloaded {url} to {dest_path}")

# Function to update the meta.yaml file with new SHA256
def update_meta_yaml(meta_yaml_path, new_sha256):
# Function to update the meta.yaml file with new SHA256 and version
def update_meta_yaml(meta_yaml_path, new_sha256, version):
with open(meta_yaml_path, 'r') as file:
meta = yaml.safe_load(file)

# Update the SHA256 field in the source section
# Update the version and SHA256 field in the meta.yaml file
meta['package']['version'] = version
meta['source']['sha256'] = new_sha256

# Write the updated YAML back to file
with open(meta_yaml_path, 'w') as file:
yaml.dump(meta, file, default_flow_style=False)
print(f"Updated meta.yaml with new SHA256: {new_sha256}")
print(f"Updated meta.yaml with version {version} and new SHA256: {new_sha256}")

# Main function
def main():
# Read the version from the VERSION file
version = read_version_from_file() # By default it looks for a file named 'VERSION'

# Define the package URL and destination for downloading
version = "0.4.11" # Update as per your version
url = f"https://pypi.io/packages/source/f/fezrs/fezrs-{version}.tar.gz"
dest_path = f"fezrs-{version}.tar.gz"

Expand All @@ -48,11 +56,11 @@ def main():
# Path to your meta.yaml file
meta_yaml_path = "recipe/meta.yaml"

# Update the meta.yaml file with the new SHA256
update_meta_yaml(meta_yaml_path, new_sha256)
# Update the meta.yaml file with the new version and SHA256
update_meta_yaml(meta_yaml_path, new_sha256, version)

# Optionally, trigger the build
os.system("conda build recipe/")

if __name__ == "__main__":
main()

0 comments on commit 15d7c36

Please sign in to comment.