Skip to content

Commit c2eae2e

Browse files
Update version to 1.2.7 in pyproject.toml and refactor PDK installation process to use a dedicated virtual environment. Improved directory management and streamlined error handling during setup.
1 parent 7ca454f commit c2eae2e

2 files changed

Lines changed: 72 additions & 76 deletions

File tree

chipfoundry_cli/main.py

Lines changed: 71 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,8 @@ def maybe_abort_no_space(err, step_label):
15811581
# Step 5: Install PDK with Ciel
15821582
if install_pdk:
15831583
console.print("\n[bold]Step 5:[/bold] Installing PDK with Ciel...")
1584-
caravel_venv_dir = project_root_path / 'caravel' / 'venv'
1584+
# Use a dedicated venv location independent of Caravel
1585+
ciel_venv_dir = project_root_path / 'dependencies' / 'ciel-venv'
15851586
pdk_root = project_root_path / 'dependencies' / 'pdks'
15861587

15871588
# Determine OPEN_PDKS_COMMIT based on PDK
@@ -1595,7 +1596,7 @@ def maybe_abort_no_space(err, step_label):
15951596

15961597
# Check if already installed
15971598
is_installed = (
1598-
check_python_package_installed(caravel_venv_dir, 'ciel') and
1599+
check_python_package_installed(ciel_venv_dir, 'ciel') and
15991600
pdk_version_file.exists() and
16001601
(pdk_root / pdk).exists()
16011602
)
@@ -1609,79 +1610,78 @@ def maybe_abort_no_space(err, step_label):
16091610
console.print(f"[dim]Would install PDK {pdk} using Ciel[/dim]")
16101611
else:
16111612
try:
1612-
# Check if caravel directory exists
1613-
caravel_dir = project_root_path / 'caravel'
1614-
if not caravel_dir.exists():
1615-
console.print("[yellow]Warning: Caravel not found. Install caravel first.[/yellow]")
1616-
console.print("[cyan]Run: cf setup --only-caravel[/cyan]")
1617-
else:
1618-
# Remove existing venv if overwriting or doesn't exist
1619-
if caravel_venv_dir.exists() and (overwrite or not is_installed):
1620-
console.print("[cyan]Removing existing Ciel venv...[/cyan]")
1621-
shutil.rmtree(caravel_venv_dir)
1613+
# Ensure dependencies directory exists
1614+
dependencies_dir = project_root_path / 'dependencies'
1615+
dependencies_dir.mkdir(exist_ok=True)
1616+
1617+
# Remove existing venv if overwriting or doesn't exist
1618+
if ciel_venv_dir.exists() and (overwrite or not is_installed):
1619+
console.print("[cyan]Removing existing Ciel venv...[/cyan]")
1620+
shutil.rmtree(ciel_venv_dir)
1621+
1622+
if not ciel_venv_dir.exists():
1623+
console.print("[cyan]Creating Ciel virtual environment...[/cyan]")
1624+
subprocess.run(
1625+
[sys.executable, '-m', 'venv', str(ciel_venv_dir)],
1626+
check=True,
1627+
capture_output=True
1628+
)
16221629

1623-
if not caravel_venv_dir.exists():
1624-
console.print("[cyan]Creating Ciel virtual environment...[/cyan]")
1625-
subprocess.run(
1626-
[sys.executable, '-m', 'venv', str(caravel_venv_dir)],
1627-
check=True,
1628-
capture_output=True
1629-
)
1630-
1631-
venv_python = str(caravel_venv_dir / 'bin' / 'python3')
1632-
1633-
console.print("[cyan]Installing Ciel...[/cyan]")
1634-
subprocess.run(
1635-
[venv_python, '-m', 'pip', 'install', '--upgrade', '--no-cache-dir', 'pip'],
1636-
check=True,
1637-
capture_output=True
1638-
)
1639-
subprocess.run(
1640-
[venv_python, '-m', 'pip', 'install', '--upgrade', '--no-cache-dir', 'ciel'],
1641-
check=True,
1642-
capture_output=True
1643-
)
1644-
console.print("[green]✓[/green] Ciel installed successfully")
1630+
venv_python = str(ciel_venv_dir / 'bin' / 'python3')
1631+
1632+
console.print("[cyan]Installing Ciel...[/cyan]")
1633+
subprocess.run(
1634+
[venv_python, '-m', 'pip', 'install', '--upgrade', '--no-cache-dir', 'pip'],
1635+
check=True,
1636+
capture_output=True
1637+
)
1638+
subprocess.run(
1639+
[venv_python, '-m', 'pip', 'install', '--upgrade', '--no-cache-dir', 'ciel'],
1640+
check=True,
1641+
capture_output=True
1642+
)
1643+
console.print("[green]✓[/green] Ciel installed successfully")
1644+
1645+
# Remove existing PDK if overwriting
1646+
if (pdk_root / pdk).exists() and overwrite:
1647+
console.print(f"[cyan]Removing existing PDK {pdk}...[/cyan]")
1648+
shutil.rmtree(pdk_root / pdk)
1649+
1650+
if not (pdk_root / pdk).exists():
1651+
console.print(f"[cyan]Enabling PDK {pdk} with Ciel...[/cyan]")
1652+
console.print("[dim]Downloading and installing PDK files...[/dim]")
1653+
1654+
# Determine PDK family from PDK variant (sky130A/sky130B -> sky130)
1655+
pdk_family = pdk.rstrip('AB') # Remove A or B suffix
1656+
1657+
ciel_bin = str(ciel_venv_dir / 'bin' / 'ciel')
16451658

