Coder Social home page Coder Social logo

netifaces-2's Introduction

Hello! 👋

I currently work as a software developer at Garda World, where I do a bunch of things, mainly related to integrating artificial intelligence to embedded systems.

I was previously an embedded software developer working on the Microchip PIC platform at M3 Solutions.

I am mainly a systems developer; I do not touch web applications very often. GNU/Linux user.

I'm interested in a large amount of things. From my time in university, I got hooked on graph theory, low level programming and compilation of dynamically-typed languages.

Outside of coding, I'm what some would call a coffee geek and I enjoy strategy games.

Publications & Projects

  • [2021] A Small Scheme VM, Compiler, and REPL in 4K (Samuel Yvon, Marc Feeley)

  • [2020] 4-cop-win graphs have at least 19 vertices (Jérémie Turcotte, Samuel Yvon)

  • [2020] Running Scheme on bare-metal (experience report) (Samuel Yvon, Marc Feeley)

    • In proceedings of the Scheme Workshop held at ICFP 2020 (I do not know why it's not on the ACM website)
    • Available on arxiv
    • Presentation available on youtube
    • Github Repository

Presentations

You can find some presentations I did (french and english) on my youtube channel. One is also linked on the ACM website

Programming skillset

These days I mostly code in Python. I'm still using C for personal projects and I am currently learning Rust like everyone else. As long as I don't do JavaScript or Typescript, I'm happy. I have also done lots of (old) Java and Groovy.

netifaces-2's People

Contributors

alfrisch avatar martinhoyer avatar relativityspace-jsmith avatar samuelyvon avatar selfisekai avatar selimb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

netifaces-2's Issues

AF_PACKET confusion

On some OSes (BSD IIRC) AF_LINK is used for the link layer. On linux, this is exposed through AF_PACKET. The previous netifaces corrected the values based on OS. I am not sure whether to use the same approach of monkeypatching the values based on the platform here, or to create a new, more explicit interface.

Changelogs beyond 0.0.16

The Github releases page stops at 0.0.16, but there is a version 0.0.21. I can't see a changelog describing what's new in the subsequent releases.

Binaries for MIPSEL

Hello, I have a hard time (cross)compiling this library to mips 32bit little endian, is it possible you can provide those as well?

Can't install on FreeBSD 14 due to missing methods

I tried to install via pip and ran into a problem on FreeBSD:

Compiling netifaces v0.1.0 (/tmp/pip-install-dyyhyxi9/netifaces2_a4e6ec59b8ba427f8cc87b285b0ddf70)
      error[E0599]: no method named `as_netlink_addr` found for union `SockaddrStorage` in the current scope
        --> src/linux.rs:82:49
         |
      82 |                 if let Some(net_link) = address.as_netlink_addr() {
         |                                                 ^^^^^^^^^^^^^^^ help: there is a method with a similar name: `as_link_addr`

      error[E0599]: no method named `as_vsock_addr` found for union `SockaddrStorage` in the current scope
        --> src/linux.rs:87:51
         |
      87 |                 if let Some(vsock_addr) = address.as_vsock_addr() {
         |                                                   ^^^^^^^^^^^^^ help: there is a method with a similar name: `as_link_addr`

      error[E0599]: no method named `as_alg_addr` found for union `SockaddrStorage` in the current scope
        --> src/linux.rs:96:49
         |
      96 |                 if let Some(alg_addr) = address.as_alg_addr() {
         |                                                 ^^^^^^^^^^^ method not found in `SockaddrStorage`

After commenting out the lines following configstarget_os = "macos" (what is not good for macos is also not good for freebsd :p ), the result is

//#[cfg(not(any(target_os = "ios", target_os = "macos")))]
//if let Some(net_link) = address.as_link_addr() {
//    add_to_types_mat(AF_NETLINK, net_link, name, &mut types_mat, &mut any);
//}

and everything is fine. Maybe not the right way.

My "build" config is

export CARGO_BUILD_TARGET=x86_64-unknown-freebsd
export RUSTUP_HOME=~/.rustup
export CARGO_HOME=~/.cargo
export PATH=$CARGO_HOME/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

Logging settings should not be changed on import

netifaces2 calls logging.basicConfig on import here. That will interfere with log setup by the application. Note that logging.basicConfig does nothing the second time it is called, so if an application uses logging.basicConfig for its own logging setup and switches from netifaces to netifaces2, it will silently break the logging setup.

Removed option '--universal2' breaks wheel support for Apple Silicon (Mac OS X arm64)

After removing '--universal2' in CI.yml (commit 05921cf) the build generates only x86 Mac OS X wheels.

      with:
        command: build
-       args: --release -o dist --universal2
+       args: --release -o dist

from pypi.org:
Version 0.0.19: netifaces2-0.0.19-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Version 0.0.21: netifaces2-0.0.21-cp37-abi3-macosx_10_12_x86_64.whl
Version 0.0.22: netifaces2-0.0.22-cp37-abi3-macosx_10_12_x86_64.whl

Import name is the same as netifaces classic

This package uses the netifaces package name. This makes it impossible to have both netifaces classic (TM) and netifaces-2 installed in the same environment. Or rather, pip will happily install both of them, but their files will overlap, making it very difficult to tell which version you even are using.

Would it be possible to rename the import name to netifaces_2 or such? I think that would make things a little more sane. And since this library doesn't exactly maintain 1:1 compatibility anyway (e.g. you cannot pass socket.AF_INET to netifaces), I feel like it's reasonable to expect people to change the package name in their code when upgrading, as they will likely have to change other stuff as well.

does the lib support in Windows 10?

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.

Wheels currently being built

README states that minimal python version is 3.5, but no cp35 or cp36 wheels are being built or at least are not available on PyPI.
This results in netifaces2 not being able to be installed on el7 and el8 (python3.6):

  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /root/tst/bin/python3 /root/tst/lib64/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-aby0ur0d/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'maturin>=0.13,<0.14'
       cwd: None
  Complete output (2 lines):
  ERROR: Could not find a version that satisfies the requirement maturin<0.14,>=0.13 (from versions: 0.7.1, 0.7.2, 0.7.6, 0.7.7, 0.7.8, 0.7.9, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.9.0, 0.9.1, 0.9.4, 0.10.0, 0.10.2, 0.10.3, 0.10.4, 0.10.5, 0.10.6, 0.11.0, 0.11.1, 0.11.2, 0.11.3, 0.11.4, 0.11.5, 0.12.0, 0.12.1, 0.12.2, 0.12.3, 0.12.4, 0.12.5, 0.12.6, 0.12.7, 0.12.8, 0.12.9, 0.12.10, 0.12.11, 0.12.12, 0.12.13, 0.12.14, 0.12.15, 0.12.16, 0.12.17, 0.12.18b1, 0.12.18b2, 0.12.18, 0.12.19, 0.12.20)
  ERROR: No matching distribution found for maturin<0.14,>=0.13

Perhaps it would be good to start using cibuildwheel to avoid headaches and also start using manylinux_2_28 (build manylinux2014 only for cp36).

I can try to help with this if you want? :)

Type information mismatch

In the rust library the netmask is called "mask" and so it's passed to Python that way, but the Python type definition has Literal["netmask"] instead.

I propose you change Literal["netmask"] to Literal["mask"] to not break existing scripts, thanks.

(This is a deviation from the old netifaces package BTW)

Is ipv6 not implemented?

my test provides only the ipv4 gateway.
the old netifaces also returned the ipv6 gateway

import netifaces
print(netifaces.gateways())
{<InterfaceType.AF_INET: 2>: [('192.168.10.1', 'eth0', True)]}

also instead of <InterfaceType.AF_INET: 2> should be a simple 2 like in the return of

print(netifaces.ifaddresses('eth0'))
{2: [{'addr': '192.168.10.4', 'broadcast': '192.168.10.255', 'mask': '255.255.255.0'}],... and so on

i clearly have an ipv6 default route

ip -6 route
default via fe80::1eed:6fff:fe2d:91b4 dev eth0 proto ra metric 202 mtu 1492 pref medium

Way to access an interface's Name or Index on Windows

Hello! I'm the dev of multicast_expert, a library that provides multicast socket functionality in Python. My library can't work without netifaces, because to do multicast subscribes you need to enumerate the interfaces on the machine and you often need to convert between an interface's index and its IP address (as there is zero consistency between the different OSs' methods of multicast subscriptions).

I've been a bit worried about the netifaces situation, so I am really grateful that you have picked up this library and are modernizing it as well. I'm working on porting multicast_expert over to use it.

However, I did run into a bit of an issue on Windows with interface indexes. On Windows, you need the interface index in order to use the IPV6_MULTICAST_IF socket option. With netifaces 1, I was getting the interface index by passing the interface's name (actually some sort of GUID) to GetAdapterIndex. Annoying to set up, but it worked. However, it looks like in netifaces2, you return the description of the interface as its name instead of the actual name field. This is much better for user experience, but breaks the method I was using.

Would it be possible to either:

  • Provide a way to get the UUID (the IP_ADAPTER_INFO Name field) from Python on Windows, so I can restore my old hack
  • Or, provide an API on all platforms to get the interface index for an interface?

The second one seems like the better option overall but I understand it would be a bit more work, so I'd really be fine with either. If you can fix this, I should be able to update multicast_expert to use netifaces2 instead of netifaces!

"default" gateways key is missing (compared to legacy netifaces package)

code that worked with legacy package:

gws = netifaces.gateways()
default_gw_iface = gws["default"][netifaces.AF_INET][1]
default_iface_ips = netifaces.ifaddresses(default_gw_iface)[netifaces.AF_INET]
grains["primary_ipv4"] = default_iface_ips[0]["addr"]

error we get

File "test.py", line xxx, in functionname
    default_gw_iface = gws["default"][netifaces.AF_INET][1]
KeyError: 'default'

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.