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

MacOS and Windows support #397

Merged
merged 34 commits into from
Jan 8, 2024
Merged

Conversation

mknorps
Copy link
Collaborator

@mknorps mknorps commented Nov 20, 2023

Support for MacOS

To support MacOS it is enough to add macos-latest to the test matrix and allow for longer runs for tests that use --install-deps option.

Support for Windows

To support Windows we needed to:

  • change all paths to be system-agnostic (5843d1e)
  • change paths that referred to python executable, pip executable and site packages to work on all systems (36e957a, 8c4ecb9, d689171)
  • Adjust command line script that creates virtual environments for tests (73e1819)
  • Skip irrelevant tests (442db96, 3b5e3b6)
  • skip real-project tests as the test setup does not work well with Windows and we may consider adjusting the tests (03fcd44)
  • few other minor tweaks.

Issues

In the process of adjusting the code to support Windows, we discovered, that the real_projects tests setup is not suited for Windows. The fact that we use a separate virtual environment, which we construct from the command line makes it hard to work with Windows.

You may see example of such problem in this CI run. In this case, project The Algorithms-Python uses conditional requirement:

    "tensorflow; python_version < '3.11'",

This falls into undeclared dependencies on Windows for Python <=3.10. This behavior should be investigated in a separate ticket.

@mknorps mknorps force-pushed the maria/macos-and-windows-support-explorations branch from ca281ac to d551f11 Compare November 20, 2023 12:36
@mknorps mknorps force-pushed the maria/macos-and-windows-support-explorations branch 3 times, most recently from 52c2291 to 3904f1a Compare November 28, 2023 12:56
@mknorps mknorps force-pushed the maria/macos-and-windows-support-explorations branch 4 times, most recently from d529d90 to 4deb134 Compare December 21, 2023 10:17
@mknorps mknorps changed the base branch from main to 25-experiments December 21, 2023 10:18
@mknorps mknorps changed the base branch from 25-experiments to main December 21, 2023 10:18
@mknorps mknorps force-pushed the maria/macos-and-windows-support-explorations branch 3 times, most recently from 0bfbdef to 92ddf45 Compare December 21, 2023 13:43
On Windows pip and Python executable are located under venv_dir\Scripts\.
`pip_path` depends now on OS.
On Windows, Python virtual environment keeps the 3rd partiies libraries under `{venv_dir}\Lib\site-packages`. Python version is not mentioned anywhere in the directories names.
On windows, a CI runner does not have admin premissions, which are needed to delete the temporary file constructed with `NamedTemporaryFile`.
In this commit, we use Ptrhon standard library to provide sys.executable and os.devnull.
Some of the tests are irrelevant to Windows. These were mearked to be skipped when run on Windows machine.
Added one test for Windows, wchich is skipped for a non-Windows run.
This issue originates from the way we run real project tests. I included more details in the PR description.
Make all paths in the code system-agnostic. They are either build with os.path.join() or with operations on `Path` object.
…on a system

For Windows, there is several differences like remove command, creation of an empty file.

We make sure that packages are installed in the new virtual environment by running python from this virtual environment with `-m pip install`
On Windows only administrator can create symlinks. We will skip this test on windows as one of a low impact.
On Windows the ordering of logs is different.
For tests and format.
For other workflows ubuntu with fixed version is changed to `ubuntu-latest`.
@mknorps mknorps force-pushed the maria/macos-and-windows-support-explorations branch 3 times, most recently from 139a3a7 to 091abe9 Compare January 3, 2024 10:37
@mknorps
Copy link
Collaborator Author

mknorps commented Jan 3, 2024

First and foremost: I'm really impressed with this PR! 🤩 Although I am surprised that people are already using FawltyDeps on Windows with some success, it is obvious that we still have quite a lot of POSIX assumptions in our code, especially under tests/, and I'm very happy with how you have tackled this: Your PR systematically fixes everything across our (by now, quite large) codebase.

I've done a first complete pass over the PR, and added (too many, probably 😅) comments. I wasn't sure if I'd get through everything today, so I posted them as I went along. Apologies for not batching them into a single review.

Despite the number of comments, I really don't have any issues with the approach you've taken here. Most of the comments are minor niggles like using sys.platform instead of platform.system or Path() instead of os.path.join().

One thing that is becoming really apparent in this PR is that our real_projects tests need some more serious rework to work well on Windows. I think disabling these on Windows is the right way to solve this, for now. Tackling that rewrite is best done in a separate PR.

Up to you, whether you want to clean up this PR by removing the other real_projects-related changes, or leave them in. I'm happy either way.

Than you @jherland for your review and insights.

I fixed two main things you asked for - using Path instead of os.path.join and sys.platform instead of platform.system.

I would leave the real-project related challenges to another PR. I tested the Python Algorithms project that was failing in the real project tests on a Windows machine and it works.

For Windows users, I think that the most important is that when FawltyDeps looks for a mapping, it checks also virtual environment available in Windows. That is the most significant improvement in my opinion for a regular user. For a developer, we made it possible with this PR to contribute to FawltyDeps when writing code on Windows thanks to the tests refactor 🎉

@mknorps mknorps force-pushed the maria/macos-and-windows-support-explorations branch 2 times, most recently from 9e41731 to dadf267 Compare January 3, 2024 10:47
@mknorps mknorps force-pushed the maria/macos-and-windows-support-explorations branch from dadf267 to d0fb833 Compare January 3, 2024 10:48
@mknorps mknorps requested a review from jherland January 3, 2024 12:33
Copy link
Member

@jherland jherland left a comment

Choose a reason for hiding this comment

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

Still a few comments here and there, but I am happy for this to be merged after you've had a look. Feel free to push back if you feel I'm getting too nitpicky. You can always tell me to fix things myself in a later PR 😅

There's one unresolved comment from the previous round, about the delete flag to NamedTemporaryFile where I think we need to be careful to get things right. Otherwise, my comments and suggestions are mostly just matters of taste, and I'm happy to get this merged with or without addressing those.

fawltydeps/packages.py Outdated Show resolved Hide resolved
fawltydeps/types.py Outdated Show resolved Hide resolved
tests/test_cmdline.py Outdated Show resolved Hide resolved
tests/test_dir_traversal.py Outdated Show resolved Hide resolved
tests/test_dir_traversal.py Outdated Show resolved Hide resolved
tests/test_dir_traversal.py Outdated Show resolved Hide resolved
tests/test_local_env.py Outdated Show resolved Hide resolved
tests/test_local_env.py Outdated Show resolved Hide resolved
tests/utils.py Outdated Show resolved Hide resolved
tests/test_types.py Outdated Show resolved Hide resolved
mknorps and others added 2 commits January 3, 2024 18:33
Co-authored-by: Johan Herland <johan.herland@tweag.io>
@mknorps mknorps force-pushed the maria/macos-and-windows-support-explorations branch 2 times, most recently from 0eb7945 to b62885f Compare January 4, 2024 12:17
@mknorps mknorps force-pushed the maria/macos-and-windows-support-explorations branch from b62885f to f4b2a0a Compare January 4, 2024 12:23
Reorder package search conditions and simplify one for Windows to resemble one for POSIX more.
@mknorps mknorps force-pushed the maria/macos-and-windows-support-explorations branch 3 times, most recently from 31d3ba2 to fb17603 Compare January 8, 2024 10:05
@mknorps mknorps force-pushed the maria/macos-and-windows-support-explorations branch from fb17603 to e16b180 Compare January 8, 2024 11:07
This commit adds 'path_sets_equal' function that checks if <Paths> created of provided strings are equal or not
@mknorps mknorps merged commit 30cc11a into main Jan 8, 2024
65 checks passed
@mknorps mknorps deleted the maria/macos-and-windows-support-explorations branch January 8, 2024 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants