Giter Site home page Giter Site logo

Comments (7)

RoliSoft avatar RoliSoft commented on July 19, 2024

Hi,

It seems I forgot that Python under Cygwin uses /cygdrive/ for paths, not the Windows version.

I will need to check for this and handle the paths accordingly.

In the meantime, you won't be able to do anything with the scripts under Cygwin. If you're eager, you could try the official Windows version of Python 3.

from wsl-distribution-switcher.

RoliSoft avatar RoliSoft commented on July 19, 2024

Seems like this has more challenges than just the correct path handling. A few crucial Windows-specific calls are missing from Cygwin's Python that are otherwise present in the Windows distribution. For example, ctypes.windll for __stdcall-ing the ntfsea library functions is missing, only ctypes.cdll is present with the __cdecl calling convention. Other than that, simple things such as sys.getwindowsversion() or os.getenv('LocalAppData') are missing, or don't return the expected value.

from wsl-distribution-switcher.

Efreak avatar Efreak commented on July 19, 2024

There is no winreg package in cygwin's* python. There is a cygwinreg available for installing via pip, however installing it doesn't help, even if I swap utils.py:8 to import cygwinreg.

It should be fairly simple to get around some of the mentioned issues;

  • sys.getwindowsversion()
    • cmd.exe /c ver
    • systeminfo.exe | grep OS
    • python: platform.system()
  • os.getenv('LocalAppData')
    • cmd.exe /c echo %LocalAppData%
    • python: os.getenv('LOCALAPPDATA')
  • import winreg
    • /proc/registry (read-only)
    • regedit.exe file.reg (requires a .reg file)
    • reg.exe query /?, reg.exe add /?, reg flags /?

* I'm actually using babun, but it uses uses the same setup.ini to download the same binaries as setup.exe.

from wsl-distribution-switcher.

RoliSoft avatar RoliSoft commented on July 19, 2024

Thank you for taking the time and contributing solutions. I've made some progress over the weekend, but didn't have time to finish it yet.

For future reference, there are a few better solutions, such as fallback to cygwinreg:

try:
    import _winreg
except:
    import cygwinreg

And as for handling paths and expanding such variables, cygpath is a really useful command that comes preinstalled with Cygwin.

I'm not using babun, however, as far as I know it is based on Cygwin and should not deviate so hard that the script would not. Should babun not work when the Cygwin support comes out, please open a separate ticket, so I can take a look at it.

I'm trying to support most scenarios Windows users could be running a Python script under.

from wsl-distribution-switcher.

RoliSoft avatar RoliSoft commented on July 19, 2024

Well, cygwinreg does not support Python 3, so that solution is completely out.

Otherwise all other issues are fixed, and the script would be ready to go.

from wsl-distribution-switcher.

RoliSoft avatar RoliSoft commented on July 19, 2024

1036f15 adds support for Cygwin, however, it does not work yet.

Cygwin has a weird permission mapping scheme[1][2], which requires permissions to be completely reset before Windows can access any files or directories created.

Although running icacls rootfs-temp /t /reset fixes this after the fact, while the extraction is happening, the NTFS Extended Attributes writer library has no access to the files, and as such the extracted files have no extended attributes.

This is a pretty annoying issue, it would be really nice if I could temporarily turn off this Windows-breaking permission mapping scheme. Alternatively, I'll most likely delay the attribute restoration part, however, this requires significant design changes on my part.

from wsl-distribution-switcher.

RoliSoft avatar RoliSoft commented on July 19, 2024

1036f15 fixes the permission issue.

One more issue left: on WSL versions before Windows interoperability, the hook scripts won't run as the output cannot be piped into Mintty. The user will just get " r r o r : 0 x 8 0 0 7 0 0 5 7".

Otherwise, the WSL installation is working. On Insider previews, the hook scripts will work as well.

from wsl-distribution-switcher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.