Skip to content

Instantly share code, notes, and snippets.

@gloriouskilka
Created December 10, 2024 12:26
Show Gist options
  • Save gloriouskilka/679ccbcac91875de950e79972d3ea61c to your computer and use it in GitHub Desktop.
Save gloriouskilka/679ccbcac91875de950e79972d3ea61c to your computer and use it in GitHub Desktop.
Autogen 0.2 autogen_agentchat_02 autogen_02
import os
import sys
def replace_in_file(filename, replacements):
with open(filename, 'r', encoding='utf-8') as f:
lines = f.readlines()
new_lines = []
for line in lines:
for old, new in replacements.items():
line = line.replace(old, new)
new_lines.append(line)
with open(filename, 'w', encoding='utf-8') as f:
f.writelines(new_lines)
def main():
# 1. Rename directory from autogen to autogen_02 if not already done
if os.path.exists('autogen') and not os.path.exists('autogen_02'):
os.rename('autogen', 'autogen_02')
# 2. Update setup.py: change package name and packages line
setup_replacements = {
'name="autogen-agentchat"': 'name="autogen_agentchat_02"',
'include=["autogen*"]': 'include=["autogen_02*"]',
'os.path.join(here, "autogen/version.py")': 'os.path.join(here, "autogen_02/version.py")'
}
if os.path.exists('setup.py'):
replace_in_file('setup.py', setup_replacements)
# 3. Recursively replace "autogen" with "autogen_02" in .py files (except setup.py, setup2.py)
for root, dirs, files in os.walk('.'):
# Skip .git and build directories
if '.git' in root or 'build' in root or 'autogen_02.egg-info' in root:
continue
for file in files:
if file.endswith('.py') and file not in ['setup.py', 'setup2.py']:
file_path = os.path.join(root, file)
replace_in_file(file_path, {'autogen': 'autogen_02'})
print("Done. The 0.2 code now uses 'autogen_02' namespace.")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment