SamuelYvon / netifaces-2

netifaces reborn
https://pypi.org/project/netifaces2/
MIT License
21 stars 7 forks source link

does the lib support in Windows 10? #21

Open echoleyo opened 7 months ago

echoleyo commented 7 months ago

Is this tested with Windows10 64bit? does it support python3.9? I have python 3.9.13 64 bit installed. the installing this lib is fine, but I can't use, when calling API it just hanging and frozen and finally got "memory allocation of 51539607552 bytes failed" error

pip install netifaces2
Looking in indexes: http://pypi.xxxx.somecompany.com/root/internal/+simple/
Requirement already satisfied: netifaces2 in c:\virtualenv\py39_13\lib\site-packages (0.0.19)
Requirement already satisfied: typing-extensions in c:\virtualenv\py39_13\lib\site-packages (from netifaces2) (4.6.3)

python
Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import netifaces
>>> netifaces.interfaces()
memory allocation of 51539607552 bytes failed

and it fail to install in python3.7.9 32 bits

pip install netifaces2
Looking in indexes: http://pypi.xxxx.somecompany.com/root/internal/+simple/
Collecting netifaces2
  Downloading http://pypi.xxxx.somecompany.com/jfrog.somecompany.com/test-pypi-prod-local/%2Bf/096/4828366650d54/netifaces2-0.0.19.tar.gz (14 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]

      Cargo, the Rust package manager, is not installed or is not on PATH.
      This package requires Rust and Cargo to compile extensions. Install it through
      the system's package manager or via https://rustup.rs/

      Checking for Rust toolchain....
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
SamuelYvon commented 7 months ago

memory allocation of 51539607552 bytes failed

Lots of bytes!

This is supposed to work on windows. I will get back to you on this within the week

SamuelYvon commented 7 months ago

@echoleyo Cannot reproduce.

Here's what I noticed from your logs:

SamuelYvon commented 7 months ago

Check on windows with python3.7, all is well.

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]

      Cargo, the Rust package manager, is not installed or is not on PATH.
      This package requires Rust and Cargo to compile extensions. Install it through
      the system's package manager or via https://rustup.rs/

      Checking for Rust toolchain....
      [end of output]

Do you have rust installed? See https://www.rust-lang.org/tools/install

echoleyo commented 7 months ago

installed rust and pip install again, still failed


pip install netifaces2
Looking in indexes: http://pypi.xxxx.somecompany.com/root/internal/+simple/
Collecting netifaces2
  Using cached http://pypi.xxxx.somecompany.com/jfrog.ford.com/test-pypi-prod-local/%2Bf/096/4828366650d54/netifaces2-0.0.19.tar.gz (14 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: typing-extensions in c:\virtualenv\py_test\lib\site-packages (from netifaces2) (4.7.1)
