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

conf-python-3 + Cygwin(mingw64) + opam 2.2.x = "python3: command not found" #26434

Open
tahina-pro opened this issue Aug 26, 2024 · 4 comments
Open
Assignees

Comments

@tahina-pro
Copy link
Contributor

If, after removing any python3.exe in Windows' PATH, I try opam install conf-python-3 with the mingw64 compilers, either from a full-fledged Cygwin environment, or from a Windows opam with its own copy of Cygwin (under C:\Users\...\AppData\Local\opam\.cygwin\root), then Cygwin python3 installs successfully, but then opam fails with:

#=== ERROR while compiling conf-python-3.9.0.0 ================================#
"python3": command not found.

By contrast, if I install Windows (not Cygwin) Python 3.x "by hand", then opam install conf-python-3 succeeds. But that may not be the result I want, because if I then install an opam package such as z3.4.8.5-1, it fails to compile because of directory separators: \ with Windows Python, but I expect Cygwin / because I expect to compile z3.4.8.5-1 with the Cygwin mingw64 compilers.

Is this related to #26130 ? Thank you in advance @UnixJunkie , @dra27 for clarifying!

Output of opam var os: win32
Output of opam var os-distribution: cygwin

Output of opam config report:

# opam config report
# opam-version         2.2.1
# self-upgrade         no
# system               arch=x86_64 os=win32 os-distribution=cygwin os-version=10.0.22621
# solver               builtin-mccs+glpk
# install-criteria     -removed,-count[avoid-version,changed],-count[version-lag,request],-count[version-lag,changed],-count[missing-depexts,changed],-changed
# upgrade-criteria     -removed,-count[avoid-version,changed],-count[version-lag,solution],-count[missing-depexts,changed],-new
# jobs                 13
# repositories         1 (http) (default repo at e89899ac28c3c15f5a5ba4b01d63a5646a1f8a5d)
# pinned               0
# current-switch       default
# invariant            ocaml >= 4.05.0
# compiler-packages    arch-x86_64.1, conf-mingw-w64-gcc-x86_64.1, flexdll.0.43, mingw-w64-shims.0.2.0, ocaml-base-compiler.5.2.0, ocaml-env-mingw64.1, ocaml-options-vanilla.1, system-mingw.1
# mingw-w64-shims:runtime-x86_64 C:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin
# mingw-w64-shims:runtime-i686
# ocaml:native         true
# ocaml:native-tools   true
# ocaml:native-dynlink true
# ocaml:stubsdir       C:/Users/taramana/AppData/Local/opam/default/lib/ocaml/stublibs;C:/Users/taramana/AppData/Local/opam/default/lib/ocaml
# ocaml:preinstalled   false
# ocaml:compiler       5.2.0
@tahina-pro
Copy link
Contributor Author

I suspect one possible reason may be that opam install is not running with a "full Cygwin PATH environment" such as the one that bash --login would provide. More precisely, python3 should be found as /usr/bin/python3 (a symlink to /etc/alternatives/python3, which is itself a symlink to python), but is not.

@UnixJunkie
Copy link
Contributor

I know nothing about windows, and would not be able to test anything related to it. If you have a suggestion to fix this package, it is welcome and others will review it.

@dra27 dra27 self-assigned this Aug 27, 2024
@dra27
Copy link
Member

dra27 commented Aug 27, 2024

This doesn't have an easy solution, I'm afraid. There are two parts to it:

  • The package installation failure I think - as you suggest - is related to symlink problems, but possibly also to an issue with .exe searching in PATH in opam at the moment.
  • The problem on the z3 side may need some work with Z3 itself - it would be a lot better if the "Windows" build of Z3 is able to cope with both Python-for-Windows (backslashes) and Python-for-Cygwin (forward-slashes), but there's some more nuance and incentive for sorting that. If opam installs Cygwin's python to it's internal installation, then it's only available during package builds - i.e. not from the Command Prompt or PowerShell instance which ran opam.

@anmaped
Copy link

anmaped commented Oct 14, 2024

@dra27

  • it seems to be just a symbolic link issue (the same happens with bash.exe);

  • I've tried, but the paths of the z3 build scripts need to be “quoted” for the path conversion to take place, and some other commands like copy need to be replaced by cp.

Ugly workaround for Windows compilation using github actions

  buildonwindows:
    name: Build on windows
    runs-on: windows-latest
    steps:
      - name: Checkout tree
        uses: actions/checkout@v2

      - name: Set-up OCaml
        uses: ocaml/setup-ocaml@v3
        with:
          ocaml-compiler: 4

      - run: $env:Path = 'D:\cygwin\bin;' + $env:Path; setx /m PATH "$env:PATH"
      - run: opam install conf-python-3
      - run: opam exec -- python3 --version
      - run: cp D:\cygwin\bin\python3.9.exe D:\cygwin\bin\python3.exe
      - run: opam exec -- python3 --version
      - run: ls D:\cygwin ; ls D:\cygwin\bin ; $env:Path
      - run: opam install . --with-test

First shows python version 3.9.13 (windows), then 3.9.16 (cygwin).

May it helps someone.

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

No branches or pull requests

9 participants
@UnixJunkie @dra27 @anmaped @tahina-pro and others