-
Notifications
You must be signed in to change notification settings - Fork 881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tools/read-version refactors and unit tests #4268
tools/read-version refactors and unit tests #4268
Conversation
* Refactor script into importable functions * Replace 'which' function with shutils * Remove unused "use_long" option * Add unit tests for read-version and add them to default pytest * Move some utility functions out of setup.py so they can be imported and tested
56b1286
to
4ae6814
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I left a couple of comments inline, but I don't feel strongly about any of them.
@@ -21,6 +21,20 @@ | |||
from setuptools.command.egg_info import egg_info | |||
from setuptools.command.install import install | |||
|
|||
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we please add a comment explaining why?
|
||
validate_version = setuptools.dist.Distribution._validate_version # type: ignore # noqa: E501 | ||
|
||
# Since read-version has a '-' and no .py extension, we have to do this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof - nice workaround.
@@ -290,7 +290,7 @@ per-file-ignores = | |||
|
|||
[pytest] | |||
# TODO: s/--strict/--strict-markers/ once pytest version is high enough | |||
testpaths = tests/unittests | |||
testpaths = tests/unittests tools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to add this to github actions (py3 environment, for example)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our tox environment builds our package and then run tests against it. The tools directory isn't included in the package, so it isn't seen by the tox environment.
tools/read-version
Outdated
arg_use_tags = "--tags" in sys.argv or bool(os.environ.get("CI_RV_TAGS")) | ||
arg_output_json = "--json" in sys.argv | ||
output = main(arg_use_tags, arg_output_json) | ||
sys.stdout.write(output + "\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just print(output)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I thought there might be a good reason so I left it, but print can do the job.
@@ -19,25 +22,6 @@ def tiny_p(cmd): | |||
) | |||
|
|||
|
|||
def which(program): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice refactor
* Refactor script into importable functions * Replace 'which' function with shutils * Remove unused "use_long" option * Add unit tests for read-version and add them to default pytest * Move some utility functions out of setup.py so they can be imported and tested
Proposed Commit Message