Repository navigation
1.0.0a0
Pre-release
Pre-release
·
34 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
Pre-release of 1.0.0. There are some big changes in this release that have been years in the making, so I'm doing a pre-release to make sure it's stable before pushing a final release. Notably:
- Dropping support for old Python versions and interpreters
- Changing how settings are handled
- Raising exceptions if getmac won't function on the system (previously,
Nonewas returned in these cases)
Please, test this release on your systems, and report back on the linked discussion!
PyPI release: https://pypi.org/project/getmac/1.0.0a0/
Added
- Rewrote documentation and published on GitHub Pages: https://ghostofgoes.github.io/getmac/index.html
- Support Python 3.10 - 3.14
- New function,
getmac.get_default_interface(), which returns the name of the system's default interface. - Support for ipaddress objects from the Python standard library:
IPv4Address,IPv4Interface,IPv6Address,IPv6Interface- These can be used with the
ipandip6arguments toget_mac_address() - The
ipargument will accept IPv6 objects and process them as ifip6was set. - If passed a string,
ipwill still treat it like a IPv4 address. This behavior may change in a future release, withipallowing either type of address, andip6argument being deprecated. IPv4NetworkandIPv6Networkwill result in aValueError. They're networks, not hosts, and passing them makes no sense.
- These can be used with the
- Handle
bytesvalues forinterface,ip,ip6, andhostnamearguments toget_mac_address(). This will just calldecode("utf-8")on the bytes. This is to ease usage with certain libraries and functions that return strings as bytes.- If you pass it some weird bytes that aren't decodable as utf-8, it's obviously going to break. Don't be dumb :)
- Added manpage for the command line interface (
getmac.1) - Improved HP-UX support
- New method,
LanscanIface, a proper implementation oflanscan -iafor HP-UX systems. This replaces the functionality of the removedUuidLanscanmethod, and is loosely based on CPython'suuid._lanscan_getnode()implementation. - Added platform detection for HP-UX
- New method,
- New setting,
settings.ARP_TIMEOUT(--arp-timeouton the command line). After sending the UDP packet to populate the ARP/NDP table, getmac keeps checking it for the host for up to this many seconds, for hosts that are slow to reply. It's off (0) by default. (Issue #101) - Windows: IPv6 lookups and finding the default interface, using
netsh.exe(new methodsNetshNeighborsandDefaultIfaceNetsh). Before, these fell back to methods for other platforms, with a "No methods for platform 'windows'" warning. (Issue #90)
Changed
- BREAKING CHANGE: refactored how settings are handled. Instead of module-level globals, they're implemented in a Settings singleton in
getmac.settings. For example,getmac.getmac.PORTshould now begetmac.settings.PORT.- NOTE: This will require code changes if your code modifies getmac settings variables
- BREAKING CHANGE:
RuntimeErroris now raised in cases where no methods are found matching the type of request and platform, or if all matching methods fail to test.- This should almost never happen unless you're on an exotic platform or have an unusual configuration, or a recent platform update changed commands such that getmac no longer functions. If you encounter a
RuntimeErrorexception, it means something went horribly wrong, and you should considor reporting the issue on GitHub.
- This should almost never happen unless you're on an exotic platform or have an unusual configuration, or a recent platform update changed commands such that getmac no longer functions. If you encounter a
- Reduce size of wheel distribution (
.whlfile). - Fixed
get_mac_address()returning an old MAC for an IP that is no longer in use on Linux. Incomplete and failed entries (Flags0x0) and proxy ARP entries (Flags0xc) in/proc/net/arpare now ignored and returnNone. Also fixed a lookup for an IP like92.168.0.1matching the entry for192.168.0.1(Issue #76). - Fixed the default interface name from
ip routeincluding extra text when the route has noprotofield, e.g.ens193 onlinkinstead ofens193fordefault via 192.168.1.254 dev ens193 onlink. - Fixed
ifconfigparsing returning a wrong MAC for some interfaces. - Fixed
ifconfigparsing on Solaris and Debian GNU/kFreeBSD, which print MACs without leading zeros (e.g.0:c:29:c1:70:2a). - Fixed the
CtypesHostmethod on Windows passing a string instead of bytes toinet_addr()when looking up a hostname. - Fixed the
FcntlIfacemethod on Linux not closing its socket after each lookup. get_mac_address()with no arguments: if the default interface can't be found (e.g. there aren't any routes) or doesn't have a MAC (e.g. a VPN tunnel), the first interface with a MAC that isn't a loopback interface is used (Issue #78).- It no longer guesses names like
eth0oren0, or returns the loopback interface's00:00:00:00:00:00. - Also helps address issue #91.
- It no longer guesses names like
- Windows:
get_mac_address()with no arguments uses the actual default interface, instead of assuming it's named "Ethernet". - Windows: interface names now must match the whole name or description (case-insensitive). Before, "Wi-Fi" could return the MAC of the "Microsoft Wi-Fi Direct Virtual Adapter".
- Windows:
GetmacExecan now find interface names >15 characters long. - Fixed
IpconfigExetaking seconds to minutes when a named interface wasn't found in certain cases. - Improved
IpconfigExeto handle non-Englishipconfigoutput, without relying on the "Physical Address" label. Interfaces are still only found by name in English output, which is a limitation that will be addressed in a future release. - Fixed interface names with characters like
(,*and.not being found (e.g.vEthernet (WSL)). - Fixed
NetstatIfacereturning the MAC of another interface. - Fixed Windows commands failing on systems where adapter names have non-English characters.
- Fixed
network_request=False(--no-net) not always preventing methods that send network requests from being used. - Fixed
FORCE_METHODset toArpingHostorCtypesHoststill sending a UDP packet before the ARP request. - Fixed a working IPv4 method being dropped when
ArpFilefails. - Fixed
ArpVariousArgsnot parsing the output of the Linuxarpcommand from thenet-toolspackage. - Fixed getmac's own
getmaccommand being run instead of Windows'getmac.exewhen getmac is installed in a virtual environment. - Fixed
IfconfigEther(macOS) runningifconfigtwice on the first lookup. - Fixed
DarwinNetworksetupIface(macOS) being marked unusable after looking up an interface that isn't a hardware port, like a VPN tunnel (Issue #91). - Python 3.13+ on Android is detected as Linux, so the Linux methods are used. The error when no methods work lists them, since the commands they use are often missing on Android (Issue #95).
Removed
- Removed support for Python 2.7 - 3.8. Most of the tooling used by getmac no longer works with 3.8 and older. If you need to use one of these versions, pin to
getmac<1.0.0. - Removed support for Jython. As of Dec 2025, Jython still does not support Python 3. If and when it supports Python 3, I'll re-add support for it.
- Removed support for IronPython. IronPython3 exists, however I don't have a way to test it in CI. If someone knows of a way to test it in GitHub actions, let me know, and I'm happy to re-add support.
- Removed RPM packaging, as it hasn't been maintained since 0.6.0.
- Removed
UuidArpGetnodemethod. It's quite slow (performs up to 3 subprocess calls internally) and the functionality is already implemented byArpVariousArgs. - Removed
UuidLanscanmethod. This has been replaced with the newLanscanIfacemethod. Some UUID internal function names changed with Python 3.9, and it made more sense to implement from scratch in getmac instead of continuing to rely on CPython-specific private functions.
Dev
- Switched to PDM for project management
- Added
pyproject.tomland consolidated the configurations for most tools- Removed
setup.py,MANIFEST.in,requirements*.txt,tox.ini
- Removed
- Switched to CodeCov from Coveralls
- Refactored source code documentation and added an API reference to the docs
- Use Ruff's formatter instead of Black and isort
- Updated development dependencies to their latest versions (pytest 8/9, Sphinx 9, mypy 2, etc.)
- Updated GitHub Actions and pinned them to commit SHAs, and added
pdm run update-actionsto update the pins. - Setup PyPI Trusted Publishing with GitHub, and added GitHub Attestations.
- CI tests on PyPy 3.10 and 3.11.
- 100% code coverage! (a significant milestone for this project)
- Added test samples from GitHub's macOS and Windows runners, collected with
scripts/collect_samples.py. - Added test samples from two third-party projects, significantly increasing test coverage. To maintain license compatibility, these samples were checked into git as-is, and are not included in the source distribution.
settingsand__version__are now published ingetmac.__all__, for type checkers.