-
Notifications
You must be signed in to change notification settings - Fork 7
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
windows fix #22
base: master
Are you sure you want to change the base?
windows fix #22
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #22 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 7
Lines 350 348 -2
Branches 79 60 -19
=========================================
- Hits 350 348 -2 ☔ View full report in Codecov by Sentry. |
6a4c859
to
851febc
Compare
@andhus #4 this is a draft on how to fix the windows compatibility (partially reverting/optimizing #11 ) i've set 5 tests to skip on Windows and adjusted some literals to be os agnostic feel free to comment/adjust |
@andhus could you please create a new release of the dirhash soon? currently there is a conflicting requirement of pathspec in scantree vs dirhash
|
...which might fix the cross-environment issues? See: andhus/scantree#22
Oh, yes (!) I missed this one: https://github.com/andhus/scantree/blame/c50ed7dc85f30b2a9bcad2965e867087555cf29d/setup.py#L27 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff @frichtarik, thanks!
Please see a few small comments/questions.
tests/test_node.py
Outdated
import pytest | ||
|
||
from scantree import CyclicLinkedDir, DirNode, LinkedDir, RecursionPath | ||
from scantree.test_utils import get_mock_recursion_path | ||
|
||
|
||
def create_basic_entries(local_path): | ||
def create_basic_entries(local_path: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a str
, but a py.path.local
gotten via the tmpdir
fixture https://docs.pytest.org/en/6.2.x/tmpdir.html#the-tmpdir-fixture. The type hint here is misleading since local_path.join
would do something very different if local_path
is a string :)
(We should actually use the newer tmp_path fixture everytwhere, but in a separate PR!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted
d1 = local_path.join("d1") | ||
d1.mkdir() | ||
f1 = local_path.join("f1") | ||
f1.write("file1") | ||
local_path.join("ld1").mksymlinkto(d1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this broken somehow (on windows)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Just curious)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, i had to even try it on Win machine, that method is not present for some reason, so I've switched to os independent approach
tests/test_path.py
Outdated
@@ -1,4 +1,4 @@ | |||
from os import scandir | |||
from os import name, scandir, symlink |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detail (!) but feels a bit unnecessary to have a module-level variable named just name
:) Maybe just import os
and use os.name
etc. for these, or from os import name as os_name
, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, same for path >>os_path
tests/test_path.py
Outdated
@@ -8,18 +8,19 @@ | |||
from scantree.test_utils import assert_dir_entry_equal | |||
|
|||
|
|||
def create_basic_entries(local_path): | |||
def create_basic_entries(local_path: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a str
see previous comment. (Would be great with type annotations, but in a separate PR :))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted
@@ -163,6 +165,7 @@ def rp(relative): | |||
tree_empty_false_expected = DirNode(path=rp("")) | |||
assert tree_empty_false == tree_empty_false_expected | |||
|
|||
@pytest.mark.skipif(os.name == "nt", reason="Windows runs too slow for set limits") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, can take a look at this separately.
@@ -4,20 +4,37 @@ | |||
from ._path import DirEntryReplacement, RecursionPath | |||
|
|||
|
|||
def convert_path(path: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I guess we could have replaced the plain string paths with os.path.join(...)
as well, but this works well 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, but it was not sure it will work for already complete paths stored as strings
src/scantree/test_utils.py
Outdated
("inode", {}), | ||
]: | ||
] | ||
if os.name != "nt": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I guess it is expected and that stat should be ignore in Windows https://stackoverflow.com/a/34572372
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While at it, could you please update _path.DirEntryReplacement.__eq__
to ignore stat
as well in the comparison?
Yes, will update those after the merge of this PR 👍 |
sorry for the delay, I got to switch employer i |
Would the lack of this PR be why using this in two WSL environments seems not to work at all? Dirhashes seem to be always different across the environments (each is pointing at a Windows drive, e.g.: |
@@ -1,12 +1,7 @@ | |||
exclude: "src/scantree/_version.py" | |||
repos: | |||
- repo: https://github.com/pre-commit/mirrors-prettier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed mirrors-prettier as the repo got deprecated (underlying prettier changes breaking the project altogether)
It took longer than expected, but i'm finally done |
@andhus how does it look with the merging? |
this switches posix.DirEntry to os. DirEntry, which is os-independent proxy as suggested by https://docs.python.org/3/library/posix.html#module-posix
adding windows image to the GH workflow matrix
limiting codecov publisher step to one job from the matrix, no need to republish the same comment too many times