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

relpath error with differing path roots #260

Open
BrianPugh opened this issue Jan 19, 2025 · 0 comments
Open

relpath error with differing path roots #260

BrianPugh opened this issue Jan 19, 2025 · 0 comments

Comments

@BrianPugh
Copy link

BrianPugh commented Jan 19, 2025

Extending conversation from python-poetry/poetry#10028

With Poetry 2.0, on windows Github Action, there's an unhandled exception when path is on mount 'C:', start on mount 'D:'. I'm not sure if this is a user (poetry) issue or an installer issue.

Full stack trace here, abbreviated to the important bits below:

  5  ~\poetry\venv\lib\site-packages\poetry\installation\wheel_installer.py:109 in install
      107|             )
      108| 
    > 109|             install(
      110|                 source=source,
      111|                 destination=destination,

  4  ~\poetry\venv\lib\site-packages\installer\_core.py:131 in install
      129| 
      130|     written_records.append((root_scheme, RecordEntry(record_file_path, None, None)))
    > 131|     destination.finalize_installation(
      132|         scheme=root_scheme,
      133|         record_file_path=record_file_path,

  3  ~\poetry\venv\lib\site-packages\installer\destinations.py:278 in finalize_installation
      276| 
      277|         record_list = list(records)
    > 278|         with construct_record_file(record_list, prefix_for_scheme) as record_stream:
      279|             self.write_to_fs(
      280|                 scheme, record_file_path, record_stream, is_executable=False

  2  ~\poetry\venv\lib\site-packages\installer\utils.py:211 in construct_record_file
      209|     writer = csv.writer(stream, delimiter=",", quotechar='"', lineterminator="\n")
      210|     for scheme, record in records:
    > 211|         writer.writerow(record.to_row(prefix_for_scheme(scheme)))
      212|     stream.seek(0)
      213|     return stream.detach()

  1  ~\poetry\venv\lib\site-packages\installer\destinations.py:271 in prefix_for_scheme
      269|             if file_scheme == scheme:
      270|                 return None
    > 271|             path = os.path.relpath(
      272|                 self.scheme_dict[file_scheme],
      273|                 start=self.scheme_dict[scheme],

  ValueError

  path is on mount 'C:', start on mount 'D:'

  at C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\ntpath.py:703 in relpath
      699|         path_abs = abspath(normpath(path))
      700|         start_drive, start_rest = splitdrive(start_abs)
      701|         path_drive, path_rest = splitdrive(path_abs)
      702|         if normcase(start_drive) != normcase(path_drive):
    > 703|             raise ValueError("path is on mount %r, start on mount %r" % (
      704|                 path_drive, start_drive))
      705| 
      706|         start_list = [x for x in start_rest.split(sep) if x]
      707|         path_list = [x for x in path_rest.split(sep) if x]

This points to this bit of code. An easy fix would be the following, but I'm unfamiliar with the broader implications:

        def prefix_for_scheme(file_scheme: str) -> Optional[str]:
            if file_scheme == scheme:
                return None
            try:
                path = os.path.relpath(
                    self.scheme_dict[file_scheme],
                    start=self.scheme_dict[scheme],
                )
            except ValueError:
                path = os.path.abspath(self.scheme_dict[file_scheme])
            return path + "/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant