|
10 | 10 | logger = logging.getLogger("mxdev") |
11 | 11 |
|
12 | 12 |
|
13 | | -def normalize_name(name: str) -> str: |
14 | | - """PEP 503 normalization: lowercased, runs of -, _, . become single -""" |
15 | | - return re.sub(r"[-_.]+", "-", name).lower() |
16 | | - |
17 | | - |
18 | 13 | class UvPyprojectUpdater(Hook): |
19 | 14 | """An mxdev hook that updates pyproject.toml during the write phase for uv-managed projects.""" |
20 | 15 |
|
@@ -66,7 +61,7 @@ def write(self, state: State) -> None: |
66 | 61 | except OSError as e: |
67 | 62 | logger.error("[%s] Failed to write pyproject.toml: %s", self.namespace, e) |
68 | 63 |
|
69 | | - def _update_pyproject(self, doc: Any, state: State) -> None: |
| 64 | + def _update_pyproject(self, doc: "tomlkit.TOMLDocument", state: State) -> None: |
70 | 65 | """Modify the pyproject.toml document based on mxdev state.""" |
71 | 66 | import tomlkit |
72 | 67 |
|
@@ -106,34 +101,9 @@ def _update_pyproject(self, doc: Any, state: State) -> None: |
106 | 101 | source_table = tomlkit.inline_table() |
107 | 102 | source_table.append("path", rel_path) |
108 | 103 |
|
109 | | - if install_mode in ("editable", "direct"): |
| 104 | + if install_mode == "editable": |
110 | 105 | source_table.append("editable", True) |
111 | 106 | elif install_mode == "fixed": |
112 | 107 | source_table.append("editable", False) |
113 | 108 |
|
114 | 109 | uv_sources[pkg_name] = source_table |
115 | | - |
116 | | - # 2. Add packages to project.dependencies if not present |
117 | | - if "project" not in doc: |
118 | | - doc.add("project", tomlkit.table()) |
119 | | - |
120 | | - if "dependencies" not in doc["project"]: |
121 | | - doc["project"]["dependencies"] = tomlkit.array() |
122 | | - |
123 | | - dependencies = doc["project"]["dependencies"] |
124 | | - pkg_name_pattern = re.compile(r"^([a-zA-Z0-9_\-\.]+)") |
125 | | - existing_pkg_names = set() |
126 | | - |
127 | | - for dep in dependencies: |
128 | | - match = pkg_name_pattern.match(str(dep).strip()) |
129 | | - if match: |
130 | | - existing_pkg_names.add(normalize_name(match.group(1))) |
131 | | - |
132 | | - for pkg_name, pkg_data in state.configuration.packages.items(): |
133 | | - install_mode = pkg_data.get("install-mode", "editable") |
134 | | - if install_mode == "skip": |
135 | | - continue |
136 | | - |
137 | | - normalized_name = normalize_name(pkg_name) |
138 | | - if normalized_name not in existing_pkg_names: |
139 | | - dependencies.append(pkg_name) |
0 commit comments