|
9 | 9 |
|
10 | 10 | import click |
11 | 11 | from morph.cli.flags import Flags |
12 | | -from morph.config.project import default_initial_project, load_project, save_project |
| 12 | +from morph.config.project import ( |
| 13 | + BuildConfig, |
| 14 | + default_initial_project, |
| 15 | + load_project, |
| 16 | + save_project, |
| 17 | +) |
13 | 18 | from morph.constants import MorphConstant |
14 | 19 | from morph.task.base import BaseTask |
15 | 20 | from morph.task.utils.run_backend.state import MorphGlobalContext |
@@ -105,42 +110,12 @@ def run(self): |
105 | 110 | ) |
106 | 111 | project.package_manager = "poetry" |
107 | 112 |
|
108 | | - save_project(self.project_root, project) |
109 | | - |
110 | | - # Generate the Dockerfile template |
111 | | - template_dir = Path(__file__).parents[1].joinpath("include") |
112 | | - docker_template_file = template_dir.joinpath("Dockerfile") |
113 | | - if not docker_template_file.exists(): |
114 | | - click.echo( |
115 | | - click.style( |
116 | | - f"Template file not found: {docker_template_file}", fg="red" |
117 | | - ) |
118 | | - ) |
119 | | - click.echo() |
120 | | - sys.exit(1) |
121 | | - |
122 | | - # Generate the Dockerfile with the selected Python version |
123 | | - dockerfile_path = os.path.join(self.project_root, "Dockerfile") |
124 | | - try: |
125 | | - with docker_template_file.open("r", encoding="utf-8") as f: |
126 | | - dockerfile_content = f.read() |
| 113 | + if project.build is None: |
| 114 | + project.build = BuildConfig() |
| 115 | + project.build.package_manager = project.package_manager |
| 116 | + project.build.runtime = f"python{self.selected_python_version}" |
127 | 117 |
|
128 | | - # Replace the placeholder with the selected Python version |
129 | | - dockerfile_content = dockerfile_content.replace( |
130 | | - "${MORPH_PYTHON_VERSION}", self.selected_python_version |
131 | | - ) |
132 | | - |
133 | | - # Write the updated Dockerfile to the project directory |
134 | | - with open(dockerfile_path, "w") as output_file: |
135 | | - output_file.write(dockerfile_content) |
136 | | - except FileNotFoundError as e: |
137 | | - click.echo( |
138 | | - click.style(f"Error: Template Dockerfile not found: {e}", fg="red") |
139 | | - ) |
140 | | - sys.exit(1) |
141 | | - except IOError as e: |
142 | | - click.echo(click.style(f"Error: Unable to write Dockerfile: {e}", fg="red")) |
143 | | - sys.exit(1) |
| 118 | + save_project(self.project_root, project) |
144 | 119 |
|
145 | 120 | try: |
146 | 121 | morph_data_version = importlib.metadata.version("morph-data") |
@@ -178,9 +153,13 @@ def run(self): |
178 | 153 | pyproject_path = Path(self.project_root) / "pyproject.toml" |
179 | 154 | pyproject_path.write_text(pyproject_content, encoding="utf-8") |
180 | 155 |
|
| 156 | + # Run 'poetry install' to install the dependencies |
| 157 | + click.echo(click.style("Running 'poetry install'...", fg="blue")) |
| 158 | + subprocess.run(["poetry", "install"], cwd=self.project_root, check=True) |
| 159 | + |
181 | 160 | click.echo( |
182 | 161 | click.style( |
183 | | - "Added 'morph-data' to pyproject.toml with 'morph-data'.", |
| 162 | + "Poetry initialized with 'morph-data' as a dependency.", |
184 | 163 | fg="green", |
185 | 164 | ) |
186 | 165 | ) |
@@ -212,9 +191,13 @@ def run(self): |
212 | 191 | pyproject_path = Path(self.project_root) / "pyproject.toml" |
213 | 192 | pyproject_path.write_text(pyproject_content, encoding="utf-8") |
214 | 193 |
|
| 194 | + # Run 'uv sync' to install dependencies |
| 195 | + click.echo(click.style("Running 'uv sync'...", fg="blue")) |
| 196 | + subprocess.run(["uv", "sync"], cwd=self.project_root, check=True) |
| 197 | + |
215 | 198 | click.echo( |
216 | 199 | click.style( |
217 | | - "Added 'morph-data' to pyproject.toml with 'morph-data'.", |
| 200 | + "uv initialized with 'morph-data' as a dependency.", |
218 | 201 | fg="green", |
219 | 202 | ) |
220 | 203 | ) |
|
0 commit comments