Portable network interface information
Project description
netifaces (2)
1. What is this?
The original netifaces was abandonned by it's maintainer, leaving us without the option to get network addresses of any kind in Python. Unfortunately, the original sources are more akin to arcane magic, so picking where it's been left off is a difficult task.
I decided to rewrite netifaces
, keeping the almost exact same API and adding the following:
- Support for future python versions
- Type annotations
- Maybe a more "queriable" API in the future
This project aims to be a drop-in replacement for those project who use netifaces
, but I do not
guarantee anything.
1.1 What is not working right-now
- The
gateways
API is only working if your system has a/proc/net/route
file or theip
tool - The
windows
gateways API is non-functional
2. Usage
For now the API is the same as the original netifaces
, so please refer to it.
Install:
pip install netifaces2
Import:
>>> import netifaces
>>> netifaces.interfaces()
...
>>> netifaces.ifaddresses('en0')
...
>>> netifacs.gateways()
...
3. API differences between this and al45tair/netifaces
gateways
The gateways
function does not support indexing through the default
special key. This is because it makes a
sane typing definition difficult to write and be understandable. Instead, if you want the same functionality,
the following is exposed:
>>> netifaces.default_gateway()
...
The result will be the default gateway for each interface type. The result may be an empty dict if no default route is set.
The level of completness differs a little bit with the original version; some
address families might not yet be available and PEER
addresses are not
reported for now. If you need a feature, open an issue and I will do my best to
add it.
Gateways also returned the interfaces indexed by integer values. This is a bit
odd (IMO) since the integers values for the interface types are
system-dependent. Enum values with a more semantic meaning are now used (they
are still tied to linux numbers), but you can use old_api=True
in
their call to get the al45air-style keys back.
AF_
Constants
In the previous version of netifaces
the AF_
constants' value were assigned
to be platform independent. This has the nice effect of abstracting the OS when
accessing the information of a network layer. However after consideration, it
does not feel like the right place to provide abstraction. If you update your
project's dependencies to this version of netifaces
, be wary of this change.
For instance, on linux you may need to replace AF_LINK
with AF_PACKET
to get
mac addresses.
In the future, an extra API will allow accessing a specific layer's information by querying for it, without using the platform's constant.
4. Platform support
Wheels
Building Linux, Windows and macOS cp37-abi3 wheels (requires Python 3.7 and newer)
Install using pip:
python -m pip install netifaces2
Linux
Linux cp37-abi3 wheels are built on manylinux2_17 aka manylinux2014 and require pip>=19.3
cp36m-manylinux2_17 wheels are unsupported and are being built only as a fallback
for systems with only Python 3.6 available.
5. License
This software is distributed under a MIT license.
6. Developing Locally
To set up for local development, you will first need to install Rust from rustup.
It's then recommended to create a virtual environment and install the package plus its dependencies into it:
$ python3 -m venv venv
$ source venv/bin/activate (or .\venv\Scripts\activate.ps1 with Windows Powershell)
$ python3 -m pip install -e '.[dev]' # This internally runs the Rust compiler
$ python3 -m pip install pre-commit
$ source venv/bin/activate # Re-source the venv to pick up new scripts
$ pre-commit install
To recompile the rust code after making changes, run:
$ python3 -m pip install -e .
again.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file netifaces2-0.0.22.tar.gz
.
File metadata
- Download URL: netifaces2-0.0.22.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c872a54e1a0e2bf078593b4460013996de804e40cab1b0ebc377b0e74b52a244 |
|
MD5 | c613c5945171e57b8da3813f2583f6b9 |
|
BLAKE2b-256 | 19408818b20a921c39fc6d6a508f180b9ae97e35b90a8d8b91d64db54f625225 |
File details
Details for the file netifaces2-0.0.22-cp37-abi3-win_amd64.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp37-abi3-win_amd64.whl
- Upload date:
- Size: 138.1 kB
- Tags: CPython 3.7+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c31ef56334aa73d0cb81d49e7a9bc3cdd8822e566594038b76c27eaf0334ea6d |
|
MD5 | a4a13b2c87e001ee13724c52b7a94a77 |
|
BLAKE2b-256 | dfc05b5c33aae4d07a4292bc6c4159222d04a1dbc4907d20863a8800e6f20ffd |
File details
Details for the file netifaces2-0.0.22-cp37-abi3-musllinux_1_1_x86_64.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp37-abi3-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.7+, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a203a34be5976a747777add600d3d9942bd87b8252bbb7d250273ec4f23744f4 |
|
MD5 | 20c54caf3b6a50c59b33ff84f67b4609 |
|
BLAKE2b-256 | 6e55290a663e7334cce09d87e70d7c162e9141fe9ea7eb0861594ec3774babe4 |
File details
Details for the file netifaces2-0.0.22-cp37-abi3-musllinux_1_1_i686.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp37-abi3-musllinux_1_1_i686.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.7+, musllinux: musl 1.1+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db607a05fa9e7b4791649b83bdc260dcc2f1082e502e6c9e22eb3853a5ff1485 |
|
MD5 | 7c1bf989067ad370d94000ca22880cf5 |
|
BLAKE2b-256 | 155154ecfb98ccacad6ff9353c3267bdea60e2cd27179440f00dc25e76b51486 |
File details
Details for the file netifaces2-0.0.22-cp37-abi3-musllinux_1_1_armv7l.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp37-abi3-musllinux_1_1_armv7l.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.7+, musllinux: musl 1.1+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03151c24171e6da9079e5abcd303f3e0d8ac275a8fe4e178f82fdf1590f989e4 |
|
MD5 | 0136f8eb19789432a55332fb65b5aaa8 |
|
BLAKE2b-256 | 527a63c6607f5b12c2367d8bc37025bde067ec8eecad9b97c8d8c39eadd1411b |
File details
Details for the file netifaces2-0.0.22-cp37-abi3-musllinux_1_1_aarch64.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp37-abi3-musllinux_1_1_aarch64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.7+, musllinux: musl 1.1+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e24c4089c743ad61c59e988d2c2de9ba2c91f1dccaecd57cf1d03c4414946a8f |
|
MD5 | 2919c8db13fc8d3c0ccbe5f56cb8d777 |
|
BLAKE2b-256 | 77883e250f667ae24f8e30a651a938a27d8281e6e3c818b70e1151ba6a25654d |
File details
Details for the file netifaces2-0.0.22-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 043ddcd4b09f9b8e86c2bd54214a90904c2fec8869d0cfd295c671c2f4cb27b3 |
|
MD5 | 0e63c6d26fa38a31c3b3bbe32bab6512 |
|
BLAKE2b-256 | d4e9fcbf4c0e84037e072364696927e6e12d78ce69c93eaaf9b382b8655bbdc8 |
File details
Details for the file netifaces2-0.0.22-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69689cf211d17968e020582ddf3b023b0b956c003571e088a86ad21e27b678d9 |
|
MD5 | c18ecef4b82ef864d4fe60403f207aef |
|
BLAKE2b-256 | 0e56f9ef7fcfa04ed4dcf0a5b631f82d131ddc9fe3df7c457a52f20fb21e0682 |
File details
Details for the file netifaces2-0.0.22-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0f59974328a3481eb0b3264a1cb479f2058cc8f09a3a0097a24d306fd59ec5e |
|
MD5 | 539e05c8a5276c97ddf305e9422a96d7 |
|
BLAKE2b-256 | 83a2a534c8362e8ac9c23497496eef39f193de37c1e10b3781bc5b3d54f9893e |
File details
Details for the file netifaces2-0.0.22-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp37-abi3-manylinux_2_17_ppc64.manylinux2014_ppc64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ppc64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47d15b7235804e4b506298d757856c97e9d969be9cf91642581bf314f98cdefa |
|
MD5 | 7e6d6af0ac3541e90757731c5e74a39f |
|
BLAKE2b-256 | e5e3c6b0840e163d2b97e49029d90674eeb1cd41308bc47acae7f27906e28ec5 |
File details
Details for the file netifaces2-0.0.22-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 150804d34f1a97d07ec7032573561267e1753c30670df5e32021a2cf4e3f76b5 |
|
MD5 | c11a4c677e08edde23ec8fbad81e1df7 |
|
BLAKE2b-256 | b2f1acf33b20232e4bceb838712ab42294d1a4a658f4ed1d4176596ea8d2d5db |
File details
Details for the file netifaces2-0.0.22-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1393ddecc35fcbb5ca89c90783ef44c1cae3f93b60bbdcb2e2ebd20783b9e06 |
|
MD5 | 34f2e3fa4b4c1ce613f1819bd054e9d6 |
|
BLAKE2b-256 | 361d4dfb25228d9047ae9bc2f72f14260ffdc6a72b436dc1af6c954e50d45cce |
File details
Details for the file netifaces2-0.0.22-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f6fa1ca50ede5d148a9c378ab08e093418666b58353a2fe31b02d772f568231 |
|
MD5 | a4c0657cf109f534048599a795719e9b |
|
BLAKE2b-256 | bacb78613bbabe140763fa5ffb9e9098c35c74440b091a21025ad4acc8e6c2a4 |
File details
Details for the file netifaces2-0.0.22-cp37-abi3-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp37-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 251.0 kB
- Tags: CPython 3.7+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b7073aabee570466373e312b7f92a81e669f2462051eaefafb8a3d9ba078a35 |
|
MD5 | 3ee2827e9ff590d9c56617d568204057 |
|
BLAKE2b-256 | 9f8adce8b32aad8d2d338c75590656c270214a89d7a41df9b8b936d0c5d31438 |
File details
Details for the file netifaces2-0.0.22-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.6m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb4ac86acfe2f23522c2b5d1bed097e810dbbe4a5bd829528e5db52a83290e52 |
|
MD5 | 57d66976057d3b99afa749e9dd521a82 |
|
BLAKE2b-256 | 9bd01488316a79bf66c3c614b9790265393f41bce72d1cc4bd9e2d759bca4de1 |
File details
Details for the file netifaces2-0.0.22-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.6m, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9a880fd3fe76bc5fb040ccafee40f752300ef6349fd7c4c6e66151763b224f8 |
|
MD5 | 9608e789ce8698f88c8ef790a6b31174 |
|
BLAKE2b-256 | 6cdfe211e1286f9c81bfbd6df04ef576b9e78d627499df64ec3c18ba1ebbebb0 |
File details
Details for the file netifaces2-0.0.22-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.6m, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81bf88e39ced999d66fff6db5c0dd70c532af18558b3e37da7cda70b6a52f842 |
|
MD5 | 7b09d53f2877297a58101b5fd4254f6b |
|
BLAKE2b-256 | 7d95a7b6d8c13bf8db3ec8dac46b1250fa36b9e7fce8ebfcde7d1ae255e7ae31 |
File details
Details for the file netifaces2-0.0.22-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: netifaces2-0.0.22-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.6m, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7bd4e11cb72d3c182b0b532a5c39d3945a35258cdade2ebaac55ab8ff3ba0e6 |
|
MD5 | 7ccfd4ac16ed7897f0505e64ca7ba831 |
|
BLAKE2b-256 | f04f15c985e5260e5efc13e4642d5641c45dfbdacf4536d8d5c1201ce647e19f |