Replace pkg_resources usage with importlib.metadata.#315
Conversation
| __version__ = 'unset' | ||
| except (ImportError, OSError): | ||
| __version__ = 'unset' | ||
| from superflore.version import VERSION |
There was a problem hiding this comment.
This convoluted indirection was an attempt to work around local import trouble with the RepoInstance. It may be we don't need the superflore.version module if the tests are better behaved in general than they are in my local workspace.
There was a problem hiding this comment.
Unfortunately, the unit tests aren't well behaved. They don't cover OpenEmbedded and the Gentoo support is working but showing it's age.
I did run the following as a test:
sed -i "s/lunar/noetic/g" tests/test_ebuild.py tests/test_generate_installers.py tests/ebuild/simple_expected.ebuild
python -m unittest tests.test_ebuild
python -m unittest tests.test_generate_installers
as well as this to do some limited testing on the new version changes:
python -m unittest tests.test_utils
This seems sufficient for now.
1e557a3 to
4ea3897
Compare
|
Thanks @nuclearsandwich for tackling this. It seems that the new lines have a new Flake8 error: It seemed to be happy with this modification: In addition to removing the extra line at the end of version.py. |
pkg_resources is only used to fetch and provide the current superflore version. In fact, there's very little need to parse this version at all (which would also require adding the `packaging` module as a dependency. Instead of parsing the version for the test, I used a cursed regexp that will test the value is greater than the current release when present.
4ea3897 to
d3cc649
Compare
| __version__ = 'unset' | ||
| except (ImportError, OSError): | ||
| __version__ = 'unset' | ||
| from superflore.version import VERSION |
There was a problem hiding this comment.
Unfortunately, the unit tests aren't well behaved. They don't cover OpenEmbedded and the Gentoo support is working but showing it's age.
I did run the following as a test:
sed -i "s/lunar/noetic/g" tests/test_ebuild.py tests/test_generate_installers.py tests/ebuild/simple_expected.ebuild
python -m unittest tests.test_ebuild
python -m unittest tests.test_generate_installers
as well as this to do some limited testing on the new version changes:
python -m unittest tests.test_utils
This seems sufficient for now.
| parse_version('0.2.1')) | ||
| if VERSION != 'unset': | ||
| self.assertRegex(get_superflore_version(), | ||
| r"^(\d{2}|[1-9]|0\.(\d{2}|[4-9]|3\.(\d{2}|[4-9]|3)))", |
There was a problem hiding this comment.
Surprised (and a little disappointed) that my use of a cursed regexp to do the version parsing went unremarked.
pkg_resources is only used to fetch and provide the current superflore version.
In fact, there's very little need to parse this version at all (which would also require adding the
packagingmodule as a dependency. Instead of parsing the version for the test, I used a cursed regexp that will test the value is greater than the current release when present.Resolves #314.