Giter Site home page Giter Site logo

addisonelliott / pyqt5ac Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 3.0 82 KB

Python module to automatically compile UI and QRC files in PyQt5 to Python files

License: MIT License

Python 100.00%
pyqt5 qt5 qt5-gui qt-gui ui resource compiler automatic

pyqt5ac's Issues

Paths are not relative to the configuration file

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.

Auto-detect configuration files

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.

shlex.split hangs if rcc_options is defined by empty in YAML config

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:

Deprecate json usage

If a json configuration is loaded then raise a warning that json support will be removed in 2.0.0.

Introduce dependency scopes in setup.py

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)
  • aggregates install tags like all (install dependencies from all use-cases)
    and the possibility to define extra tags in case of need (like 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.

Custom variables not supported from CLI

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.

Fail execution if file generation fails

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 webhook to GitLab mirror repository

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.

"Bad file descriptor error" from 'click\_winconsole.py'

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:
image
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

Ensure eventually generated folders contain `__init__.py` files

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.

Set up codeclimate integration

Add the repository on https://codeclimate.com/dashboard.

After that, under Repo Settings -> Plugins, select the following:

  • Fixme
  • Git.legal
  • Markdownlint
  • Pep8
  • Radon
  • SonarPython

After the setup, it might require some time to run the analysis. And probably it will be only triggered on the next commit.

Configurable logging levels

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.

Tests seems to be not independent

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:

  1. Get the code from PR #3
  2. 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)
  3. python -m pytest --> 7 tests fail: variables apparently contains the default keys already.
  4. python -m pytest --random-order --> 8 tests fail: same reason.
  5. python -m pytest tests/test_pyqt5ac.py::test_resource_generation --> passes
  6. python -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.

Define custom variables

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.

Typing

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.

Update deprecated yaml loading

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)

More robust check for regeneration [WIP]

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:

  • IDE's refactoring (or not refactoring properly) imports in the generated files and not in the *.ui / *.qrc
  • Other files, which are being imported into the current one, changing name/path (like *.qrc's resources)
  • Users editing the files
  • Probably more unexpected ones

I would recommend to plan a strategy to detect such changes and how to deal with them.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.