-
Notifications
You must be signed in to change notification settings - Fork 16
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
Prepare for Pip package management #3
Open
alexander-bauer
wants to merge
12
commits into
vesposito:master
Choose a base branch
from
alexander-bauer:pip-installable
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Prepare for Pip package management #3
alexander-bauer
wants to merge
12
commits into
vesposito:master
from
alexander-bauer:pip-installable
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit moves much of the content of the repository into a subdirectory named `easyucs` that is a Python package. It adds a `setup.py` in the root of the repository which contains metadata necessary to build, distribute, and install EasyUCS as a Python package. Import statements throughout the project are adjusted to reflect the package structure: `import common` is changed to `import easyucs.common`, and `from __init__ import ...` style imports are changed to just `from easyucs import ...`. (To note: some of the `from __init__ import`s may no longer be necessary in this format.) The scripts `easyucs.py` and `easyucs_gui.py` are also made part of the `easyucs` package, and adjusted to act as modules. They can be invoked like `python -m easyucs.easyucs <args>` or `python -m easyucs.easyucs_gui <args>` respectively. Their imports are changed to respect the package structure, and it is now more robust for `easyucs_gui.py` to import from `easyucs.py`.
That is, `python -m easyucs.easyucs`-style invocation. This updates the references in the documentation to commands formerly `easyucs.py` and `easyucs_gui.py`. It also changes install instructions, and recommends Pip as the primary installation method. References to files that have moved are also adjusted. Additionally, trailing spaces are removed.
These are scripts for running the `easyucs` and `easyucs_gui` modules by way of Python scripts of the same name. This replaces the `python -m easyucs.easyucs`-style invocation with a simpler `easyucs` invocation.
This replaces the uglier `python -m easyucs.easyucs`-style invocation with a cleaner `easyucs` convenience script. This method does mean that manual local installs (via zip or direct git download) will not work by the same invocation; a note is added in the README to address that. (Installations by that method can use `easyucs/scripts/easyucs` and `easyucs_gui`.)
External Python tools trying to call EasyUCS may invoke the module using `runpy`, like `runpy.run_module('easyucs.easyucs')`, but would need to modify `sys.argv` in order to pass alternate arguments to it. Adding this optional `argv` option to `easyucs.main()` will allow external tooling to invoke the main routine just as though they were calling it on the command line. This may be a niche case, but adding the flexibility is at very little cost.
This ensures that the `easyucs/schema/` directory is included as-is and installed within the package root. This is necessary to address issue vesposito#6.
This makes it so that all config schemas are loaded from `schema/ucs/<devicetype>/master.json` relative to the `EASYUCS_ROOT`, defined as the EasyUCS Python package root. This resolves issue vesposito#6, though it does not add an option for specifying custom schema paths.
This makes ConfigManagers load JSON schema files using `with ... as` syntax rather than directly opening and closing file handles, and also invokes `json.load(file_handle)` directly rather than first reading the file to a string, and then deserializing from the string
This resolves a mis-use of setuptools causing package_data (specifically, `schema/`) not to be included recursively. Several directories were previously specified to setuptools using globs like `schema/**/*`. As it turns out, such globs do not recursively expand to list all files unless an additional option is passed to the underlying function, which setuptools does not seem to give an option to provide. This commit adds a function to work around that behavior.
This commit resolves issue vesposito#7 in which when `--logfile` is specified on the command line, it is created but not written to. This was caused by a line in the creation of the console logger dropping the file logger from the list of linked log handlers. Now when `--logfile` is passed, the file is created, and both it and stderr are written to.
Previously, the logfile log_level was set strictly to `DEBUG`. This commit amends it to use the same log_level as the console handler.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR restructures the repository to allow it to be packaged easily by Pip. Metadata and dependencies are listed in
setup.py
, andeasyucs
can be installed from this repository via a normal Pip invocation.Former scripts
easyucs.py
andeasyucs_gui.py
are turned into Python modules (that are members of this package), and replaced by convenience scriptseasyucs
andeasyucs_gui
that simply invoke those named Python modules.Documentation is adjusted to refer to the new convenience scripts. Some formatting is added, and some trailing whitespace is removed.
A
.gitignore
is added to ignore files and directories left by Pip and virtual environments.Much of what this PR addresses is mentioned in issue #2.