Building wheels for collected packages: netifaces2
  Building wheel for netifaces2 (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for netifaces2 (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [155 lines of output]
      Running `maturin pep517 build-wheel -i C:\virtualenv\py_test\Scripts\python.exe --compatibility off --target i686-pc-windows-msvc`
      ðŸ\x8d¹ Building a mixed python/rust project
      🔗 Found pyo3 bindings
      ðŸ\x90\x8d Found CPython 3.7 at C:\virtualenv\py_test\Scripts\python.exe
      📡 Using build options bindings from pyproject.toml
         Compiling proc-macro2 v1.0.70
         Compiling unicode-ident v1.0.12
         Compiling syn v1.0.109
         Compiling proc-macro-hack v0.5.20+deprecated
         Compiling pyo3-build-config v0.15.2
         Compiling once_cell v1.18.0
         Compiling winapi v0.3.9
         Compiling autocfg v1.1.0
         Compiling cfg-if v1.0.0
         Compiling parking_lot_core v0.8.6
         Compiling scopeguard v1.2.0
         Compiling unindent v0.1.11
      error: could not compile `cfg-if` (lib) due to 3 previous errors
      warning: build failed, waiting for other jobs to finish...
      error: could not compile `scopeguard` (lib) due to 17 previous errors
      💥 maturin failed
        Caused by: Failed to build a native library through cargo
        Caused by: Cargo build finished with "exit code: 101": `"cargo" "rustc" "--release" "--target" "i686-pc-windows-msvc" "--manifest-path" "C:\\Users\\myid\\AppData\\Local\\Temp\\pip-install-gn2ozisw\\netifaces2_e1adcdde8fe140d3a200cde9074852cd\\Cargo.toml" "--message-format" "json" "--lib"`
      error[E0463]: can't find crate for `core`
        |
        = note: the `i686-pc-windows-msvc` target may not be installed
        = help: consider downloading the target with `rustup target add i686-pc-windows-msvc`

      error[E0463]: can't find crate for `compiler_builtins`

      error: aborting due to 2 previous errors

      For more information about this error, try `rustc --explain E0463`.

      error[E0463]: can't find crate for `core`
        |
        = note: the `i686-pc-windows-msvc` target may not be installed
        = help: consider downloading the target with `rustup target add i686-pc-windows-msvc`

      error[E0463]: can't find crate for `compiler_builtins`

      error[E0463]: can't find crate for `core`
         --> C:\Users\myid\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scopeguard-1.2.0\src\lib.rs:192:1
          |
      192 | extern crate core as std;
          | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
          |
          = note: the `i686-pc-windows-msvc` target may not be installed
          = help: consider downloading the target with `rustup target add i686-pc-windows-msvc`

      error: cannot find macro `stringify` in this scope
         --> C:\Users\myid\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scopeguard-1.2.0\src\lib.rs:487:24
          |
      487 |         f.debug_struct(stringify!(ScopeGuard))
          |                        ^^^^^^^^^

      error: cannot find attribute `derive` in this scope
         --> C:\Users\myid\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scopeguard-1.2.0\src\lib.rs:212:3
          |
      212 | #[derive(Debug)]
          |   ^^^^^^

      error[E0405]: cannot find trait `FnOnce` in this scope
         --> C:\Users\myid\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scopeguard-1.2.0\src\lib.rs:306:8
          |
      306 |     F: FnOnce(T),
          |        ^^^^^^ not found in this scope

      error[E0405]: cannot find trait `FnOnce` in this scope
         --> C:\Users\myid\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scopeguard-1.2.0\src\lib.rs:317:8
          |
      317 |     F: FnOnce(T),
          |        ^^^^^^ not found in this scope

      error[E0405]: cannot find trait `FnOnce` in this scope
         --> C:\Users\myid\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scopeguard-1.2.0\src\lib.rs:377:8
          |
      377 |     F: FnOnce(T),
          |        ^^^^^^ not found in this scope

      error[E0405]: cannot find trait `Sync` in this scope
         --> C:\Users\myid\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scopeguard-1.2.0\src\lib.rs:435:22
          |
      435 | unsafe impl<T, F, S> Sync for ScopeGuard<T, F, S>
          |                      ^^^^ not found in this scope

      error[E0405]: cannot find trait `Sync` in this scope
         --> C:\Users\myid\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scopeguard-1.2.0\src\lib.rs:437:8
          |
      437 |     T: Sync,
          |        ^^^^ not found in this scope

      error[E0405]: cannot find trait `FnOnce` in this scope
         --> C:\Users\myid\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scopeguard-1.2.0\src\lib.rs:438:8
          |
      438 |     F: FnOnce(T),
          |        ^^^^^^ not found in this scope

      error[E0405]: cannot find trait `FnOnce` in this scope
         --> C:\Users\myid\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scopeguard-1.2.0\src\lib.rs:445:8
          |
      445 |     F: FnOnce(T),
          |        ^^^^^^ not found in this scope

      error[E0405]: cannot find trait `FnOnce` in this scope
         --> C:\Users\myid\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scopeguard-1.2.0\src\lib.rs:457:8
          |
      457 |     F: FnOnce(T),
          |        ^^^^^^ not found in this scope

      error[E0405]: cannot find trait `Drop` in this scope
         --> C:\Users\myid\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scopeguard-1.2.0\src\lib.rs:465:15
          |
      465 | impl<T, F, S> Drop for ScopeGuard<T, F, S>
          |               ^^^^ not found in this scope

      error[E0405]: cannot find trait `FnOnce` in this scope
         --> C:\Users\myid\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scopeguard-1.2.0\src\lib.rs:467:8
          |
      467 |     F: FnOnce(T),
          |        ^^^^^^ not found in this scope

      error[E0405]: cannot find trait `FnOnce` in this scope
         --> C:\Users\myid\.cargo\registry\src\index.crates.io-6f17d22bba15001f\scopeguard-1.2.0\src\lib.rs:483:8
          |
      483 |     F: FnOnce(T),
          |        ^^^^^^ not found in this scope

      error: aborting due to 16 previous errors

      Some errors have detailed explanations: E0405, E0463.

      For more information about an error, try `rustc --explain E0405`.

      Error: command ['maturin', 'pep517', 'build-wheel', '-i', 'C:\\virtualenv\\py_test\\Scripts\\python.exe', '--compatibility', 'off', '--target', 'i686-pc-windows-msvc'] returned non-zero exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for netifaces2
Failed to build netifaces2
ERROR: Could not build wheels for netifaces2, which is required to install pyproject.toml-based projects
SamuelYvon commented 7 months ago

Can you run rustup target add i686-pc-windows-msvc and retry? Thanks

echoleyo commented 7 months ago

installation is fine now, but when calling the method, get same error when running from python 3.9.13 64bit


(py_test) C:\Users\myid\Downloads>rustup target add i686-pc-windows-msvc
info: downloading component 'rust-std' for 'i686-pc-windows-msvc'
info: installing component 'rust-std' for 'i686-pc-windows-msvc'
 19.7 MiB /  19.7 MiB (100 %)   8.4 MiB/s in  2s ETA:  0s

(py_test) C:\Users\myid\Downloads>pip install netifaces2
Looking in indexes: http://pypi.xxxx.somecompany.com/root/internal/+simple/
Collecting netifaces2
  Using cached http://pypi.xxxx.somecompany.com/jfrog.ford.com/test-pypi-prod-local/%2Bf/096/4828366650d54/netifaces2-0.0.19.tar.gz (14 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: typing-extensions in c:\virtualenv\py_test\lib\site-packages (from netifaces2) (4.7.1)
Building wheels for collected packages: netifaces2
  Building wheel for netifaces2 (pyproject.toml) ... done
  Created wheel for netifaces2: filename=netifaces2-0.0.19-cp37-none-win32.whl size=123884 sha256=1bb636545eec5a84c8da5ae9a9c11deae9967c8db744a5d2b83917779f46e6aa
  Stored in directory: c:\users\myid\appdata\local\pip\cache\wheels\22\8f\8d\63af1729a1a28b8616d8756ab56a5deca8751aafd9e6170227
Successfully built netifaces2
Installing collected packages: netifaces2
Successfully installed netifaces2-0.0.19

(py_test) C:\Users\myid\Downloads>python
Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:01:55) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> import netifaces
>>> netifaces.interfaces()
memory allocation of 1610612736 bytes failed
SamuelYvon commented 7 months ago

Ok interesting. Must be something related to the way the network interfaces are fetched on windows and your specific hardware. On windows, the information is retrieved through IpHelper, the windows lib for the networking interfaces. I will get back to you with a set of commands to try

echoleyo commented 6 months ago

any updates?

SamuelYvon commented 6 months ago

No, sorry, haven't gotten the time to get to it.

SamuelYvon commented 6 months ago

@echoleyo Alright! Sorry for the delay. Can you please do the following:

And let me know the output :)

echoleyo commented 5 months ago

cargo run
   Compiling windows_x86_64_msvc v0.42.2
   Compiling windows v0.42.0
   Compiling win_ip_helper v0.1.0 (C:\Users\yli278\dev\netifaces-2\win_ip_helper)
    Finished dev [unoptimized + debuginfo] target(s) in 14.20s
     Running `target\debug\win_ip_helper.exe`
To get the adapter's table, 5680 bytes are required, or 8 structures.
SamuelYvon commented 5 months ago

Well that seems like a reasonable amount to me! Will make sure the code is synced. with what is in the wheel and publish a wheel tomorrow or later today.

echoleyo commented 5 months ago

sounds good, I can test the wheel before you publishing if you want


From: Samuel Yvon @.> Sent: January 2, 2024 12:14 PM To: SamuelYvon/netifaces-2 @.> Cc: echoleyo @.>; Mention @.> Subject: Re: [SamuelYvon/netifaces-2] does the lib support in Windows 10? (Issue #21)

Well that seems like a reasonable amount to me! Will make sure the code is synced. with what is in the wheel and publish a wheel tomorrow or later today.

— Reply to this email directly, view it on GitHubhttps://github.com/SamuelYvon/netifaces-2/issues/21#issuecomment-1874308800, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADIDAF5NCD2HVMICKWJEKJTYMQ56XAVCNFSM6AAAAABAAIBK6CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZUGMYDQOBQGA. You are receiving this because you were mentioned.Message ID: @.***>

SamuelYvon commented 5 months ago

Youll find the wheels here https://github.com/SamuelYvon/netifaces-2/actions/runs/7240437956

SamuelYvon commented 5 months ago

@echoleyo I've merged my changes, should be deployed soon

echoleyo commented 5 months ago

Sounds great, thank you


From: Samuel Yvon @.> Sent: January 7, 2024 11:05 AM To: SamuelYvon/netifaces-2 @.> Cc: echoleyo @.>; Mention @.> Subject: Re: [SamuelYvon/netifaces-2] does the lib support in Windows 10? (Issue #21)

@echoleyohttps://github.com/echoleyo I've merged my changes, should be deployed soon

— Reply to this email directly, view it on GitHubhttps://github.com/SamuelYvon/netifaces-2/issues/21#issuecomment-1880099278, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADIDAFYDXPAZO346G4YGMLTYNLBT3AVCNFSM6AAAAABAAIBK6CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBQGA4TSMRXHA. You are receiving this because you were mentioned.Message ID: @.***>

SamuelYvon commented 5 months ago

@echoleyo Let me know if it is fixed on your side

echoleyo commented 5 months ago

it eats my memory when running it



________________________________
From: Samuel Yvon ***@***.***>
Sent: January 9, 2024 12:02 PM
To: SamuelYvon/netifaces-2 ***@***.***>
Cc: echoleyo ***@***.***>; Mention ***@***.***>
Subject: Re: [SamuelYvon/netifaces-2] does the lib support in Windows 10? (Issue #21)

@echoleyo<https://github.com/echoleyo> Let me know if it is fixed on your side

—
Reply to this email directly, view it on GitHub<https://github.com/SamuelYvon/netifaces-2/issues/21#issuecomment-1883439427>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ADIDAFYORHZTYTFJSU6NBB3YNVZ3PAVCNFSM6AAAAABAAIBK6CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBTGQZTSNBSG4>.
You are receiving this because you were mentioned.
SamuelYvon commented 5 months ago

Can you clarify what you mean by eating memory?? It should use some but not crash and it should return it

echoleyo commented 5 months ago

the console is frozen and memory are all eventually occupied by running method (netifaces.interfaces()), and my pc got very slow down. did you see the attached screenshot? attached again


From: Samuel Yvon @.> Sent: January 9, 2024 1:49 PM To: SamuelYvon/netifaces-2 @.> Cc: echoleyo @.>; Mention @.> Subject: Re: [SamuelYvon/netifaces-2] does the lib support in Windows 10? (Issue #21)

Can you clarify what you mean by eating memory?? It should use some but not crash and it should return it

— Reply to this email directly, view it on GitHubhttps://github.com/SamuelYvon/netifaces-2/issues/21#issuecomment-1883600692, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADIDAF2ATB2TDJR4EZI742TYNWGMDAVCNFSM6AAAAABAAIBK6CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBTGYYDANRZGI. You are receiving this because you were mentioned.

SamuelYvon commented 5 months ago

No, no screenshot is attached :(

echoleyo commented 5 months ago

console_log mem1 proc

SamuelYvon commented 5 months ago

This is worse than what you had before. Quite annoying.

I'll investigate once I get to a windows pc again

echoleyo commented 5 months ago

Any new solution?

SamuelYvon commented 5 months ago

I haven't had the chance to look into it due to family matters. I will take a look again; I'm confused why your PC specifically causes issue, as I've tested it on multiple computers now.

echoleyo commented 5 months ago

Thanks I will try install and run on other PCs, see if I can reproduce the same issue, and I also noticed that default_gateways() not working in Windows, do you have a plan to fix that, that's the major API I will use.

SamuelYvon commented 5 months ago

It's not implemented on windows; also coming

echoleyo commented 4 months ago

Thanks I will try install and run on other PCs, see if I can reproduce the same issue, and I also noticed that default_gateways() not working in Windows, do you have a plan to fix that, that's the major API I will use.

I tested other 4 PCs (Win10), on Python 3.9.13 64bit, 4 can install successfully, 2 PCs run netifaces.interfaces() successfully, other 2 fail to run and get the issue

echoleyo commented 4 months ago

another issue is that I failed to install netifaces2 in 3.9.13 32 bit


pip install netifaces2
Looking in indexes: http://xxxxxx
Collecting netifaces2
  Downloading http://xxxxxx/xxxxx.com/test-pypi-prod-local/%2Bf/25e/87c02af32bb94/netifaces2-0.0.21.tar.gz (18 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]

      Cargo, the Rust package manager, is not installed or is not on PATH.
      This package requires Rust and Cargo to compile extensions. Install it through
      the system's package manager or via https://rustup.rs/

      Checking for Rust toolchain....
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
SamuelYvon commented 4 months ago

@echoleyo On the machine where it does not work, can you repeat this step? https://github.com/SamuelYvon/netifaces-2/issues/21#issuecomment-1859248299