addisonelliott / pyqt5ac Goto Github PK
View Code? Open in Web Editor NEWPython module to automatically compile UI and QRC files in PyQt5 to Python files
License: MIT License
Python module to automatically compile UI and QRC files in PyQt5 to Python files
License: MIT License
I just stumbled upon this behavior. My main script contains this line:
pyqt5ac.main(config=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'pyqt5ac.yml'))
and my pyqt5ac.yml
is the following:
variables:
BASEDIR : "be_bi_pyqt_template"
ioPaths:
-
- "%%BASEDIR%%/resources/*.ui"
- "%%BASEDIR%%/resources/generated/ui_%%FILENAME%%.py"
-
- "%%BASEDIR%%/resources/*/*.qrc"
- "%%BASEDIR%%/resources/generated/%%FILENAME%%_rc.py"
uic_options: --from-imports
force: False
The two files are siblings.
When I run main
from the same folder that contains the two files, I get:
Skipping example_widget, up to date
When I run main
from any other folder, I get:
No items found in be_bi_pyqt_template/resources/*.ui
No items found in be_bi_pyqt_template/resources/*/*.qrc
I am looking into this issue now, as it is rather critical for me. Expect a PR soon.
This is a feature request. If we can agree on a default name for the .yml configuration files, pyqt5ac
could be modified to look for it at startup if no more specific instructions are given.
So, instead of typing something like
pyqt5ac --config pyqt5ac.yml
one could simply type
pyqt5ac
and, if pyqt5ac.yml
exists in the folder, it would load it.
I can take on the implementation of this feature if you wish, but let's agree on the details first.
In the _buildCommand
method, the shlex.split
hangs on reading standard input if options
happen to be None
.
The options arguments can be None if one defines the rcc_options
key in the YAML configuration file, as such:
# Invoke with pyqt5ac -c pyqt5.yml
# Additional options to pass to the resource compiler.
# See: https://manpages.ubuntu.com/manpages/hirsute/man1/pyrcc5.1.html
rcc_options:
Set up a Travis pipeline that can publish the package to Pypi repository.
Release could be triggered based on a tag.
If a json configuration is loaded then raise a warning that json support will be removed in 2.0.0.
Modern Python modules tend to offer a setup.py that separates dependencies by usage. For example, they provide:
core
install (only necessary packages)test
install (the packages you need to run the tests properly)doc
install (the packages you need to build documentation)dev
install (extra packages for development)all
(install dependencies from all use-cases)ci
for extra packages needed on CI only, etc.)I understand this package has not a lot of dependencies, but I believe it's a good practice to categorize them that way.
In addition, I'm not entirely sure what the requirements.txt
is being used for. Currently installing this package with pip install -e .
works just fine.
It seems like I forgot to add support for the new custom variables feature from the CLI interface. Shall I fix this for consistency, or you plan to deprecate the CLI support and therefore this is not very relevant?
I have no need for this feature but I understand why it might be better to have it.
Currently if any generation fails (e.g. because a Qt file is invalid) then the script continues running. To raise awareness of the problem, rather let's fail the script's execution in such case.
Also introduce a new lenient
argument which can disable this new strict behaviour. By default it's False, and if given, the script doesn't terminate in case a generation fails.
Set up a webhook to the corresponding GitLab repository: https://gitlab.com/zkovari/pyqt5ac
Steps to do so:
The webhook setup should point to
https://gitlab.com/api/v4/projects/17788428/mirror/pull?private_token=<PERSONAL_ACCESS_TOKEN>
, replacing with your GitLab personal access token. Content type is application/json
. Event is push event.
Expected outcome: a push event on GitHub would automatically trigger a pipeline on GitLab.
Hi.
I'm trying to use pyqt5ac in a rather straightforward way ( I think), using your example for python script.
I added this to my main script:
pyqt5ac.main(rccOptions='', uicOptions='--from-imports', force=False, initPackage=True, config='', ioPaths=[['gui/*.ui', 'gui/%%FILENAME%%_ui.py'], ['icons/*.qrc', 'icons/%%FILENAME%%_rc.py']])
when running it, I get this error:
from the click package.
Oddly, one of the .ui files (camerawindow.ui) does manage to compile and a camerawindow_ui.py is generated in the gui directory.
How can I make it work?
Thanks,
Ido
Folders into Python packages are always required to contain a __init__.py
file, or otherwise they might not be recognized as submodules and imports can fail.
Currently pyqt5ac creates new folders if required, but it does not ensure the presence of such __init__.py
and therefore the generated files might fail to import.
In #3 I proposed a patch that will make sure that at least the folder containing the files includes as well an __init__.py
. I haven't tested it over more nested setups, hopefully it's a rare use-case, but in any case it seems rather simple to extend at need.
it also comes with a flag called --no-init
to disable such check at need.
Add the repository on https://codeclimate.com/dashboard.
After that, under Repo Settings -> Plugins, select the following:
After the setup, it might require some time to run the analysis. And probably it will be only triggered on the next commit.
Very minor feature request.
What about adding something like a --quiet
flag to suppress output if no files are compiled? I don't see the point of the Skipping [this file], up to date
apart from debugging purposes. Optimally we could have properly configurable logging levels.
In #3 I added a check on the variables
dictionary. Running the tests before introducing modifications showed no issue. However, after introducing that simple check over the input, it seems like the tests have an issue and they are not independent.
How to reproduce:
pip install pytest pytest-random-order
(btw, this was a guess and it wouldn't be necessary if test dependencies were specified in setup.py
, see #21)python -m pytest
--> 7 tests fail: variables
apparently contains the default keys already.python -m pytest --random-order
--> 8 tests fail: same reason.python -m pytest tests/test_pyqt5ac.py::test_resource_generation
--> passespython -m pytest tests/test_pyqt5ac.py::<any other failed test>
--> passes (I tested them all one by one)I recommend having a look at pytest documentation in any case. Or, if you're using any other framework for testing and this is a consequence of a wrong guess, please document it somewhere and I'll retry.
Currently I see that three variables can be used to specify the name and location of the files to convert: FILENAME, EXT and DIRNAME.
Is there any way to define extra variables? A practical example:
config.yml
variables:
- BASEDIR: my_project_name
ioPaths:
-
- "%%BASEDIR%%/gui/*.ui"
- "%%BASEDIR%%/generated/%%FILENAME%%_ui.py"
uic_options: --from-imports
force: False
That would be allow me to put the configuration file in the root of the project, so it doesn't get packaged when I release the code.
As a suggestion, it would be nice to introduce typing, at least in function signatures.
Let me know if you need help on this, but it should be a really small thing.
Currently the click CLI is not tested
Continuous testing and QA.
The current way we load the yamls is already deprecated:
pyqt5ac.py:133: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
configData = yaml.load(fh)
Currently, pyqt5ac verifies whether a file needs to be regenerated only basing on the last saved date recorded on the file system.
However, a generated file might become invalid for multiple other reasons:
I would recommend to plan a strategy to detect such changes and how to deal with them.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.