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

windows fix #22

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

windows fix #22

wants to merge 6 commits into from

Conversation

frichtarik
Copy link
Contributor

@frichtarik frichtarik commented Apr 17, 2024

  • 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

@codecov-commenter
Copy link

codecov-commenter commented Apr 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (50b35fe) to head (f0a4386).
Report is 2 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

@frichtarik frichtarik marked this pull request as draft April 17, 2024 12:51
@frichtarik frichtarik force-pushed the windows_fix branch 13 times, most recently from 6a4c859 to 851febc Compare April 22, 2024 13:30
@frichtarik frichtarik marked this pull request as ready for review April 22, 2024 13:41
@frichtarik
Copy link
Contributor Author

@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
this causes tests to pass, circumventing some Windows peculiars, for the price of decreasing coverage (not sure why as that should be counted on Linux environment)

feel free to comment/adjust

@frichtarik
Copy link
Contributor Author

frichtarik commented Apr 22, 2024

@andhus could you please create a new release of the dirhash soon? currently there is a conflicting requirement of pathspec in scantree vs dirhash

  • with the renaming of workflow, job names changed and now PR expects 6 non-existing checks to finish

bossanova808 added a commit to bossanova808/repository.bossanova808 that referenced this pull request Apr 22, 2024
...which might fix the cross-environment issues?
See: andhus/scantree#22
@andhus
Copy link
Owner

andhus commented Apr 23, 2024

@andhus could you please create a new release of the dirhash soon? currently there is a conflicting requirement of pathspec in scantree vs dirhash

Oh, yes (!) I missed this one: https://github.com/andhus/scantree/blame/c50ed7dc85f30b2a9bcad2965e867087555cf29d/setup.py#L27

@andhus
Copy link
Owner

andhus commented Apr 23, 2024

⬆️ https://github.com/andhus/dirhash-python/releases/tag/v0.4.0

Copy link
Owner

@andhus andhus left a 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.

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):
Copy link
Owner

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!)

Copy link
Contributor Author

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)
Copy link
Owner

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)?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Just curious)

Copy link
Contributor Author

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

@@ -1,4 +1,4 @@
from os import scandir
from os import name, scandir, symlink
Copy link
Owner

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?

Copy link
Contributor Author

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

@@ -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):
Copy link
Owner

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 :))

Copy link
Contributor Author

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")
Copy link
Owner

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:
Copy link
Owner

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 👍

Copy link
Contributor Author

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

("inode", {}),
]:
]
if os.name != "nt":
Copy link
Owner

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

Copy link
Owner

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?

@andhus
Copy link
Owner

andhus commented Apr 23, 2024

with the renaming of workflow, job names changed and now PR expects 6 non-existing checks to finish

Yes, will update those after the merge of this PR 👍

@frichtarik
Copy link
Contributor Author

sorry for the delay, I got to switch employer i am was working for and switch dev machine 🤦
after last fixes, there is one test that fails on LIN but not WIN, going to fix that later today and we should be good to go

@bossanova808
Copy link

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.: /mnt/e/Git/Kodi/repository.bossanova808

@@ -1,12 +1,7 @@
exclude: "src/scantree/_version.py"
repos:
- repo: https://github.com/pre-commit/mirrors-prettier
Copy link
Contributor Author

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)

@frichtarik
Copy link
Contributor Author

It took longer than expected, but i'm finally done

@racinmat
Copy link

racinmat commented Jul 9, 2024

@andhus how does it look with the merging?

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

Successfully merging this pull request may close these issues.

None yet

5 participants