pyca / pynacl

Python binding to the Networking and Cryptography (NaCl) library
https://pynacl.readthedocs.io/
Apache License 2.0
1.06k stars 233 forks source link

Can't install/compile on Windows Server 2019 using PyPy #672

Closed sergeyklay closed 3 years ago

sergeyklay commented 3 years ago

Hello,

PyNaCl can't be compiled on Windows Server 2019 using PyPy. I created a repo with simple GitHub Actions Workflow to demonstrate the issue. Everything is OK with Python 3.6 - 3.10 but installation fails on PyPy 7.3.5 (Python Python 3.7.10).

Screenshot 2021-06-07 at 15 41 54

PyNaCl's setup.py says:

Exception: ERROR: The 'make' utility is missing from PATH

here https://github.com/pyca/pynacl/blob/9d7509e4c4867bfbd9b6d5fd6de78a07780b7d7a/setup.py#L157-L160

However, GNU Make 4.2.1 is installed on the system, as you can see from the output of these steps: https://github.com/sergeyklay/pynacl-windows-install-issue/blob/6a2b2f9d061e2c3b33101e28494c06d349981bbc/.github/workflows/ci.yml#L51-L57

> Run (Get-Command make).Path
C:\ProgramData\Chocolatey\bin\make.exe

> Run make --version
GNU Make 4.2.1
Built for x86_64-w64-mingw32
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
sergeyklay commented 3 years ago

I copied current which function used in PyNaCl and ran it separately, with some modifications:

import os

def which(name, flags=os.X_OK):  # Taken from pynacl's setup.py
    result = []
    exts = filter(None, os.environ.get("PATHEXT", "").split(os.pathsep))
    path = os.environ.get("PATH", None)
+     print(f'[DEBUG] current path is {path}')
    if path is None:
        return []
    for p in os.environ.get("PATH", "").split(os.pathsep):
        p = os.path.join(p, name)
        if os.access(p, flags):
+             print(f'[DEBUG] found (1) {name}: {p}')
            result.append(p)
        for e in exts:
            pext = p + e
            if os.access(pext, flags):
+                 print(f'[DEBUG] found (2) {name}: {pext}')
                result.append(pext)

    return result

+ result = which('make')
+ print(f'result = {result}')

Bellow is the code from GitHub Actions Workflow:

      - name: Find make
        run: (Get-Command make).Path

      - name: Show make version
        run: make --version

      - name: Search make using Python code
        run: python searchmake.py

And the output:

Screenshot 2021-06-07 at 15 34 35

However, which function could not find the make executable:

result = []
alex commented 3 years ago

I guess this needs to also search for make.exe on windows, not just make.

On Mon, Jun 7, 2021 at 8:39 AM Serghei Iakovlev @.***> wrote:

I copied current which function used in PyNaCl https://github.com/pyca/pynacl/blob/main/setup.py#L71 and ran it separately, with some modifications:

import os

def which(name, flags=os.X_OK): # Taken from pynacl's setup.py result = [] exts = filter(None, os.environ.get("PATHEXT", "").split(os.pathsep)) path = os.environ.get("PATH", None)+ print(f'[DEBUG] current path is {path}') if path is None: return [] for p in os.environ.get("PATH", "").split(os.pathsep): p = os.path.join(p, name) if os.access(p, flags):+ print(f'[DEBUG] found (1) {name}: {p}') result.append(p) for e in exts: pext = p + e if os.access(pext, flags):+ print(f'[DEBUG] found (2) {name}: {pext}') result.append(pext)

return result
  • result = which('make')+ print(f'result = {result}')

Bellow is the code from GitHub Actions Workflow https://github.com/sergeyklay/pynacl-windows-install-issue/blob/master/.github/workflows/ci.yml :

  - name: Find make
    run: (Get-Command make).Path

  - name: Show make version
    run: make --version

  - name: Search make using Python code
    run: python searchmake.py

And the output: [image: Screenshot 2021-06-07 at 15 34 35] https://user-images.githubusercontent.com/1256298/121017489-00643d80-c7a6-11eb-8afe-2fcdab3c3931.png

However, which function could not find the make executable:

result = []

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pyca/pynacl/issues/672#issuecomment-855889585, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAGBF3D3IM4NZK47ANSH3TRS4XJANCNFSM46G7PWSA .

-- All that is necessary for evil to succeed is for good people to do nothing.

sergeyklay commented 3 years ago

I guess this needs to also search for make.exe on windows, not just make.

This is done by current implementation of PyNaCl's which:

# PATHEXT stores '.EXE;.COM;' and so on
exts = filter(None, os.environ.get("PATHEXT", "").split(os.pathsep))

    # ...

    for p in os.environ.get("PATH", "").split(os.pathsep):
        p = os.path.join(p, name)

        # ...

        for e in exts:
            pext = p + e  # <- here 
            # ...

Full code is: https://github.com/pyca/pynacl/blob/9d7509e4c4867bfbd9b6d5fd6de78a07780b7d7a/setup.py#L71-L85