@@ -151,16 +151,22 @@ def on_config(self, config):
151
151
if not isinstance (loaded_configs , list ):
152
152
loaded_configs = [loaded_configs ]
153
153
154
+ # It can happen that the drive letter case is inconsistent on Windows.
155
+ # Therefore, assure first character to be uppercase for the following
156
+ # checks. See: https://t.ly/9t1SU
157
+ site_prefixes = list (map (capitalize , site .PREFIXES ))
158
+ cwd = capitalize (os .getcwd ())
159
+
154
160
# We need to make sure the user put every file in the current working
155
161
# directory. To assure the reproduction inside the ZIP file can be run,
156
162
# validate that the MkDocs paths are children of the current root.
157
- paths_to_validate = [
163
+ paths_to_validate = list ( map ( capitalize , [
158
164
config .config_file_path ,
159
165
config .docs_dir ,
160
166
abs_custom_dir ,
161
167
abs_projects_dir ,
162
168
* [cfg .get ("INHERIT" , "" ) for cfg in loaded_configs ]
163
- ]
169
+ ]))
164
170
165
171
# Convert relative hook paths to absolute path
166
172
for hook in config .hooks :
@@ -169,7 +175,7 @@ def on_config(self, config):
169
175
170
176
# Remove valid paths from the list
171
177
for path in list (paths_to_validate ):
172
- if not path or path .startswith (os . getcwd () ):
178
+ if not path or path .startswith (cwd ):
173
179
paths_to_validate .remove (path )
174
180
175
181
# Report the invalid paths to the user
@@ -191,14 +197,14 @@ def on_config(self, config):
191
197
self .excluded_entries = []
192
198
193
199
# Exclude the site_dir at project root
194
- if config .site_dir .startswith (os . getcwd () ):
200
+ if capitalize ( config .site_dir ) .startswith (cwd ):
195
201
self .exclusion_patterns .append (_resolve_pattern (config .site_dir ))
196
202
197
203
# Exclude the Virtual Environment directory. site.getsitepackages() has
198
204
# inconsistent results across operating systems, and relies on the
199
205
# PREFIXES that will contain the absolute path to the activated venv.
200
- for path in site . PREFIXES :
201
- if path .startswith (os . getcwd () ):
206
+ for path in site_prefixes :
207
+ if path .startswith (cwd ):
202
208
self .exclusion_patterns .append (_resolve_pattern (path ))
203
209
204
210
# Guess other Virtual Environment paths in case we forget to activate
@@ -209,9 +215,9 @@ def on_config(self, config):
209
215
if filename .lower () != "pyvenv.cfg" :
210
216
continue
211
217
212
- path = abs_root [ 0 ]. upper () + abs_root [ 1 :]
218
+ path = capitalize ( abs_root )
213
219
214
- if path not in site . PREFIXES :
220
+ if path not in site_prefixes :
215
221
print (f"Possible inactive venv: { path } " )
216
222
self .exclusion_patterns .append (_resolve_pattern (path ))
217
223
@@ -509,7 +515,7 @@ def _load_yaml(abs_src_path: str):
509
515
# in the pattern creation for files and directories. The patterns are matched
510
516
# using the search function, so they are prefixed with ^ for specificity.
511
517
def _resolve_pattern (abspath : str , return_path : bool = False ):
512
- path = abspath .replace (os .getcwd (), "" , 1 )
518
+ path = capitalize ( abspath ) .replace (capitalize ( os .getcwd () ), "" , 1 )
513
519
path = path .replace (os .sep , "/" ).rstrip ("/" )
514
520
515
521
if not path :
@@ -543,6 +549,11 @@ def _is_dotpath(path: str, log_warning: bool = False) -> bool:
543
549
return True
544
550
return False
545
551
552
+ # It can happen that the drive letter case is inconsistent on Windows.
553
+ # Capitalize the first character keeping the rest the same for comparison.
554
+ # See: https://t.ly/9t1SU
555
+ def capitalize (path : str ):
556
+ return path [0 ].upper () + path [1 :] if path else path
546
557
547
558
# -----------------------------------------------------------------------------
548
559
# Data
0 commit comments