From a33fc09a091f73ca3cc3192dfc88218883aed1c9 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 14 Sep 2018 13:52:32 +0200 Subject: Add "copyexamples" make target for copying all the examples to the build And remove examples/package.py, which is basically just a zip call anyhow. Change-Id: I70ae585f9919dc3e9a6fb8bfe8feee26c4b72ab1 Reviewed-by: Friedemann Kleint --- README.md | 5 +++- examples/README.md | 11 ++------- examples/examples.pro | 22 ++++++++++++++++++ examples/package.py | 64 --------------------------------------------------- pythonextensions.pro | 7 +++++- 5 files changed, 34 insertions(+), 75 deletions(-) create mode 100644 examples/examples.pro delete mode 100644 examples/package.py diff --git a/README.md b/README.md index b609d3f..657bf9b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ This plugin for QtCreator makes it possible to extend the QtCreator by writing Python extensions. These extensions are simply Python packages, so they are directories containing a `__init__.py` and any other Python files necessary. They can be shared as zip archives, installed and managed -through the included extension manager (which is a Python extension itself) and thus allow the QtCreator to be easily extended with custom functionality. +through the included extension manager (which is a Python extension itself) and +thus allow the QtCreator to be easily extended with custom functionality. **WARNING:** This is a first draft / proof of concept and only offers very limited functionality. There will still be many bugs and so far @@ -72,6 +73,8 @@ After this, the plugin should be installed into the QtCreator version you built in the previous steps. If this worked, you can now go ahead and check out the `examples` folder and play with the provided example Python extensions. +You can copy all examples to the right location in the build directory by +running `make copyexamples`. Notice that depending on your configuration, you may need to add Clang to your library paths for Shiboken to run. Achieve this by running the diff --git a/examples/README.md b/examples/README.md index f94ef22..977c45c 100644 --- a/examples/README.md +++ b/examples/README.md @@ -5,13 +5,6 @@ own directory, where you can inspect its source code. ## How to install -If you want to install some of these extensions to play around with them, you can use the -`package.py` utility. Run `$ python package.py` in your terminal, to generate extension packages -(.zip files) of all the extensions in this directory. The generated extension packages can then be -installed into your QtCreator using the extension manager that comes with the plugin. (Find the -extension manager in the help menu of your QtCreator.) -To clean this directory from generated packages, simply run `$ python package.py clean` in your -terminal. Note that for your own Python extensions, it is sufficient to distribute .zip -files, which you can easily generate manually. **Remember to include a top-level directory** when -making your own extension packages. +Simply run `make copyexamples` to copy the examples to the right location +in the build directory. diff --git a/examples/examples.pro b/examples/examples.pro new file mode 100644 index 0000000..58de286 --- /dev/null +++ b/examples/examples.pro @@ -0,0 +1,22 @@ +# We cannot use qtcreatordata.pri for this, because that cannot be made "on request only" +# so we use a "no_default_install" install target instead. + +TEMPLATE = aux + +include(../plugins/pythonextensions/qtcreator.pri) +include($$IDE_SOURCE_TREE/qtcreator.pri) + +inst_examples.files = \ + macroexpander \ + numpysetup \ + projects \ + requirerequests \ + smallmenu \ + transform + +inst_examples.path = $$IDE_PLUGIN_PATH/python +inst_examples.CONFIG += no_default_install directory +INSTALLS += inst_examples + +copyexamples.depends += install_inst_examples +QMAKE_EXTRA_TARGETS += copyexamples diff --git a/examples/package.py b/examples/package.py deleted file mode 100644 index 08f6077..0000000 --- a/examples/package.py +++ /dev/null @@ -1,64 +0,0 @@ -############################################################################# -## -## Copyright (C) 2018 The Qt Company Ltd. -## Contact: http://www.qt.io/licensing/ -## -## This file is part of the Python Extensions Plugin for QtCreator. -## -## $QT_BEGIN_LICENSE:BSD$ -## You may use this file under the terms of the BSD license as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################# - -# This script is just here for convenience. If you are writing -# your own extension, manually creating a zip archive is sufficient. - -# Usage: $ python package.py -# (pass argument 'clean' to remove generated package.zip files) - -import os, sys, shutil - -def package(): - for entry in os.scandir("./"): - if entry.is_dir(): - shutil.make_archive(entry.path.split("/")[-1], "zip", "./", entry.path) - -def clean(): - for entry in os.scandir("./"): - if entry.is_file() and entry.name.split(".")[-1] == "zip": - os.remove(entry.path) - - -if __name__ == "__main__": - if "clean" in sys.argv: - clean() - else: - package() diff --git a/pythonextensions.pro b/pythonextensions.pro index 5d5804d..b884dd9 100644 --- a/pythonextensions.pro +++ b/pythonextensions.pro @@ -3,8 +3,13 @@ TEMPLATE = subdirs SUBDIRS += \ pythonextensions \ python \ - optional + optional \ + examples pythonextensions.subdir = plugins/pythonextensions optional.depends = pythonextensions + +copyexamples.CONFIG += recursive +copyexamples.recurse = examples +QMAKE_EXTRA_TARGETS += copyexamples -- cgit v1.2.3