-
Notifications
You must be signed in to change notification settings - Fork 38
cookiecutter: modified files pt2 #154
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| **Added:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Changed:** | ||
|
|
||
| * Package reformatted to comply with new Billinge Group package structure | ||
|
|
||
| **Deprecated:** | ||
|
|
||
| * pkg_resources replaced with importlib | ||
|
|
||
| **Removed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Fixed:** | ||
|
|
||
| * <news item> | ||
|
|
||
| **Security:** | ||
|
|
||
| * <news item> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,8 +16,9 @@ | |
| """This module contains global parameters needed by PDFgui.""" | ||
|
|
||
| import os.path | ||
| from importlib import resources | ||
|
|
||
| from pkg_resources import Requirement, resource_filename | ||
| from pkg_resources import Requirement | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think pkg_resources is deprecated so we want to get rid of this. I would put pkg_resources fixes on a separate PR tbh. |
||
|
|
||
| from diffpy.pdfgui.gui import debugoptions | ||
|
|
||
|
|
@@ -31,7 +32,7 @@ | |
| isAltered = False | ||
|
|
||
| # Resolve APPDATADIR base path to application data files. | ||
| _mydir = os.path.abspath(resource_filename(__name__, "")) | ||
| _mydir = os.path.abspath(str(resources.files(__name__).joinpath(""))) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whenever we touch lines of code that do path munging, switch the code to using pathlib.Path. Then do it for the full module. This also on a separate PR because it will be harder to merge. |
||
| _upbasedir = os.path.normpath(_mydir + "/../../..") | ||
| _development_mode = os.path.basename(_upbasedir) == "src" and os.path.isfile( | ||
| os.path.join(_upbasedir, "../setup.py") | ||
|
|
@@ -47,7 +48,7 @@ | |
| if _development_mode: | ||
| APPDATADIR = os.path.dirname(_mydir) | ||
| else: | ||
| APPDATADIR = os.path.join(resource_filename(_req, ""), "diffpy/pdfgui") | ||
| APPDATADIR = os.path.join(str(resources.files(_req, "")), "diffpy/pdfgui") | ||
|
|
||
| APPDATADIR = os.path.abspath(APPDATADIR) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,34 @@ | ||
| #!/usr/bin/env python | ||
| ############################################################################## | ||
| # | ||
| # diffpy.pdfgui by DANSE Diffraction group | ||
| # Simon J. L. Billinge | ||
| # (c) 2012-2024 Trustees of the Columbia University | ||
| # in the City of New York. All rights reserved. | ||
| # (c) 2012-2024 The Trustees of Columbia University in the City of New York. | ||
| # All rights reserved. | ||
| # | ||
| # File coded by: Pavol Juhas | ||
| # File coded by: Billinge Group members and community contributors. | ||
| # | ||
| # See AUTHORS.txt for a list of people who contributed. | ||
| # See LICENSE.txt for license information. | ||
| # See GitHub contributions for a more detailed list of contributors. | ||
| # https://github.com/diffpy/diffpy.pdfgui/graphs/contributors | ||
| # | ||
| # See LICENSE.rst for license information. | ||
| # | ||
| ############################################################################## | ||
|
|
||
| """Convenience module for executing all unit tests with | ||
|
|
||
| python -m diffpy.pdfgui.tests.run | ||
| """ | ||
|
|
||
| import sys | ||
|
|
||
| if __name__ == "__main__": | ||
| import sys | ||
| import pytest | ||
|
|
||
| # show warnings by default | ||
| if not sys.warnoptions: | ||
| import os | ||
| import warnings | ||
|
|
||
| warnings.simplefilter("default") | ||
| # also affect subprocesses | ||
| os.environ["PYTHONWARNINGS"] = "default" | ||
| from diffpy.pdfgui.tests import test | ||
|
|
||
| # produce zero exit code for a successful test | ||
| sys.exit(not test().wasSuccessful()) | ||
| if __name__ == "__main__": | ||
| # show output results from every test function | ||
| args = ["-v"] | ||
| # show the message output for skipped and expected failure tests | ||
| if len(sys.argv) > 1: | ||
| args.extend(sys.argv[1:]) | ||
| print("pytest arguments: {}".format(args)) | ||
| # call pytest and exit with the return code from pytest | ||
| exit_res = pytest.main(args) | ||
| sys.exit(exit_res) | ||
|
|
||
| # End of 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.
did you test this? It is unlikely to work because this is a relative file-path.