Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed paths on Windows #168

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions partcad/src/partcad/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(self, root_path=None, search_root=True):
self.current_project_path += os.path.relpath(
initial_root_path,
root_path,
)
).replace(os.path.sep, "/")
if self.current_project_path == self.name + "/.":
self.current_project_path = self.name

Expand Down Expand Up @@ -205,6 +205,10 @@ def import_project(self, parent, project_import_config):
return imported_project

def get_project_abs_path(self, rel_project_path: str):
"""
Get the full package path (not a filesystem path) of a package
given the relative path from the current package
"""
if rel_project_path.startswith("/"):
return rel_project_path

Expand All @@ -215,9 +219,7 @@ def get_project_abs_path(self, rel_project_path: str):
if rel_project_path == "":
return project_path

if not project_path.endswith("/"):
project_path += "/"
return os.path.abspath(project_path + rel_project_path)
return get_child_project_path(project_path, rel_project_path)

def get_project(self, rel_project_path: str):
project_path = self.get_project_abs_path(rel_project_path)
Expand Down
13 changes: 12 additions & 1 deletion partcad/src/partcad/runtime_python_conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,20 @@ def __init__(self, ctx, version=None):
root_prefix = info["root_prefix"]
root_bin = os.path.join(root_prefix, "bin")
root_scripts = os.path.join(root_prefix, "Scripts")
search_paths = [
root_scripts,
root_bin,
root_prefix,
]
if os.name == "nt":
search_path_strings = ";".join(search_paths)
else:
search_path_strings = ":".join(search_paths)
self.conda_path = shutil.which(
"conda", path=f"{root_scripts}:{root_bin}:{root_prefix}"
"conda",
path=search_path_strings,
)
pc_logging.error("Conda path corrected: %s" % self.conda_path)

async def run(self, cmd, stdin="", cwd=None):
with self.lock:
Expand Down
7 changes: 5 additions & 2 deletions partcad/src/partcad/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@

def get_child_project_path(parent_path, child_name):
if parent_path.endswith("/"):
return parent_path + child_name
result = parent_path + child_name
else:
return parent_path + "/" + child_name
result = parent_path + "/" + child_name

result = re.sub(r"/[^/]*/\.\.", "", result)
return result


def resolve_resource_path(current_project_name, pattern: str):
Expand Down
Loading