Skip to content

Commit 07fcabf

Browse files
authored
Merge pull request #65 from GhostofGoes/refactor
Refactor for 0.9.0
2 parents 25c7152 + 4e64fb3 commit 07fcabf

File tree

125 files changed

+5617
-1582
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+5617
-1582
lines changed

.coveragerc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Temporary hack until we remove shutilwhich with removal of Python 2
2+
# TODO: move relative_files into tox.ini
3+
[run]
4+
relative_files = True
5+
omit =
6+
getmac/shutilwhich.py

.gitattributes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
*.md text eol=lf
77

88
# Samples
9-
tests/samples/windows*/*.out text eol=crlf
9+
tests/samples/**/*.out text eol=lf
1010
tests/samples/*.out text eol=lf
11+
tests/samples/windows*/*.out text eol=crlf
1112

1213
# Windows
1314
*.ps1 text eol=crlf
@@ -16,7 +17,6 @@ tests/samples/*.out text eol=lf
1617
# POSIX
1718
*.sh text eol=lf
1819
*.bash text eol=lf
19-
.travis-osx text eol=lf
2020
*.1 text eol=lf
2121
packaging/*.spec text eol=lf
2222
Makefile text eol=lf

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ A clear and concise description of what you expected to happen.
1515

1616
**System info**
1717
(please complete the following information):
18-
- OS name: [e.g. Windows 10 x64]
19-
- OS Version: [1804 build 17134]
20-
- Python version: [3.6.5 x64]
18+
- OS name (e.g. Windows 10 x64):
19+
- OS Version (e.g. 1804 build 17134):
20+
- Python version (e.g. CPython 3.6.5 x64):
21+
- getmac version (e.g. getmac 0.8.3):
2122

2223
**Additional context**
2324
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_allowed: true
2+
contact_links:
3+
- name: Have a general question or comment?
4+
url: "https://github.com/GhostofGoes/getmac/discussions"
5+
about: Open a discussion thread!

.github/pull_request_template.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
### All Submissions:
22

3-
* [ ] Have you followed the guidelines in our Contributing document?
4-
* [ ] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change?
5-
* [ ] Have you added an explanation of what your changes do and why you'd like us to include them?
3+
- [ ] Have you followed the guidelines in our Contributing document?
4+
- [ ] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change?
5+
- [ ] Have you added an explanation of what your changes do and why you'd like us to include them?
66

77
<!-- You can erase any parts of this template not applicable to your Pull Request. -->
88

99
### Code changes:
1010

11-
* [ ] Did you format your code with Black?
12-
* [ ] `black getmac tests`
13-
* [ ] Are the linting checks passing?
14-
* [ ] `tox -e check`
15-
* [ ] Do all tests pass locally?
16-
* [ ] `tox`
17-
* [ ] Have you updated the [CHANGELOG](CHANGELOG.md) with a summary of your change?
18-
* [ ] Did you add your name to the contributors list in the [README](README.md)?
11+
- [ ] Did you format your code with Black?
12+
- `black getmac tests`
13+
- [ ] Are the linting checks passing?
14+
- `tox -e check`
15+
- [ ] Do all tests pass locally?
16+
- `tox`
17+
- [ ] Have you updated the [CHANGELOG](CHANGELOG.md) with a summary of your change?
18+
- [ ] Did you add your name to the contributors list in the [README](README.md)?
1919

2020
### Summary of changes:
21-
*
21+
-

.github/workflows/ci.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: CI
2+
3+
on:
4+
- release
5+
- push
6+
- pull_request
7+
8+
jobs:
9+
lint:
10+
name: Run lint checks
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: actions/setup-python@v3
15+
with:
16+
python-version: "3.8"
17+
- name: Install tox
18+
run: python -m pip install tox
19+
- name: Run lint checks
20+
run: tox -e check
21+
test:
22+
name: Run tests
23+
runs-on: ${{ matrix.platform }}
24+
strategy:
25+
fail-fast: false
26+
# Versions available:
27+
# pypy: https://downloads.python.org/pypy/versions.json
28+
# Python: https://github.com/actions/python-versions/blob/main/versions-manifest.json
29+
# Additional info: https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md
30+
# OS images: https://github.com/actions/runner-images
31+
matrix:
32+
python-version:
33+
- "2.7"
34+
- "3.5"
35+
- "3.6"
36+
- "3.7"
37+
- "3.8"
38+
- "3.9"
39+
- "pypy-2.7"
40+
- "pypy-3.6"
41+
- "pypy-3.7"
42+
- "pypy-3.8"
43+
- "pypy-3.9"
44+
architecture:
45+
- x86
46+
- x64
47+
platform:
48+
- ubuntu-20.04
49+
- windows-latest
50+
- macos-latest
51+
exclude:
52+
- platform: ubuntu-20.04
53+
architecture: x86
54+
- platform: macos-latest
55+
architecture: x86
56+
- platform: ubuntu-20.04
57+
python-version: "3.4"
58+
- platform: macos-latest
59+
python-version: "3.4"
60+
- platform: macos-latest
61+
python-version: "pypy-2.7"
62+
- platform: macos-latest
63+
python-version: "pypy-3.6"
64+
- platform: macos-latest
65+
python-version: "pypy-3.7"
66+
- platform: macos-latest
67+
python-version: "pypy-3.8"
68+
- platform: windows-latest
69+
python-version: "pypy-2.7"
70+
steps:
71+
- uses: actions/checkout@v3
72+
- uses: actions/setup-python@v3
73+
with:
74+
python-version: ${{ matrix.python-version }}
75+
architecture: ${{ matrix.architecture }}
76+
- name: Display platform and environment information
77+
run: |
78+
python --version
79+
python -c "import sys; print('sys.version: %s' % str(sys.version))"
80+
python -c "import sys; print('sys.platform: %s' % str(sys.platform))"
81+
python -c "import os; print('os.name: %s' % str(os.name))"
82+
python -c "import platform; print('platform.uname(): %s' % str(platform.uname()))"
83+
- name: Install dependencies
84+
run: python -m pip install tox coveralls tox-gh-actions
85+
# TODO: fix benchmark results (maybe a separate Job?)
86+
- name: Run tests
87+
run: tox
88+
- uses: codecov/codecov-action@v2
89+
with:
90+
fail_ci_if_error: true
91+
- name: Coveralls
92+
if: ${{ matrix.platform == 'ubuntu-20.04' && github.event_name != 'pull_request' }}
93+
uses: AndreMiras/coveralls-python-action@develop
94+
with:
95+
parallel: true
96+
flag-name: ${{ matrix.python-version }}-${{ matrix.platform }}
97+
coveralls_finish:
98+
needs: test
99+
runs-on: ubuntu-20.04
100+
steps:
101+
- name: Coveralls Finished
102+
if: ${{ github.event_name != 'pull_request' }}
103+
uses: AndreMiras/coveralls-python-action@develop
104+
with:
105+
parallel-finished: true
106+
107+
108+
# TODO: publish
109+
# TODO: need to do this for both "getmac" and "get-mac" packages
110+
# TODO: don't publish pre-releases OR publish them as pre-releases to PyPI
111+
112+
# https://github.com/marketplace/actions/upload-a-build-artifact
113+
114+
# name: "Build and publish a release"
115+
116+
# on:
117+
# release:
118+
# types: [released]
119+
120+
# jobs:
121+
# publish:
122+
# name: "📦 Publish Python distributions"
123+
# runs-on: "ubuntu-20.04"
124+
# strategy:
125+
# matrix:
126+
# python-version:
127+
# - "3.8"
128+
# steps:
129+
# - uses: "actions/checkout@master"
130+
# - name: "🐍 Set up Python ${{ matrix.python-version }}"
131+
# uses: "actions/setup-python@v2"
132+
# with:
133+
# python-version: "${{ matrix.python-version }}"
134+
# - name: "🐍 Install wheel"
135+
# run: "python -m pip install wheel --user"
136+
# - name: "🐍 Build a binary wheel and a source tarball"
137+
# run: "python setup.py sdist bdist_wheel"
138+
# - name: "📦 Publish distribution to PyPI"
139+
# uses: "pypa/gh-action-pypi-publish@master"
140+
# if: "startsWith(github.ref, 'refs/tags')"
141+
# with:
142+
# password: "${{ secrets.pypi_password }}"

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ on:
2323
jobs:
2424
analyze:
2525
name: Analyze
26-
runs-on: ubuntu-latest
26+
runs-on: ubuntu-20.04
2727
permissions:
2828
actions: read
2929
contents: read
@@ -42,7 +42,7 @@ jobs:
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v1
45+
uses: github/codeql-action/init@v2
4646
with:
4747
languages: ${{ matrix.language }}
4848
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -53,7 +53,7 @@ jobs:
5353
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5454
# If this step fails, then you should remove it and run the build manually (see below)
5555
- name: Autobuild
56-
uses: github/codeql-action/autobuild@v1
56+
uses: github/codeql-action/autobuild@v2
5757

5858
# ℹ️ Command-line programs to run using the OS shell.
5959
# 📚 https://git.io/JvXDl
@@ -67,4 +67,4 @@ jobs:
6767
# make release
6868

6969
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v1
70+
uses: github/codeql-action/analyze@v2

.travis.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,62 @@
33
**NOTE**: if any changes significantly impact your project or use case, please open an issue on [GitHub](https://github.com/GhostofGoes/getmac/issues) or email me (see git commit author info for address).
44

55

6-
## NEXT (XX/XX/XXXX)
7-
* TBD
6+
## 0.9.0 (01/23/2023)
7+
**Announcement**: Compatibility with Python versions older than 3.6 (2.7, 3.4, and 3.5) is deprecated and will be removed in getmac 1.0.0. If you are stuck on an unsupported Python, considor loosely pinning the version of this package in your dependency list, e.g. `getmac<1`.
8+
9+
This release is a *complete rewrite of getmac from the ground up*. The public API of `getmac` is **unchanged** as part of this rewrite. `get_mac_address()` is still the primary way of getting a MAC address, it's just the "under the hood" internals that have changed completely.
10+
11+
It's passing tests and seems to be operable. However, with a change this large there are ineviteably issues that the tests or I don't catch, so I'm doing a series of pre-releases until I'm 99% confident in it's stability. Refer to `docs/rewrite.md` for a in-depth explanation of the rewrite changes.
12+
13+
The new system has a number of benefits
14+
- Reduction of false-positives and false-negatives by improving method selection accuracy (platform, validity, etc.)
15+
- *Significantly* faster overall
16+
- "Misses" have the same performance as "Hits"
17+
- Easier to test, since each method can be tested directly via it's class
18+
- Easier to type annotate and analyze with mypy
19+
- Easier to read, improving reviewability and ease of contributing for newcomers
20+
- Extensible! Custom methods can be defined and added at runtime (which is perfect if you have some particular edge case but aren't able to open-source it).
21+
22+
### Added
23+
* Fully support Python 3.9 (automated tests in CI)
24+
* Tentatively support Python 3.10 and 3.11 (unable to test due to the need to be able to still test 2.7)
25+
* Added default interface detection for MacOS (command: `route get default`)
26+
* Added initial support for Solaris/SunOS. There were a few existing methods that worked as-is, so just added indicators that those methods support `sunos` (Which applies to any system where `platform.system() == SunOS`).
27+
* `arping` (POSIX) or `SendARP` (Windows) will now *always* be used instead of sending a UDP packet when looking for the MAC of a IPv4 host, if they're available and operable (otherwise, UDP + ARP table check will be used like before).
28+
* The amount of time taken to get a result (in seconds) will now be recorded and logged if debugging is enabled (`DEBUG>=1` or `-d`)
29+
* Added command line argument to override the UDP port for network requests: `--override-port` (this was already possible in Python via `getmac.getmac.PORT`, but wasn't configurable via the CLI. Now it is!).
30+
* Added ability to override the detected platform via `--override-platform` argument (CLI) or `getmac.getmac.OVERRIDE_PLATFORM` variable (Python). This will force methods for that platform to be used, regardless of the actual platform. Here's an example forcing `linux` to be used as the platform: `getmac -i eth0 --override-platform linux`. In version 1.0.0, this feature will added as an argument to `get_mac_address()`.
31+
* Added ability to force a specific method to be used via `--force-method` argument (CLI) or `getmac.getmac.FORCE_METHOD` variable (Python). This is useful for troubleshotting issues, general debugging, and testing changes. Example: `getmac -v -dddd --ip 192.168.0.1 --force-method ctypeshost`
32+
33+
### Changed
34+
* **Complete rewrite of `getmac` from the ground up. Refer to `docs/rewrite.md` for a in-depth explanation of the rewrite changes**
35+
* Fixed a failure to look up a hostname now returns `None`, as expected, instead of raising an exception (`socket.gaierror`).
36+
* Fixed numerous false-negative and false-positive bugs
37+
* Improved overall performance
38+
* Performance for cases where no MAC is found is now the same as cases where a MAC is found (speed of "misses" now equals that of "hits")
39+
* Improved the reliability and performance of many methods
40+
* Fixed `netstat` on older Linux distros (such as Ubuntu 12.04)
41+
* Overhauled `ifconfig` parsing. It should now be far more reliable and accurate across all platforms.
42+
* Improved Android support. Note that newer devices are locked down and the amount of information that's obtainable by an unprivileged process is quite limited (Android 7/9 and newer, not sure exactly when they changed this, I'm not an Android guy). That being said, the normal Linux methods should work fine, provided you have the proper permissions (usually, `root`).
43+
* Fixed bug with `/proc/net/route` parsing (this affected Android and potentially other platforms)
44+
* Improve default interface detection for FreeBSD (command: `route get default`)
45+
46+
### Removed
47+
* Removed man pages from distribution (`getmac.1`/`getmac2.1`). They were severely out of date and unused. May re-add at a later date.
48+
49+
### Dev
50+
* Migrate CI to GitHub Actions, remove TravisCI and Appveyor
51+
* Add flake8 plugins: `flake8-pytest-style` and `flake8-annotations`
52+
* Add additional samples and tests for WSL1 (with the Ubuntu 18.04 distro)
53+
* Add additional samples for Windows 10
54+
* Add additional samples for MacOS
55+
* Add samples and tests for Ubuntu 12.04
56+
* Add samples for NetBSD 8 (support coming in a future release)
57+
* Add samples for Solaris 10 (support TBD)
58+
* Add samples for several versions of Android
59+
* Add new tests
60+
* Improve existing tests
61+
* Consolidate everything related to RPM packaging to `packaging/rpm/`. This stuff hasn't been updated since 0.6.0, may remove in the future and leave distro packaging to distro maintainers.
862

963

1064
## 0.8.3 (12/10/2021)

0 commit comments

Comments
 (0)