1646-
# Remove existing PDK if overwriting
1647-
if (pdk_root / pdk).exists() and overwrite:
1648-
console.print(f"[cyan]Removing existing PDK {pdk}...[/cyan]")
1649-
shutil.rmtree(pdk_root / pdk)
1659+
# Set up environment with PDK_ROOT
1660+
env = os.environ.copy()
1661+
env['PDK_ROOT'] = str(pdk_root)
1662+
env['CIEL_DATA_SOURCE'] = 'static-web:https://chipfoundry.github.io/ciel-releases'
16501663

1664+
# Run from project root instead of caravel directory
1665+
result = subprocess.run(
1666+
[ciel_bin, 'enable', '--pdk-family', pdk_family, open_pdks_commit],
1667+
cwd=str(project_root_path),
1668+
env=env,
1669+
capture_output=True,
1670+
text=True,
1671+
check=True
1672+
)
1673+
1674+
# Verify PDK was actually installed
16511675
if not (pdk_root / pdk).exists():
1652-
console.print(f"[cyan]Enabling PDK {pdk} with Ciel...[/cyan]")
1653-
console.print("[dim]Downloading and installing PDK files...[/dim]")
1654-
1655-
# Determine PDK family from PDK variant (sky130A/sky130B -> sky130)
1656-
pdk_family = pdk.rstrip('AB') # Remove A or B suffix
1657-
1658-
ciel_bin = str(caravel_venv_dir / 'bin' / 'ciel')
1659-
1660-
# Set up environment with PDK_ROOT
1661-
env = os.environ.copy()
1662-
env['PDK_ROOT'] = str(pdk_root)
1663-
env['CIEL_DATA_SOURCE'] = 'static-web:https://chipfoundry.github.io/ciel-releases'
1664-
1665-
result = subprocess.run(
1666-
[ciel_bin, 'enable', '--pdk-family', pdk_family, open_pdks_commit],
1667-
cwd=str(caravel_dir),
1668-
env=env,
1669-
capture_output=True,
1670-
text=True,
1671-
check=True
1672-
)
1673-
1674-
# Verify PDK was actually installed
1675-
if not (pdk_root / pdk).exists():
1676-
raise Exception(f"PDK directory {pdk_root / pdk} was not created by Ciel")
1677-
1678-
# Create version file only if PDK exists
1679-
pdk_root.mkdir(parents=True, exist_ok=True)
1680-
with open(pdk_version_file, 'w') as f:
1681-
f.write(f'{open_pdks_commit}\n')
1682-
1683-
console.print("[green]✓[/green] PDK installed successfully")
1684-
console.print(f"[dim]PDK installed to: {pdk_root}[/dim]")
1676+
raise Exception(f"PDK directory {pdk_root / pdk} was not created by Ciel")
1677+
1678+
# Create version file only if PDK exists
1679+
pdk_root.mkdir(parents=True, exist_ok=True)
1680+
with open(pdk_version_file, 'w') as f:
1681+
f.write(f'{open_pdks_commit}\n')
1682+
1683+
console.print("[green]✓[/green] PDK installed successfully")
1684+
console.print(f"[dim]PDK installed to: {pdk_root}[/dim]")
16851685

16861686
except subprocess.CalledProcessError as e:
16871687
maybe_abort_no_space(e, "PDK install")
@@ -2059,7 +2059,6 @@ def harden(macro, project_root, list_designs, tag, pdk, use_nix, use_docker, dry
20592059
execution_method = "Nix" if use_nix else "Docker"
20602060

20612061
# Set up environment variables
2062-
caravel_root = project_root_path / 'caravel'
20632062
pdk_root = project_root_path / 'dependencies' / 'pdks'
20642063

20652064
if not pdk:
@@ -2119,7 +2118,6 @@ def harden(macro, project_root, list_designs, tag, pdk, use_nix, use_docker, dry
21192118
env = os.environ.copy()
21202119
env.update({
21212120
'PROJECT_ROOT': str(project_root_path),
2122-
'CARAVEL_ROOT': str(caravel_root),
21232121
'PDK_ROOT': str(pdk_root),
21242122
'PDK': pdk,
21252123
'LIBRELANE_RUN_TAG': tag,
@@ -2133,7 +2131,6 @@ def harden(macro, project_root, list_designs, tag, pdk, use_nix, use_docker, dry
21332131
env = os.environ.copy()
21342132
env.update({
21352133
'PROJECT_ROOT': str(project_root_path),
2136-
'CARAVEL_ROOT': str(caravel_root),
21372134
'PDK_ROOT': str(pdk_root),
21382135
'PDK': pdk,
21392136
'LIBRELANE_RUN_TAG': tag,
@@ -2150,7 +2147,6 @@ def harden(macro, project_root, list_designs, tag, pdk, use_nix, use_docker, dry
21502147
str(venv_bin / 'python3'), '-m', 'librelane',
21512148
'-m', str(project_root_path),
21522149
'-m', str(pdk_root),
2153-
'-m', str(caravel_root),
21542150
'--dockerized',
21552151
]
21562152

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "chipfoundry-cli"
3-
version = "1.2.6"
3+
version = "1.2.7"
44
description = "CLI tool to automate ChipFoundry project submission to SFTP server"
55
authors = ["ChipFoundry <marwan.abbas@chipfoundry.io>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)