diff --git a/HEAD b/HEAD new file mode 100644 index 00000000..b870d826 --- /dev/null +++ b/HEAD @@ -0,0 +1 @@ +ref: refs/heads/main diff --git a/README.md b/README.md index 9e3ad17b..d8691164 100644 --- a/README.md +++ b/README.md @@ -1,162 +1,40 @@ -# CadQuery editor +A fork of cq-editor with support for selectable dark+light colour theme added. Also, an optional switch to delete the saved preferences from disk was added due to reasons. I started the fork out of simple need, as cq-editor + cadquery look very promising for some ideas I have - e.g. programmatically generated, parametrically comprehensive 3D models of inductor coils for use with KiCAD - at the same time that light backgrounds are unusable for me together with the dark ones I'm used to (actually they feel like a bright brick wall slamming into the visual cortex). -[![Build status](https://ci.appveyor.com/api/projects/status/g98rs7la393mgy91/branch/master?svg=true)](https://ci.appveyor.com/project/adam-urbanczyk/cq-editor/branch/master) -[![codecov](https://codecov.io/gh/CadQuery/CQ-editor/branch/master/graph/badge.svg)](https://codecov.io/gh/CadQuery/CQ-editor) -[![Build Status](https://dev.azure.com/cadquery/CQ-editor/_apis/build/status/CadQuery.CQ-editor?branchName=master)](https://dev.azure.com/cadquery/CQ-editor/_build/latest?definitionId=3&branchName=master) -[![DOI](https://zenodo.org/badge/136604983.svg)](https://zenodo.org/badge/latestdoi/136604983) +Some of the ways my changes accomplish things may be inelegant, break the OO paradigm or in other ways be abominable, due to (but probably not exclusively): -CadQuery GUI editor based on PyQT supports Linux, Windows and Mac. +1. This is the first time I use conda (I settled for micromamba). +2. This is the first time I make changes in any Python code I didn't write myself the same week. +3. This is the third time I do anything in Python except for a page-long text processing hack two years ago and a similar one five years ago. +4. This is the first time I do anything using the qt framework aside from a 'hello world' window sometime around the previous millenium. +5. This is the first time I use git for anything more esoteric than 'git clone'. -Screenshot -Screenshot -Screenshot +It wasn't until I was done with the goal I had set that I was struck with the realization that there's a non-negligible probability that my dark mode implementation may be of use to someone, and that the socially responsible thing to do would be to publizise my work on github. Hence (5) above, in addition to, as a result of me from the outset only planning to risk myself being exposed to my code: -## Notable features +6. Any documentation in the commit is what I remember after everything was done, which is probably half if that. -* OCCT based -* Graphical debugger for CadQuery scripts - * Step through script and watch how your model changes -* CadQuery object stack inspector - * Visual inspection of current workplane and selected items - * Insight into evolution of the model -* Export to various formats - * STL - * STEP +The largest (only...?) difference between the conda environment dependencies in my fork w.r.t. the origin is a Python version bump to 3.10.? and the resulting versions upgrades of everything dependant on it. I probably didn't have good reasons, although I do remember something about a non-ancient qdarkstyle version and its requirements, although I may be confusing it with something else that may or may not be reality-related. Additionally, there may well remain unnecessary and forgotten packages I installed but ultimately didn't need. -## Installation - Pre-Built Packages (Recommended) +The steps to get my code running are something at least similar to the ones below: -### Release Packages +$ cd ~/ +$ wget -qO- https://micromamba.snakepit.net/api/micromamba/linux-64/latest | tar -xvj bin/micromamba +$ bin/micromamba shell init -s bash -p ~/micromamba -Stable release builds which do not require Anaconda are attached to the [latest release](https://github.com/CadQuery/CQ-editor/releases). Download the zip file for your operating system, extract it, and run the CQ-editor script for your OS (CQ-editor.cmd for Windows, CQ-editor.sh for Linux and MacOS). On Windows you should be able to simply double-click on CQ-editor.cmd. On Linux and MacOS you may need to make the script executable with `chmod +x CQ-editor.sh` and run the script from the command line. The script contains an environment variable export that may be required to get CQ-editor to launch correctly on MacOS Big Sur, so it is better to use the script than to launch CQ-editor directly. +$ git clone https://github.com/axhan/CQ-editor_themed.git +$ micromamba env create -f CQ-editor/cqgui_env.yml -n cqgui +$ micromamba activate cqgui +(cqgui) $ cd ~/micromamba/envs/cqgui -### Development Packages +(cqgui) $ micromamba install python=3.10.4 -c conda-forge +(cqgui) $ micromamba install cadquery=master -c CadQuery +(cqgui) $ micromamba install spyder -c conda-forge -Development builds are also available, but can be unstable and should be used at your own risk. Click on the newest build with a green checkmark [here](https://github.com/jmwright/CQ-editor/actions?query=workflow%3Abuild), wait for the _Artifacts_ section at the bottom of the page to load, and then click on the appropriate download for your operating system. Extract the archive file and run the shell (Linux/MacOS) or cmd (Windows) script in the root CQ-editor directory. The CQ-editor window should launch. +(cqgui) $ mkdir src +(cqgui) $ mv ~/CQ-editor src/ +(cqgui) $ cd src/CQ-editor -## Installation (Anaconda) +# Test run: +(cqgui) $ python run.py -Use conda to install: -``` -conda install -c cadquery -c conda-forge cq-editor=master -``` -and then simply type `cq-editor` to run it. This installs the latest version built directly from the HEAD of this repository. - -Alternatively clone this git repository and set up the following conda environment: -``` -conda env create -f cqgui_env.yml -n cqgui -conda activate cqgui -python run.py -``` - -On some linux distributions (e.g. `Ubuntu 18.04`) it might be necessary to install additonal packages: -``` -sudo apt install libglu1-mesa libgl1-mesa-dri mesa-common-dev libglu1-mesa-dev -``` -On Fedora 29 the packages can be installed as follows: -``` -dnf install -y mesa-libGLU mesa-libGL mesa-libGLU-devel -``` - -## Usage - -### Showing Objects - -By default, CQ-editor will display a 3D representation of all `Workplane` objects in a script with a default color and alpha (transparency). To have more control over what is shown, and what the color and alpha settings are, the `show_object` method can be used. `show_object` tells CQ-editor to explicity display an object, and accepts the `options` parameter. The `options` parameter is a dictionary of rendering options named `alpha` and `color`. `alpha` is scaled between 0.0 and 1.0, with 0.0 being completely opaque and 1.0 being completely transparent. The color is set using R (red), G (green) and B (blue) values, and each one is scaled from 0 to 255. Either option or both can be omitted. - -```python -show_object(result, options={"alpha":0.5, "color": (64, 164, 223)}) -``` - -Note that `show_object` works for `Shape` and `TopoDS_Shape` objects too. In order to display objects from the embedded Python console use `show`. - -### Rotate, Pan and Zoom the 3D View - -The following mouse controls can be used to alter the view of the 3D object, and should be familiar to CAD users, even if the mouse buttons used may differ. - -* _Left Mouse Button_ + _Drag_ = Rotate -* _Middle Mouse Button_ + _Drag_ = Pan -* _Right Mouse Button_ + _Drag_ = Zoom -* _Mouse Wheel_ = Zoom - -### Debugging Objects - -There are multiple menu options to help in debugging a CadQuery script. They are included in the `Run` menu, with corresponding buttons in the toolbar. Below is a listing of what each menu item does. - -* `Debug` (Ctrl + F5) - Instead of running the script completely through as with the `Render` item, it begins executing the script but stops at the first non-empty line, waiting for the user to continue execution manually. -* `Step` (Ctrl + F10) - Will move execution of the script to the next non-empty line. -* `Step in` (Ctrl + F11) - Will follow the flow of execution to the inside of a user-created function defined within the script. -* `Continue` (Ctrl + F12) - Completes execution of the script, starting from the current line that is being debugged. - -It is also possible to do visual debugging of objects. This is possible by using the `debug()` function to display an object instead of `show_object()`. An alternative method for the following code snippet is shown below for highlighting a specific face, but it demonstrates one use of `debug()`. -```python -import cadquery as cq - -result = cq.Workplane().box(10, 10, 10) - -highlight = result.faces('>Z') - -show_object(result, name='box') -debug(highlight) -``` -Objects displayed with `debug()` are colored in red and have their alpha set so they are semi-transparent. This can be useful for checking for interference, clearance, or whether the expected face is being selected, as in the code above. - -### Console Logging - -Python's standard `print()` function will not output to the CQ-editor GUI, and `log()` should be used instead. `log()` will output the provided text to the _Log viewer_ panel, providing another way to debug CadQuery scripts. If you started CQ-editor from the command line, the `print()` function will output text back to it. - -### Using an External Code Editor - -Some users prefer to use an external code editor instead of the built-in Spyder-based editor that comes stock with CQ-editor. The steps below should allow CQ-editor to work alongside most text editors. - -1. Open the Preferences dialog by clicking `Edit->Preferences`. -2. Make sure that `Code Editor` is selected in the left pane. -3. Check `Autoreload` in the right pane. -4. If CQ-editor is not catching the saves from your external editor, increasing `Autoreload delay` in the right pane may help. This issue has been reported when using vim or emacs. - -### Exporting an Object - -Any object can be exported to either STEP or STL format. The steps for doing so are listed below. - -1. Highlight the object to be exported in the _Objects_ panel. -2. Click either `Export as STL` or `Export as STEP` from the `Tools` menu, depending on which file format you want to export. Both of these options will be disabled if an object is not selected in the _Objects_ panel. - -Clicking either _Export_ item will present a file dialog that allows the file name and location of the export file to be set. - -### Displaying All Wires for Debugging - -**NOTE:** This is intended for debugging purposes, and if not removed, could interfere with the execution of your model in some cases. - -Using `consolidateWires()` is a quick way to combine all wires so that they will display together in CQ-editor's viewer. In the following code, it is used to make sure that both rects are displayed. This technique can make it easier to debug in-progress 2D sketches. - -```python -import cadquery as cq -res = cq.Workplane().rect(1,1).rect(3,3).consolidateWires() -show_object(res) -``` - -### Highlighting a Specific Face - -Highlighting a specific face in a different color can be useful when debugging, or when trying to learn CadQuery selectors. The following code creates a separate, highlighted object to show the selected face in red. This is an alternative to using a `debug()` object, and in most cases `debug()` will provide the same result with less code. However, this method will allow the color and alpha of the highlight object to be customized. - -```python -import cadquery as cq - -result = cq.Workplane().box(10, 10, 10) - -highlight = result.faces('>Z') - -show_object(result) -show_object(highlight,'highlight',options=dict(alpha=0.1,color=(1.,0,0))) -``` - -### Naming an Object - -By default, objects have a randomly generated ID in the object inspector. However, it can be useful to name objects so that it is easier to identify them. The `name` parameter of `show_object()` can be used to do this. - -```python -import cadquery as cq - -result = cq.Workplane().box(10, 10, 10) - -show_object(result, name='box') -``` +![Screenshot from 2022-04-08 16-18-39](https://user-images.githubusercontent.com/41844315/162455097-620813fb-4279-4013-a9d1-e7f3aaed12ab.png) +![Screenshot from 2022-04-08 16-18-55](https://user-images.githubusercontent.com/41844315/162455138-97051129-ad2f-48ca-94c7-b9316d37456a.png) diff --git a/README_cq-editor.md b/README_cq-editor.md new file mode 100644 index 00000000..9e3ad17b --- /dev/null +++ b/README_cq-editor.md @@ -0,0 +1,162 @@ +# CadQuery editor + +[![Build status](https://ci.appveyor.com/api/projects/status/g98rs7la393mgy91/branch/master?svg=true)](https://ci.appveyor.com/project/adam-urbanczyk/cq-editor/branch/master) +[![codecov](https://codecov.io/gh/CadQuery/CQ-editor/branch/master/graph/badge.svg)](https://codecov.io/gh/CadQuery/CQ-editor) +[![Build Status](https://dev.azure.com/cadquery/CQ-editor/_apis/build/status/CadQuery.CQ-editor?branchName=master)](https://dev.azure.com/cadquery/CQ-editor/_build/latest?definitionId=3&branchName=master) +[![DOI](https://zenodo.org/badge/136604983.svg)](https://zenodo.org/badge/latestdoi/136604983) + +CadQuery GUI editor based on PyQT supports Linux, Windows and Mac. + +Screenshot +Screenshot +Screenshot + +## Notable features + +* OCCT based +* Graphical debugger for CadQuery scripts + * Step through script and watch how your model changes +* CadQuery object stack inspector + * Visual inspection of current workplane and selected items + * Insight into evolution of the model +* Export to various formats + * STL + * STEP + +## Installation - Pre-Built Packages (Recommended) + +### Release Packages + +Stable release builds which do not require Anaconda are attached to the [latest release](https://github.com/CadQuery/CQ-editor/releases). Download the zip file for your operating system, extract it, and run the CQ-editor script for your OS (CQ-editor.cmd for Windows, CQ-editor.sh for Linux and MacOS). On Windows you should be able to simply double-click on CQ-editor.cmd. On Linux and MacOS you may need to make the script executable with `chmod +x CQ-editor.sh` and run the script from the command line. The script contains an environment variable export that may be required to get CQ-editor to launch correctly on MacOS Big Sur, so it is better to use the script than to launch CQ-editor directly. + +### Development Packages + +Development builds are also available, but can be unstable and should be used at your own risk. Click on the newest build with a green checkmark [here](https://github.com/jmwright/CQ-editor/actions?query=workflow%3Abuild), wait for the _Artifacts_ section at the bottom of the page to load, and then click on the appropriate download for your operating system. Extract the archive file and run the shell (Linux/MacOS) or cmd (Windows) script in the root CQ-editor directory. The CQ-editor window should launch. + +## Installation (Anaconda) + +Use conda to install: +``` +conda install -c cadquery -c conda-forge cq-editor=master +``` +and then simply type `cq-editor` to run it. This installs the latest version built directly from the HEAD of this repository. + +Alternatively clone this git repository and set up the following conda environment: +``` +conda env create -f cqgui_env.yml -n cqgui +conda activate cqgui +python run.py +``` + +On some linux distributions (e.g. `Ubuntu 18.04`) it might be necessary to install additonal packages: +``` +sudo apt install libglu1-mesa libgl1-mesa-dri mesa-common-dev libglu1-mesa-dev +``` +On Fedora 29 the packages can be installed as follows: +``` +dnf install -y mesa-libGLU mesa-libGL mesa-libGLU-devel +``` + +## Usage + +### Showing Objects + +By default, CQ-editor will display a 3D representation of all `Workplane` objects in a script with a default color and alpha (transparency). To have more control over what is shown, and what the color and alpha settings are, the `show_object` method can be used. `show_object` tells CQ-editor to explicity display an object, and accepts the `options` parameter. The `options` parameter is a dictionary of rendering options named `alpha` and `color`. `alpha` is scaled between 0.0 and 1.0, with 0.0 being completely opaque and 1.0 being completely transparent. The color is set using R (red), G (green) and B (blue) values, and each one is scaled from 0 to 255. Either option or both can be omitted. + +```python +show_object(result, options={"alpha":0.5, "color": (64, 164, 223)}) +``` + +Note that `show_object` works for `Shape` and `TopoDS_Shape` objects too. In order to display objects from the embedded Python console use `show`. + +### Rotate, Pan and Zoom the 3D View + +The following mouse controls can be used to alter the view of the 3D object, and should be familiar to CAD users, even if the mouse buttons used may differ. + +* _Left Mouse Button_ + _Drag_ = Rotate +* _Middle Mouse Button_ + _Drag_ = Pan +* _Right Mouse Button_ + _Drag_ = Zoom +* _Mouse Wheel_ = Zoom + +### Debugging Objects + +There are multiple menu options to help in debugging a CadQuery script. They are included in the `Run` menu, with corresponding buttons in the toolbar. Below is a listing of what each menu item does. + +* `Debug` (Ctrl + F5) - Instead of running the script completely through as with the `Render` item, it begins executing the script but stops at the first non-empty line, waiting for the user to continue execution manually. +* `Step` (Ctrl + F10) - Will move execution of the script to the next non-empty line. +* `Step in` (Ctrl + F11) - Will follow the flow of execution to the inside of a user-created function defined within the script. +* `Continue` (Ctrl + F12) - Completes execution of the script, starting from the current line that is being debugged. + +It is also possible to do visual debugging of objects. This is possible by using the `debug()` function to display an object instead of `show_object()`. An alternative method for the following code snippet is shown below for highlighting a specific face, but it demonstrates one use of `debug()`. +```python +import cadquery as cq + +result = cq.Workplane().box(10, 10, 10) + +highlight = result.faces('>Z') + +show_object(result, name='box') +debug(highlight) +``` +Objects displayed with `debug()` are colored in red and have their alpha set so they are semi-transparent. This can be useful for checking for interference, clearance, or whether the expected face is being selected, as in the code above. + +### Console Logging + +Python's standard `print()` function will not output to the CQ-editor GUI, and `log()` should be used instead. `log()` will output the provided text to the _Log viewer_ panel, providing another way to debug CadQuery scripts. If you started CQ-editor from the command line, the `print()` function will output text back to it. + +### Using an External Code Editor + +Some users prefer to use an external code editor instead of the built-in Spyder-based editor that comes stock with CQ-editor. The steps below should allow CQ-editor to work alongside most text editors. + +1. Open the Preferences dialog by clicking `Edit->Preferences`. +2. Make sure that `Code Editor` is selected in the left pane. +3. Check `Autoreload` in the right pane. +4. If CQ-editor is not catching the saves from your external editor, increasing `Autoreload delay` in the right pane may help. This issue has been reported when using vim or emacs. + +### Exporting an Object + +Any object can be exported to either STEP or STL format. The steps for doing so are listed below. + +1. Highlight the object to be exported in the _Objects_ panel. +2. Click either `Export as STL` or `Export as STEP` from the `Tools` menu, depending on which file format you want to export. Both of these options will be disabled if an object is not selected in the _Objects_ panel. + +Clicking either _Export_ item will present a file dialog that allows the file name and location of the export file to be set. + +### Displaying All Wires for Debugging + +**NOTE:** This is intended for debugging purposes, and if not removed, could interfere with the execution of your model in some cases. + +Using `consolidateWires()` is a quick way to combine all wires so that they will display together in CQ-editor's viewer. In the following code, it is used to make sure that both rects are displayed. This technique can make it easier to debug in-progress 2D sketches. + +```python +import cadquery as cq +res = cq.Workplane().rect(1,1).rect(3,3).consolidateWires() +show_object(res) +``` + +### Highlighting a Specific Face + +Highlighting a specific face in a different color can be useful when debugging, or when trying to learn CadQuery selectors. The following code creates a separate, highlighted object to show the selected face in red. This is an alternative to using a `debug()` object, and in most cases `debug()` will provide the same result with less code. However, this method will allow the color and alpha of the highlight object to be customized. + +```python +import cadquery as cq + +result = cq.Workplane().box(10, 10, 10) + +highlight = result.faces('>Z') + +show_object(result) +show_object(highlight,'highlight',options=dict(alpha=0.1,color=(1.,0,0))) +``` + +### Naming an Object + +By default, objects have a randomly generated ID in the object inspector. However, it can be useful to name objects so that it is easier to identify them. The `name` parameter of `show_object()` can be used to do this. + +```python +import cadquery as cq + +result = cq.Workplane().box(10, 10, 10) + +show_object(result, name='box') +``` diff --git a/anders_patch.txt b/anders_patch.txt new file mode 100644 index 00000000..d719ae98 --- /dev/null +++ b/anders_patch.txt @@ -0,0 +1,38 @@ +A fork of cq-editor with support for selectable dark+light colour theme added. Also, an optional switch to delete the saved preferences from disk was added due to reasons. I started the fork out of simple need, as cq-editor + cadquery look very promising for some ideas I have - e.g. programmatically generated, parametrically comprehensive 3D models of inductor coils for use with KiCAD - at the same time that light backgrounds are unusable for me together with the dark ones I'm used to (actually they feel like a bright brick wall slamming into the visual cortex). + +Some of the ways my changes accomplish things may be inelegant, break the OO paradigm or in other ways be abominable, due to (but probably not exclusively): + +1. This is the first time I use conda (I settled for micromamba). +2. This is the first time I make changes in any Python code I didn't write myself the same week. +3. This is the third time I do anything in Python except for a page-long text processing hack two years ago and a similar one five years ago. +4. This is the first time I do anything using the qt framework aside from a 'hello world' window sometime around the previous millenium. +5. This is the first time I use git for anything more esoteric than 'git clone'. + +It wasn't until I was done with the goal I had set that I was struck with the realization that there's a non-negligible probability that my dark mode implementation may be of use to someone, and that the socially responsible thing to do would be to publizise my work on github. Hence (5) above, in addition to, as a result of me from the outset only planning to risk myself being exposed to my code: + +6. Any documentation in the commit is what I remember after everything was done, which is probably half if that. + +The largest (only...?) difference between the conda environment dependencies in my fork w.r.t. the origin is a Python version bump to 3.10.? and the resulting versions upgrades of everything dependant on it. I probably didn't have good reasons, although I do remember something about a non-ancient qdarkstyle version and its requirements, although I may be confusing it with something else that may or may not be reality-related. Additionally, there may well remain unnecessary and forgotten packages I installed but ultimately didn't need. + +The steps to get my code running are something at least similar to the ones below: + +$ cd ~/ +$ wget -qO- https://micromamba.snakepit.net/api/micromamba/linux-64/latest | tar -xvj bin/micromamba +$ bin/micromamba shell init -s bash -p ~/micromamba + +$ git clone https://github.com/CadQuery/CQ-editor.git +$ micromamba env create -f CQ-editor/cqgui_env.yml -n cqgui +$ micromamba activate cqgui +(cqgui) $ cd ~/micromamba/envs/cqgui + +(cqgui) $ micromamba install python=3.10.4 -c conda-forge +(cqgui) $ micromamba install cadquery=master -c CadQuery +(cqgui) $ micromamba install spyder -c conda-forge + +(cqgui) $ mkdir src +(cqgui) $ mv ~/CQ-editor src/ +(cqgui) $ cd src/CQ-editor + +# Test run: +(cqgui) $ python run.py + diff --git a/appveyor.yml b/appveyor.yml index 899f7de6..abf05ed1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,13 +22,14 @@ install: - cmd: miniconda.exe /S /InstallationType=JustMe /D=%MINICONDA_DIRNAME% - cmd: set "PATH=%MINICONDA_DIRNAME%;%MINICONDA_DIRNAME%\\Scripts;%PATH%" - cmd: activate + - mamba config --set always_yes yes - mamba info - mamba env create --name cqgui -f cqgui_env.yml - sh: source activate cqgui - cmd: activate cqgui - mamba list - - mamba install -y pytest pluggy pytest-qt - - mamba install -y pytest-mock pytest-cov pytest-repeat codecov pyvirtualdisplay + - pip install pytest pluggy pytest-qt + - pip install pytest-mock pytest-cov pytest-repeat codecov pyvirtualdisplay build: false diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0b3fcdbe..6e1235fc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,39 +11,54 @@ resources: repositories: - repository: templates type: github - name: CadQuery/conda-packages + name: jmwright/conda-packages endpoint: CadQuery -parameters: - - name: minor - type: object - default: - - 8 - - 9 - - 10 - jobs: -- ${{ each minor in parameters.minor }}: - - template: conda-build.yml@templates - parameters: - name: Linux - vmImage: 'ubuntu-18.04' - py_maj: 3 - py_min: ${{minor}} - conda_bld: 3.21.6 - - - template: conda-build.yml@templates - parameters: - name: macOS - vmImage: 'macOS-10.15' - py_maj: 3 - py_min: ${{minor}} - conda_bld: 3.21.6 - - - template: conda-build.yml@templates - parameters: - name: Windows - vmImage: 'windows-latest' - py_maj: 3 - py_min: ${{minor}} - conda_bld: 3.21.6 +- template: conda-build.yml@templates + parameters: + name: Linux + vmImage: 'ubuntu-18.04' + py_maj: 3 + py_min: 8 + conda_bld: '3.20.3' + +- template: conda-build.yml@templates + parameters: + name: macOS + vmImage: 'macOS-10.15' + py_maj: 3 + py_min: 8 + conda_bld: '3.20.3' + +- template: conda-build.yml@templates + parameters: + name: Windows + vmImage: 'vs2017-win2016' + py_maj: 3 + py_min: 8 + conda_bld: '3.20.3' + +- template: conda-build.yml@templates + parameters: + name: Linux + vmImage: 'ubuntu-18.04' + py_maj: 3 + py_min: 9 + conda_bld: '3.21.4' + +- template: conda-build.yml@templates + parameters: + name: macOS + vmImage: 'macOS-10.15' + py_maj: 3 + py_min: 9 + conda_bld: '3.21.4' + +- template: conda-build.yml@templates + parameters: + name: Windows + vmImage: 'vs2017-win2016' + py_maj: 3 + py_min: 9 + conda_bld: '3.21.4' diff --git a/commit.txt b/commit.txt new file mode 100644 index 00000000..f492f84c --- /dev/null +++ b/commit.txt @@ -0,0 +1,14 @@ +A preferences option to select dark or light mode was added. Dark mode was made the default. + +Support was added for application-wide dark or light mode using qdarkstyle through qt stylesheets. + +The stylesheet doesn't affect the console component background colour, so I made it set light or dark background styles using its own, separate Jupyter styling according to the app theme. + +(The code editor's colours are alse immune to the stylesheet, but I left it untouched since its preferences-selectable syntax color schemes already include schemes with both light and dark backgrounds. + +The 3D viewer's colours are also impervious to stylesheets, I likewise left it untouched since its colours are already fully adjustable in the preferences). + +A command-line option '-r, --restore_defaults' to delete the file containing stored preferences was added. + +All instantiations of QApplication except one were made conditional on it not already having been instantiated. + diff --git a/conda/meta.yaml b/conda/meta.yaml index 4986d98e..b46cf6b1 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -23,8 +23,8 @@ requirements: - logbook - pyqt=5.* - pyqtgraph - - spyder=5.* - - path + - spyder=4.* + - path.py - logbook - requests diff --git a/config b/config new file mode 100644 index 00000000..07d359d0 --- /dev/null +++ b/config @@ -0,0 +1,4 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true diff --git a/cq_editor/__main__.py b/cq_editor/__main__.py index 0fc8f700..8875a55d 100644 --- a/cq_editor/__main__.py +++ b/cq_editor/__main__.py @@ -1,7 +1,10 @@ +import os import sys import argparse +import qdarkstyle from PyQt5.QtWidgets import QApplication +from PyQt5.QtCore import QFile, QTextStream, QSettings NAME = 'CQ-editor' @@ -14,15 +17,33 @@ def main(): parser = argparse.ArgumentParser(description=NAME) + parser.add_argument('-r', '--restore_defaults', + required = False, + action = 'store_true', + help = 'restore default settings and exit') parser.add_argument('filename',nargs='?',default=None) - args = parser.parse_args(app.arguments()[1:]) - win = MainWindow(filename=args.filename if args.filename else None) - win.show() - sys.exit(app.exec_()) + if args.restore_defaults: + settings = QSettings(MainWindow.org, MainWindow.name) + print('Deleting settings file ' + settings.fileName() + '\n') + # The config file may not exist yet + try: + os.remove(settings.fileName()) + except FileNotFoundError: + pass + sys.exit() + else: + app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5', + palette=qdarkstyle.DarkPalette)) + win = MainWindow() + if args.filename: + win.components['editor'].load_from_file(args.filename) -if __name__ == "__main__": + win.show() + sys.exit(app.exec_()) + +if __name__ == "__main__": main() diff --git a/cq_editor/cq_utils.py b/cq_editor/cq_utils.py index e32ba6c6..a16eb714 100644 --- a/cq_editor/cq_utils.py +++ b/cq_editor/cq_utils.py @@ -7,7 +7,7 @@ from OCP.XCAFPrs import XCAFPrs_AISObject from OCP.TopoDS import TopoDS_Shape -from OCP.AIS import AIS_InteractiveObject, AIS_Shape, AIS_ColoredShape +from OCP.AIS import AIS_Shape, AIS_ColoredShape from OCP.Quantity import \ Quantity_TOC_RGB as TOC_RGB, Quantity_Color @@ -50,7 +50,7 @@ def to_workplane(obj : cq.Shape): return rv -def make_AIS(obj : Union[cq.Workplane, List[cq.Workplane], cq.Shape, List[cq.Shape], cq.Assembly, AIS_InteractiveObject], +def make_AIS(obj : Union[cq.Workplane, List[cq.Workplane], cq.Shape, List[cq.Shape], cq.Assembly, AIS_Shape], options={}): shape = None @@ -58,7 +58,7 @@ def make_AIS(obj : Union[cq.Workplane, List[cq.Workplane], cq.Shape, List[cq.Sha if isinstance(obj, cq.Assembly): label, shape = toCAF(obj) ais = XCAFPrs_AISObject(label) - elif isinstance(obj, AIS_InteractiveObject): + elif isinstance(obj, AIS_Shape): ais = obj else: shape = to_compound(obj) diff --git a/cq_editor/main_window.py b/cq_editor/main_window.py index abe00a01..8f664d8a 100644 --- a/cq_editor/main_window.py +++ b/cq_editor/main_window.py @@ -1,9 +1,12 @@ import sys -from PyQt5.QtWidgets import (QLabel, QMainWindow, QToolBar, QDockWidget, QAction) +from PyQt5.QtWidgets import (QLabel, QMainWindow, QToolBar, + QDockWidget, QAction, QApplication) import cadquery as cq +import qdarkstyle + from .widgets.editor import Editor from .widgets.viewer import OCCViewer from .widgets.console import ConsoleWidget @@ -19,17 +22,25 @@ from .icons import icon from .preferences import PreferencesWidget +from pyqtgraph.parametertree import Parameter, ParameterTree class MainWindow(QMainWindow,MainMixin): name = 'CQ-Editor' org = 'CadQuery' - def __init__(self,parent=None, filename=None): + def __init__(self,parent=None): super(MainWindow,self).__init__(parent) MainMixin.__init__(self) + self.preferences = Parameter.create(name='Preferences',children=[ + {'name': 'Application color theme', 'type': 'list', + 'values': ['Light','Dark'], 'value': 'Dark'}]) + + self.preferences.sigTreeStateChanged.connect(self.preferencesChanged) + + self.setWindowIcon(icon('app')) self.viewer = OCCViewer(self) @@ -53,11 +64,22 @@ def __init__(self,parent=None, filename=None): self.restorePreferences() self.restoreWindow() + self.restoreComponentState() - if filename: - self.components['editor'].load_from_file(filename) + self.components['console'].appThemeChanged( + self.preferences['Application color theme']) - self.restoreComponentState() + + def preferencesChanged(self, *args): + + if self.preferences['Application color theme'] == 'Light': + QApplication.instance().setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5', + palette=qdarkstyle.LightPalette)) + self.components['console'].appThemeChanged('Light') #Set console light bg + elif self.preferences['Application color theme'] == 'Dark': + QApplication.instance().setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5', + palette=qdarkstyle.DarkPalette)) + self.components['console'].appThemeChanged('Dark') #Set console dark bg def closeEvent(self,event): @@ -99,7 +121,7 @@ def prepare_panes(self): 'Console', self, defaultArea='bottom')) - + self.registerComponent('traceback_viewer', TracebackPane(self), lambda c: dock(c, diff --git a/cq_editor/mixins.py b/cq_editor/mixins.py index f48f0d23..8a9cf14d 100644 --- a/cq_editor/mixins.py +++ b/cq_editor/mixins.py @@ -14,16 +14,12 @@ class MainMixin(object): - name = 'Main' - org = 'Unknown' - components = {} docks = {} preferences = None def __init__(self): - - self.settings = QSettings(self.org,self.name) + self.settings = QSettings(self.org, self.name) def registerComponent(self,name,component,dock=None): @@ -121,4 +117,4 @@ def saveComponentState(self,store): def restoreComponentState(self,store): - pass \ No newline at end of file + pass diff --git a/cq_editor/widgets/console.py b/cq_editor/widgets/console.py index 77fd1dcc..d6288286 100644 --- a/cq_editor/widgets/console.py +++ b/cq_editor/widgets/console.py @@ -15,7 +15,10 @@ def __init__(self, customBanner=None, namespace=dict(), *args, **kwargs): # if not customBanner is None: # self.banner = customBanner - + +# super(RichJupyterWidget, self).set_color_scheme('Monokai') + +# self.set_default_style('linux') self.font_size = 6 self.kernel_manager = kernel_manager = QtInProcessKernelManager() kernel_manager.start_kernel(show_banner=False) @@ -36,6 +39,12 @@ def stop(): self.push_vars(namespace) + def appThemeChanged(self, appTheme): + if appTheme == 'Light': + self.set_default_style('lightbg') # Style with light bg + elif appTheme == 'Dark': + self.set_default_style('linux') # Style with dark bg + @pyqtSlot(dict) def push_vars(self, variableDict): """ @@ -69,11 +78,11 @@ def _banner_default(self): if __name__ == "__main__": - - import sys - app = QApplication(sys.argv) + app = QApplication.instance() + if app is None: + app = QApplication(sys.argv) console = ConsoleWidget(customBanner='IPython console test') console.show() diff --git a/cq_editor/widgets/debugger.py b/cq_editor/widgets/debugger.py index ffddfa03..25fd5b4a 100644 --- a/cq_editor/widgets/debugger.py +++ b/cq_editor/widgets/debugger.py @@ -356,10 +356,7 @@ def trace_local(self,frame,event,arg): def module_manager(): """ unloads any modules loaded while the context manager is active """ loaded_modules = set(sys.modules.keys()) - - try: - yield - finally: - new_modules = set(sys.modules.keys()) - loaded_modules - for module_name in new_modules: - del sys.modules[module_name] + yield + new_modules = set(sys.modules.keys()) - loaded_modules + for module_name in new_modules: + del sys.modules[module_name] diff --git a/cq_editor/widgets/editor.py b/cq_editor/widgets/editor.py index 128891b4..b2e75678 100644 --- a/cq_editor/widgets/editor.py +++ b/cq_editor/widgets/editor.py @@ -32,7 +32,7 @@ class Editor(CodeEditor,ComponentMixin): {'name': 'Autoreload: watch imported modules', 'type': 'bool', 'value': False}, {'name': 'Line wrap', 'type': 'bool', 'value': False}, {'name': 'Color scheme', 'type': 'list', - 'values': ['Spyder','Monokai','Zenburn'], 'value': 'Spyder'}]) + 'values': ['Spyder','Monokai','Zenburn'], 'value': 'Monokai'}]) EXTENSIONS = 'py' @@ -212,12 +212,10 @@ def _clear_watched_paths(self): self._file_watcher.removePaths(paths) def _watch_paths(self): - if Path(self._filename).exists(): + if self._filename: self._file_watcher.addPath(self._filename) if self.preferences['Autoreload: watch imported modules']: - module_paths = self.get_imported_module_paths(self._filename) - if module_paths: - self._file_watcher.addPaths(module_paths) + self._file_watcher.addPaths(get_imported_module_paths(self._filename)) # callback triggered by QFileSystemWatcher def _file_changed(self): @@ -247,43 +245,35 @@ def saveComponentState(self,store): def restoreComponentState(self,store): - filename = store.value(self.name+'/state') + filename = store.value(self.name+'/state',self.filename) - if filename and self.filename == '': + if filename and filename != '': try: self.load_from_file(filename) except IOError: self._logger.warning(f'could not open {filename}') - def get_imported_module_paths(self, module_path): - - finder = ModuleFinder([os.path.dirname(module_path)]) - imported_modules = [] - - try: - finder.run_script(module_path) - except SyntaxError as err: - self._logger.warning(f'Syntax error in {module_path}: {err}') - except Exception as err: - self._logger.warning( - f'Cannot determine imported modules in {module_path}: {type(err).__name__} {err}' - ) - else: - for module_name, module in finder.modules.items(): - if module_name != '__main__': - path = getattr(module, '__file__', None) - if path is not None and os.path.isfile(path): - imported_modules.append(path) - - return imported_modules +def get_imported_module_paths(module_path): + finder = ModuleFinder([os.path.dirname(module_path)]) + finder.run_script(module_path) + imported_modules = [] + for module_name, module in finder.modules.items(): + if module_name != '__main__': + path = getattr(module, '__file__', None) + if path is not None and os.path.isfile(path): + imported_modules.append(path) + return imported_modules if __name__ == "__main__": from PyQt5.QtWidgets import QApplication - app = QApplication(sys.argv) + app = QApplication.instance() + if app is None: + app = QApplication(sys.argv) + editor = Editor() editor.show() diff --git a/cq_editor/widgets/object_tree.py b/cq_editor/widgets/object_tree.py index c0ea1dcf..f4e75717 100644 --- a/cq_editor/widgets/object_tree.py +++ b/cq_editor/widgets/object_tree.py @@ -20,10 +20,10 @@ def __init__(self,*args,**kwargs): class ObjectTreeItem(QTreeWidgetItem): - props = [{'name': 'Name', 'type': 'str', 'value': ''}, - {'name': 'Color', 'type': 'color', 'value': "f4a824"}, - {'name': 'Alpha', 'type': 'float', 'value': 0, 'limits': (0,1), 'step': 1e-1}, - {'name': 'Visible', 'type': 'bool','value': True}] +# props = [{'name': 'Name', 'type': 'str', 'value': ''}, +# {'name': 'Color', 'type': 'color', 'value': "f4a824"}, +# {'name': 'Alpha', 'type': 'float', 'value': 0, 'limits': (0,1), 'step': 1e-1}, +# {'name': 'Visible', 'type': 'bool','value': True}] def __init__(self, name, @@ -44,8 +44,11 @@ def __init__(self, self.shape_display = shape_display self.sig = sig - self.properties = Parameter.create(name='Properties', - children=self.props) + self.properties = Parameter.create(name='Properties', children=[ + {'name': 'Name', 'type': 'str', 'value': ''}, + {'name': 'Color', 'type': 'color', 'value': "f4a824"}, + {'name': 'Alpha', 'type': 'float', 'value': 0, 'limits': (0,1), 'step': 1e-1}, + {'name': 'Visible', 'type': 'bool','value': True}]) self.properties['Name'] = name self.properties['Alpha'] = ais.Transparency() diff --git a/cq_editor/widgets/viewer.py b/cq_editor/widgets/viewer.py index f788fb13..ec16371b 100644 --- a/cq_editor/widgets/viewer.py +++ b/cq_editor/widgets/viewer.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -from OCP.Graphic3d import Graphic3d_Camera, Graphic3d_StereoMode from PyQt5.QtWidgets import (QWidget, QPushButton, QDialog, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QFileDialog, QHBoxLayout, QFrame, QLabel, QApplication, @@ -40,12 +39,8 @@ class OCCViewer(QWidget,ComponentMixin): {'name': 'Background color (aux)', 'type': 'color', 'value': (30,30,30)}, {'name': 'Default object color', 'type': 'color', 'value': "FF0"}, {'name': 'Deviation', 'type': 'float', 'value': 1e-5, 'dec': True, 'step': 1}, - {'name': 'Angular deviation', 'type': 'float', 'value': 0.1, 'dec': True, 'step': 1}, - {'name': 'Projection Type', 'type': 'list', 'value': 'Orthographic', - 'values': ['Orthographic', 'Perspective', 'Stereo', 'MonoLeftEye', 'MonoRightEye']}, - {'name': 'Stereo Mode', 'type': 'list', 'value': 'QuadBuffer', - 'values': ['QuadBuffer', 'Anaglyph', 'RowInterlaced', 'ColumnInterlaced', - 'ChessBoard', 'SideBySide', 'OverUnder']}]) + {'name': 'Angular deviation', 'type': 'float', 'value': 0.1, 'dec': True, 'step': 1}]) + IMAGE_EXTENSIONS = 'png' sigObjectSelected = pyqtSignal(list) @@ -82,70 +77,48 @@ def updatePreferences(self,*args): ctx.SetDeviationCoefficient(self.preferences['Deviation']) ctx.SetDeviationAngle(self.preferences['Angular deviation']) - v = self._get_view() - camera = v.Camera() - projection_type = self.preferences['Projection Type'] - camera.SetProjectionType(getattr(Graphic3d_Camera, f'Projection_{projection_type}', - Graphic3d_Camera.Projection_Orthographic)) - - # onle relevant for stereo projection - stereo_mode = self.preferences['Stereo Mode'] - params = v.ChangeRenderingParams() - params.StereoMode = getattr(Graphic3d_StereoMode, f'Graphic3d_StereoMode_{stereo_mode}', - Graphic3d_StereoMode.Graphic3d_StereoMode_QuadBuffer) - def create_actions(self,parent): self._actions = \ {'View' : [QAction(qta.icon('fa.arrows-alt'), - 'Fit (Shift+F1)', + 'Fit', parent, - shortcut='shift+F1', triggered=self.fit), QAction(QIcon(':/images/icons/isometric_view.svg'), - 'Iso (Shift+F2)', + 'Iso', parent, - shortcut='shift+F2', triggered=self.iso_view), QAction(QIcon(':/images/icons/top_view.svg'), - 'Top (Shift+F3)', + 'Top', parent, - shortcut='shift+F3', triggered=self.top_view), QAction(QIcon(':/images/icons/bottom_view.svg'), - 'Bottom (Shift+F4)', + 'Bottom', parent, - shortcut='shift+F4', triggered=self.bottom_view), QAction(QIcon(':/images/icons/front_view.svg'), - 'Front (Shift+F5)', + 'Front', parent, - shortcut='shift+F5', triggered=self.front_view), QAction(QIcon(':/images/icons/back_view.svg'), - 'Back (Shift+F6)', + 'Back', parent, - shortcut='shift+F6', triggered=self.back_view), QAction(QIcon(':/images/icons/left_side_view.svg'), - 'Left (Shift+F7)', + 'Left', parent, - shortcut='shift+F7', triggered=self.left_view), QAction(QIcon(':/images/icons/right_side_view.svg'), - 'Right (Shift+F8)', + 'Right', parent, - shortcut='shift+F8', triggered=self.right_view), QAction(qta.icon('fa.square-o'), - 'Wireframe (Shift+F9)', + 'Wireframe', parent, - shortcut='shift+F9', triggered=self.wireframe_view), QAction(qta.icon('fa.square'), - 'Shaded (Shift+F10)', + 'Shaded', parent, - shortcut='shift+F10', triggered=self.shaded_view)], 'Tools' : [QAction(icon('screenshot'), 'Screenshot', @@ -362,7 +335,10 @@ def set_selected(self,ais): import sys from OCP.BRepPrimAPI import BRepPrimAPI_MakeBox - app = QApplication(sys.argv) + app = QApplication.instance() + if app is None: + app = QApplication(sys.argv) + viewer = OCCViewer() dlg = QDialog() diff --git a/cqgui_env.yml b/cqgui_env.yml index 79ba4b28..c23250d2 100644 --- a/cqgui_env.yml +++ b/cqgui_env.yml @@ -1,13 +1,309 @@ -name: cq-occ-conda-test-py3 +name: cqgui channels: - - CadQuery - - conda-forge +- https://conda.anaconda.org +- https://repo.anaconda.com/pkgs dependencies: - - pyqt=5 - - pyqtgraph - - python=3.10 - - spyder=5 - - path - - logbook - - requests - - cadquery=master +- spyder=5.3.0=py310hff52083_0 +- python-lsp-server=1.4.1=pyhd8ed1ab_1 +- pyflakes=2.4.0=pyhd8ed1ab_0 +- jinja2-time=0.2.0=pyhd8ed1ab_3 +- qstylizer=0.2.1=pyhd8ed1ab_0 +- pycodestyle=2.8.0=pyhd8ed1ab_0 +- arrow=1.2.2=pyhd8ed1ab_0 +- unidecode=1.3.4=pyhd8ed1ab_0 +- cookiecutter=1.7.3=pyh6c4a22f_1 +- text-unidecode=1.3=py_0 +- tinycss2=1.1.1=pyhd8ed1ab_0 +- autopep8=1.6.0=pyhd8ed1ab_1 +- inflection=0.5.1=pyh9f0ad1d_0 +- qdarkstyle=3.0.3=pyhd8ed1ab_0 +- spyder-kernels=2.3.0=py310hff52083_0 +- jellyfish=0.9.0=py310h6acc77f_0 +- ipython=7.32.0=py310hff52083_0 +- cadquery=master=py3.10 +- vtk=9.0.1=qt_py310h8cd55b6_210 +- watchdog=2.1.7=py310hff52083_1 +- wurlitzer=3.0.2=py310hff52083_1 +- pyyaml=6.0=py310h5764c6d_4 +- path=16.4.0=py310hff52083_1 +- pyqtgraph=0.12.4=pyhd8ed1ab_0 +- argh=0.26.2=pyh9f0ad1d_1002 +- three-merge=0.1.1=pyh9f0ad1d_0 +- textdistance=4.2.2=pyhd8ed1ab_0 +- qtconsole-base=5.3.0=pyhd8ed1ab_0 +- ipykernel=6.12.1=py310hfdc917e_0 +- python-lsp-jsonrpc=1.0.0=pyhd8ed1ab_0 +- debugpy=1.5.1=py310h122e73d_0 +- ipython_genutils=0.2.0=py_1 +- helpdev=0.7.1=pyhd8ed1ab_0 +- qtpy=2.0.1=pyhd8ed1ab_0 +- pyxdg=0.27=pyhd8ed1ab_0 +- ld_impl_linux-64=2.36.1=hea4e1c9_2 +- soupsieve=2.3.1=pyhd8ed1ab_0 +- mysql-libs=8.0.28=h28c427c_3 +- nbconvert-core=6.4.5=pyhd8ed1ab_2 +- mysql-common=8.0.28=haf5c9bc_3 +- openssl=1.1.1n=h166bdaf_0 +- python=3.10.4=h9a8a25e_0_cpython +- typing_extensions=4.1.1=pyha770c72_0 +- importlib_metadata=4.11.3=hd8ed1ab_1 +- liblapack=3.9.0=11_linux64_openblas +- backports=1.0=py_2 +- binaryornot=0.4.4=py_1 +- gstreamer=1.20.1=hd4edc92_1 +- libblas=3.9.0=11_linux64_openblas +- libnsl=2.0.0=h7f98852_0 +- libzip=1.8.0=h4de3113_1 +- font-ttf-ubuntu=0.83=hab24e00_0 +- libevent=2.1.10=h9b69904_4 +- font-ttf-source-code-pro=2.038=h77eed37_0 +- freeimage=3.18.0=h88c329d_7 +- libnetcdf=4.8.1=nompi_hcd642e3_100 +- proj=7.2.0=h277dcde_2 +- pyqt-impl=5.12.3=py310h1f8e252_8 +- ffmpeg=4.3.2=h37c90e5_3 +- bleach=4.1.0=pyhd8ed1ab_0 +- tomli=2.0.1=pyhd8ed1ab_0 +- libraw=0.20.2=h10796ff_1 +- double-conversion=3.1.7=h9c3ff4c_0 +- libxkbcommon=1.0.3=he3ba5ed_0 +- pydocstyle=6.1.1=pyhd8ed1ab_0 +- libtheora=1.1.1=h7f98852_1005 +- black=22.3.0=pyhd8ed1ab_0 +- lazy-object-proxy=1.7.1=py310h5764c6d_1 +- gmp=6.2.1=h58526e2_0 +- requests=2.27.1=pyhd8ed1ab_0 +- logbook=1.5.3=py310h6acc77f_5 +- freetype=2.10.4=h0708190_1 +- openjpeg=2.4.0=hb52868f_1 +- libedit=3.1.20191231=he28a2e2_2 +- python-dateutil=2.8.2=pyhd8ed1ab_0 +- qtconsole=5.3.0=pyhd8ed1ab_0 +- python-fastjsonschema=2.15.3=pyhd8ed1ab_0 +- nss=3.77=h2350873_0 +- rtree=0.9.7=py310hbdcdc62_3 +- dbus=1.13.6=h5008d03_3 +- yapf=0.32.0=pyhd8ed1ab_0 +- sqlite=3.37.1=h4ff8645_0 +- libopenblas=0.3.17=hf726d26_1 +- libtiff=4.3.0=h542a066_3 +- xorg-libxext=1.3.4=h7f98852_1 +- zstd=1.5.2=ha95c52a_0 +- nlopt=2.7.1=py310hf38e9df_0 +- readline=8.1=h46c0cb4_0 +- pexpect=4.8.0=pyh9f0ad1d_2 +- zeromq=4.3.4=h9c3ff4c_1 +- libglu=9.0.0=he1b5a44_1001 +- sphinxcontrib-devhelp=1.0.2=py_0 +- libopus=1.3.1=h7f98852_1 +- pycparser=2.21=pyhd8ed1ab_0 +- eigen=3.4.0=h4bd325d_0 +- pyls-spyder=0.4.0=pyhd8ed1ab_0 +- ncurses=6.3=h9c3ff4c_0 +- pyqt=5.12.3=py310hff52083_8 +- rapidjson=1.1.0=he1b5a44_1002 +- xorg-libxdmcp=1.1.3=h7f98852_0 +- sphinxcontrib-jsmath=1.0.1=py_0 +- gl2ps=1.4.2=h0708190_0 +- libgfortran4=7.5.0=h14aa051_20 +- libogg=1.3.4=h7f98852_1 +- krb5=1.19.3=h3790be6_0 +- pyqtwebengine=5.12.1=py310hfcd6d55_8 +- libuuid=2.32.1=h7f98852_1000 +- libvorbis=1.3.7=h9c3ff4c_0 +- xorg-libx11=1.7.2=h7f98852_0 +- nbconvert=6.4.5=pyhd8ed1ab_2 +- alsa-lib=1.2.3=h516909a_0 +- libxml2=2.9.12=h885dcf4_1 +- loguru=0.5.3=py310hff52083_3 +- xorg-libxau=1.0.9=h7f98852_0 +- xorg-kbproto=1.0.7=h7f98852_1002 +- ca-certificates=2021.10.8=ha878542_0 +- asttokens=2.0.5=pyhd8ed1ab_0 +- libcblas=3.9.0=11_linux64_openblas +- libgomp=11.2.0=h1d223b6_14 +- openexr=2.5.5=hf817b99_0 +- click=8.1.2=py310hff52083_0 +- importlib_resources=5.6.0=pyhd8ed1ab_0 +- libxcb=1.13=h7f98852_1004 +- x264=1!161.3030=h7f98852_1 +- multimethod=1.6=pyhd8ed1ab_0 +- chardet=4.0.0=py310hff52083_3 +- qtawesome=1.1.1=pyhd8ed1ab_0 +- libclang=13.0.1=default_hc23dcda_0 +- lz4-c=1.9.3=h9c3ff4c_1 +- brotlipy=0.7.0=py310h5764c6d_1004 +- c-ares=1.18.1=h7f98852_0 +- xz=5.2.5=h516909a_1 +- libsodium=1.0.18=h36c2ea0_1 +- jxrlib=1.1=h7f98852_2 +- hdf5=1.10.6=nompi_h3c11f04_101 +- jpeg=9e=h7f98852_0 +- xorg-libice=1.0.10=h7f98852_0 +- libspatialindex=1.9.3=h9c3ff4c_4 +- libgfortran-ng=7.5.0=h14aa051_20 +- lcms2=2.12=hddcbb42_0 +- font-ttf-inconsolata=3.000=h77eed37_0 +- path.py=12.5.0=0 +- libglib=2.70.2=h174f98d_4 +- libnghttp2=1.47.0=h727a467_0 +- glew=2.1.0=h9c3ff4c_2 +- libiconv=1.16=h516909a_0 +- fonts-conda-ecosystem=1=0 +- lerc=3.0=h9c3ff4c_0 +- occt=7.5.3=h7391655_0 +- xorg-xextproto=7.3.0=h7f98852_1002 +- gst-plugins-base=1.20.1=hcf0ee16_1 +- pcre=8.45=h9c3ff4c_0 +- pandoc=2.17.1.1=ha770c72_0 +- typing-extensions=4.1.1=hd8ed1ab_0 +- pyparsing=3.0.7=pyhd8ed1ab_0 +- libllvm13=13.0.1=hf817b99_2 +- backports.functools_lru_cache=1.6.4=pyhd8ed1ab_0 +- parso=0.7.0=pyh9f0ad1d_0 +- keyutils=1.6.1=h166bdaf_0 +- libstdcxx-ng=11.2.0=he4da1e4_14 +- _openmp_mutex=4.5=1_gnu +- python-slugify=6.1.1=pyhd8ed1ab_0 +- tzdata=2022a=h191b570_0 +- xorg-libxt=1.2.1=h7f98852_2 +- tbb-devel=2020.2=h4bd325d_4 +- intervaltree=3.0.2=py_0 +- libwebp-base=1.2.2=h7f98852_1 +- pugixml=1.11.4=h9c3ff4c_0 +- ocp=7.5.3.0=py310h75af40c_2 +- yaml=0.2.5=h7f98852_2 +- libpq=14.2=hd57d9b9_0 +- jbig=2.1=h7f98852_2003 +- poyo=0.5.0=py_0 +- libpng=1.6.37=h21135ba_2 +- nspr=4.32=h9c3ff4c_1 +- alabaster=0.7.12=py_0 +- sphinxcontrib-serializinghtml=1.1.5=pyhd8ed1ab_1 +- gettext=0.19.8.1=h73d1719_1008 +- libev=4.33=h516909a_1 +- _libgcc_mutex=0.1=conda_forge +- gnutls=3.6.13=h85f3911_1 +- lame=3.100=h7f98852_1001 +- expat=2.4.8=h27087fc_0 +- ilmbase=2.5.5=h780b84a_0 +- python_abi=3.10=2_cp310 +- typish=1.9.3=pyhd8ed1ab_0 +- nbformat=5.3.0=pyhd8ed1ab_0 +- tbb=2020.2=h4bd325d_4 +- icu=69.1=h9c3ff4c_0 +- utfcpp=3.2.1=ha770c72_0 +- libssh2=1.10.0=ha56f1ee_2 +- libzlib=1.2.11=h166bdaf_1014 +- qt=5.12.9=h1304e3e_6 +- font-ttf-dejavu-sans-mono=2.37=hab24e00_0 +- xorg-libsm=1.2.3=hd9c2040_1000 +- pybind11-abi=4=hd8ed1ab_3 +- setuptools=62.0.0=py310hff52083_0 +- pygments=2.11.2=pyhd8ed1ab_0 +- hdf4=4.2.15=h10796ff_3 +- nptyping=1.4.4=pyhd8ed1ab_0 +- fonts-conda-forge=1=0 +- pip=22.0.4=pyhd8ed1ab_0 +- atomicwrites=1.4.0=pyh9f0ad1d_0 +- ezdxf=0.17.2=py310h91b1402_0 +- defusedxml=0.7.1=pyhd8ed1ab_0 +- jedi=0.17.2=py310hff52083_2 +- curl=7.82.0=h7bff187_0 +- wheel=0.37.1=pyhd8ed1ab_0 +- decorator=5.1.1=pyhd8ed1ab_0 +- ptyprocess=0.7.0=pyhd3deb0d_0 +- flake8=4.0.1=pyhd8ed1ab_2 +- pylint=2.13.4=pyhd8ed1ab_0 +- entrypoints=0.4=pyhd8ed1ab_0 +- xorg-xproto=7.0.31=h7f98852_1007 +- nest-asyncio=1.5.5=pyhd8ed1ab_0 +- babel=2.9.1=pyh44b312d_0 +- traitlets=5.1.1=pyhd8ed1ab_0 +- pthread-stubs=0.4=h36c2ea0_1001 +- sphinxcontrib-qthelp=1.0.3=py_0 +- backcall=0.2.0=pyh9f0ad1d_0 +- python-lsp-black=1.2.0=pyhd8ed1ab_0 +- rope=0.23.0=pyhd8ed1ab_0 +- six=1.16.0=pyh6c4a22f_0 +- libcurl=7.82.0=h7bff187_0 +- pyopenssl=22.0.0=pyhd8ed1ab_0 +- stack_data=0.2.0=pyhd8ed1ab_0 +- wcwidth=0.2.5=pyh9f0ad1d_2 +- zlib=1.2.11=h166bdaf_1014 +- jsoncpp=1.9.4=h4bd325d_3 +- prompt-toolkit=3.0.29=pyha770c72_0 +- keyring=23.4.0=py310hff52083_2 +- colorama=0.4.4=pyh9f0ad1d_0 +- urllib3=1.26.9=pyhd8ed1ab_0 +- numpy=1.22.3=py310h45f3432_1 +- tornado=6.1=py310h5764c6d_3 +- cloudpickle=2.0.0=pyhd8ed1ab_0 +- diff-match-patch=20200713=pyh9f0ad1d_0 +- tk=8.6.12=h27826a3_0 +- sortedcontainers=2.4.0=pyhd8ed1ab_0 +- certifi=2021.10.8=py310hff52083_2 +- attrs=21.4.0=pyhd8ed1ab_0 +- libdeflate=1.10=h7f98852_0 +- zipp=3.8.0=pyhd8ed1ab_0 +- pyrsistent=0.18.1=py310h5764c6d_1 +- beautifulsoup4=4.10.0=pyha770c72_0 +- importlib-metadata=4.11.3=py310hff52083_1 +- jsonschema=4.4.0=pyhd8ed1ab_0 +- jeepney=0.8.0=pyhd8ed1ab_0 +- cffi=1.15.0=py310h0fdd8cc_0 +- cryptography=36.0.2=py310h597c629_1 +- matplotlib-inline=0.1.3=pyhd8ed1ab_0 +- markupsafe=2.1.1=py310h5764c6d_1 +- mistune=0.8.4=py310h6acc77f_1005 +- nettle=3.6=he412f7d_0 +- sphinxcontrib-htmlhelp=2.0.0=pyhd8ed1ab_0 +- pure_eval=0.2.2=pyhd8ed1ab_0 +- pluggy=1.0.0=py310hff52083_3 +- fontconfig=2.14.0=h8e229c2_0 +- future=0.18.2=py310hff52083_5 +- jupyterlab_pygments=0.1.2=pyh9f0ad1d_0 +- pandocfilters=1.5.0=pyhd8ed1ab_0 +- testpath=0.6.0=pyhd8ed1ab_0 +- pickleshare=0.7.5=py_1003 +- packaging=21.3=pyhd8ed1ab_0 +- pytz=2022.1=pyhd8ed1ab_0 +- psutil=5.9.0=py310h5764c6d_1 +- dataclasses=0.8=pyhc8e2a94_3 +- jupyter_client=7.2.1=pyhd8ed1ab_0 +- nbclient=0.5.13=pyhd8ed1ab_0 +- jupyter_core=4.9.2=py310hff52083_0 +- nbconvert-pandoc=6.4.5=pyhd8ed1ab_2 +- idna=3.3=pyhd8ed1ab_0 +- pyzmq=22.3.0=py310h330234f_2 +- webencodings=0.5.1=py_1 +- charset-normalizer=2.0.12=pyhd8ed1ab_0 +- imagesize=1.3.0=pyhd8ed1ab_0 +- snowballstemmer=2.2.0=pyhd8ed1ab_0 +- sphinxcontrib-applehelp=1.0.2=py_0 +- libffi=3.4.2=h7f98852_5 +- pysocks=1.7.1=py310hff52083_5 +- openh264=2.1.1=h780b84a_0 +- docutils=0.17.1=py310hff52083_1 +- sphinx=4.5.0=pyh6c4a22f_0 +- numpydoc=1.2.1=pyhd8ed1ab_2 +- wrapt=1.14.0=py310h5764c6d_1 +- astroid=2.11.2=py310hff52083_0 +- bzip2=1.0.8=h7f98852_4 +- mccabe=0.6.1=py_1 +- isort=5.10.1=pyhd8ed1ab_0 +- dill=0.3.4=pyhd8ed1ab_0 +- platformdirs=2.5.1=pyhd8ed1ab_0 +- toml=0.10.2=pyhd8ed1ab_0 +- libgcc-ng=11.2.0=h1d223b6_14 +- ujson=5.1.0=py310hd8f1fbe_1 +- secretstorage=3.3.1=py310hff52083_1 +- python-jsonrpc-server=0.4.0=pyh9f0ad1d_0 +- pathspec=0.9.0=pyhd8ed1ab_0 +- mypy_extensions=0.4.3=py310hff52083_5 +- typed-ast=1.5.2=py310h6acc77f_0 +- executing=0.8.3=pyhd8ed1ab_0 +- pyqt5-sip=4.19.18=py310h122e73d_8 +- jinja2=3.0.3=pyhd8ed1ab_0 +- pyqtchart=5.12=py310hfcd6d55_8 + diff --git a/description b/description new file mode 100644 index 00000000..498b267a --- /dev/null +++ b/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/hooks/applypatch-msg.sample b/hooks/applypatch-msg.sample new file mode 100755 index 00000000..a5d7b84a --- /dev/null +++ b/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} +: diff --git a/hooks/commit-msg.sample b/hooks/commit-msg.sample new file mode 100755 index 00000000..b58d1184 --- /dev/null +++ b/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/hooks/fsmonitor-watchman.sample b/hooks/fsmonitor-watchman.sample new file mode 100755 index 00000000..14ed0aa4 --- /dev/null +++ b/hooks/fsmonitor-watchman.sample @@ -0,0 +1,173 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use IPC::Open2; + +# An example hook script to integrate Watchman +# (https://facebook.github.io/watchman/) with git to speed up detecting +# new and modified files. +# +# The hook is passed a version (currently 2) and last update token +# formatted as a string and outputs to stdout a new update token and +# all files that have been modified since the update token. Paths must +# be relative to the root of the working tree and separated by a single NUL. +# +# To enable this hook, rename this file to "query-watchman" and set +# 'git config core.fsmonitor .git/hooks/query-watchman' +# +my ($version, $last_update_token) = @ARGV; + +# Uncomment for debugging +# print STDERR "$0 $version $last_update_token\n"; + +# Check the hook interface version +if ($version ne 2) { + die "Unsupported query-fsmonitor hook version '$version'.\n" . + "Falling back to scanning...\n"; +} + +my $git_work_tree = get_working_dir(); + +my $retry = 1; + +my $json_pkg; +eval { + require JSON::XS; + $json_pkg = "JSON::XS"; + 1; +} or do { + require JSON::PP; + $json_pkg = "JSON::PP"; +}; + +launch_watchman(); + +sub launch_watchman { + my $o = watchman_query(); + if (is_work_tree_watched($o)) { + output_result($o->{clock}, @{$o->{files}}); + } +} + +sub output_result { + my ($clockid, @files) = @_; + + # Uncomment for debugging watchman output + # open (my $fh, ">", ".git/watchman-output.out"); + # binmode $fh, ":utf8"; + # print $fh "$clockid\n@files\n"; + # close $fh; + + binmode STDOUT, ":utf8"; + print $clockid; + print "\0"; + local $, = "\0"; + print @files; +} + +sub watchman_clock { + my $response = qx/watchman clock "$git_work_tree"/; + die "Failed to get clock id on '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + + return $json_pkg->new->utf8->decode($response); +} + +sub watchman_query { + my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') + or die "open2() failed: $!\n" . + "Falling back to scanning...\n"; + + # In the query expression below we're asking for names of files that + # changed since $last_update_token but not from the .git folder. + # + # To accomplish this, we're using the "since" generator to use the + # recency index to select candidate nodes and "fields" to limit the + # output to file names only. Then we're using the "expression" term to + # further constrain the results. + if (substr($last_update_token, 0, 1) eq "c") { + $last_update_token = "\"$last_update_token\""; + } + my $query = <<" END"; + ["query", "$git_work_tree", { + "since": $last_update_token, + "fields": ["name"], + "expression": ["not", ["dirname", ".git"]] + }] + END + + # Uncomment for debugging the watchman query + # open (my $fh, ">", ".git/watchman-query.json"); + # print $fh $query; + # close $fh; + + print CHLD_IN $query; + close CHLD_IN; + my $response = do {local $/; }; + + # Uncomment for debugging the watch response + # open ($fh, ">", ".git/watchman-response.json"); + # print $fh $response; + # close $fh; + + die "Watchman: command returned no output.\n" . + "Falling back to scanning...\n" if $response eq ""; + die "Watchman: command returned invalid output: $response\n" . + "Falling back to scanning...\n" unless $response =~ /^\{/; + + return $json_pkg->new->utf8->decode($response); +} + +sub is_work_tree_watched { + my ($output) = @_; + my $error = $output->{error}; + if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) { + $retry--; + my $response = qx/watchman watch "$git_work_tree"/; + die "Failed to make watchman watch '$git_work_tree'.\n" . + "Falling back to scanning...\n" if $? != 0; + $output = $json_pkg->new->utf8->decode($response); + $error = $output->{error}; + die "Watchman: $error.\n" . + "Falling back to scanning...\n" if $error; + + # Uncomment for debugging watchman output + # open (my $fh, ">", ".git/watchman-output.out"); + # close $fh; + + # Watchman will always return all files on the first query so + # return the fast "everything is dirty" flag to git and do the + # Watchman query just to get it over with now so we won't pay + # the cost in git to look up each individual file. + my $o = watchman_clock(); + $error = $output->{error}; + + die "Watchman: $error.\n" . + "Falling back to scanning...\n" if $error; + + output_result($o->{clock}, ("/")); + $last_update_token = $o->{clock}; + + eval { launch_watchman() }; + return 0; + } + + die "Watchman: $error.\n" . + "Falling back to scanning...\n" if $error; + + return 1; +} + +sub get_working_dir { + my $working_dir; + if ($^O =~ 'msys' || $^O =~ 'cygwin') { + $working_dir = Win32::GetCwd(); + $working_dir =~ tr/\\/\//; + } else { + require Cwd; + $working_dir = Cwd::cwd(); + } + + return $working_dir; +} diff --git a/hooks/post-update.sample b/hooks/post-update.sample new file mode 100755 index 00000000..ec17ec19 --- /dev/null +++ b/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/hooks/pre-applypatch.sample b/hooks/pre-applypatch.sample new file mode 100755 index 00000000..4142082b --- /dev/null +++ b/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +precommit="$(git rev-parse --git-path hooks/pre-commit)" +test -x "$precommit" && exec "$precommit" ${1+"$@"} +: diff --git a/hooks/pre-commit.sample b/hooks/pre-commit.sample new file mode 100755 index 00000000..e144712c --- /dev/null +++ b/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=$(git hash-object -t tree /dev/null) +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --type=bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/hooks/pre-merge-commit.sample b/hooks/pre-merge-commit.sample new file mode 100755 index 00000000..399eab19 --- /dev/null +++ b/hooks/pre-merge-commit.sample @@ -0,0 +1,13 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git merge" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message to +# stderr if it wants to stop the merge commit. +# +# To enable this hook, rename this file to "pre-merge-commit". + +. git-sh-setup +test -x "$GIT_DIR/hooks/pre-commit" && + exec "$GIT_DIR/hooks/pre-commit" +: diff --git a/hooks/pre-push.sample b/hooks/pre-push.sample new file mode 100755 index 00000000..4ce688d3 --- /dev/null +++ b/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +zero=$(git hash-object --stdin &2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/hooks/pre-rebase.sample b/hooks/pre-rebase.sample new file mode 100755 index 00000000..6cbef5c3 --- /dev/null +++ b/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up to date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +<<\DOC_END + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". + +DOC_END diff --git a/hooks/pre-receive.sample b/hooks/pre-receive.sample new file mode 100755 index 00000000..a1fd29ec --- /dev/null +++ b/hooks/pre-receive.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to make use of push options. +# The example simply echoes all push options that start with 'echoback=' +# and rejects all pushes when the "reject" push option is used. +# +# To enable this hook, rename this file to "pre-receive". + +if test -n "$GIT_PUSH_OPTION_COUNT" +then + i=0 + while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" + do + eval "value=\$GIT_PUSH_OPTION_$i" + case "$value" in + echoback=*) + echo "echo from the pre-receive-hook: ${value#*=}" >&2 + ;; + reject) + exit 1 + esac + i=$((i + 1)) + done +fi diff --git a/hooks/prepare-commit-msg.sample b/hooks/prepare-commit-msg.sample new file mode 100755 index 00000000..10fa14c5 --- /dev/null +++ b/hooks/prepare-commit-msg.sample @@ -0,0 +1,42 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first one removes the +# "# Please enter the commit message..." help message. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +COMMIT_MSG_FILE=$1 +COMMIT_SOURCE=$2 +SHA1=$3 + +/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" + +# case "$COMMIT_SOURCE,$SHA1" in +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; +# *) ;; +# esac + +# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" +# if test -z "$COMMIT_SOURCE" +# then +# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" +# fi diff --git a/hooks/push-to-checkout.sample b/hooks/push-to-checkout.sample new file mode 100755 index 00000000..af5a0c00 --- /dev/null +++ b/hooks/push-to-checkout.sample @@ -0,0 +1,78 @@ +#!/bin/sh + +# An example hook script to update a checked-out tree on a git push. +# +# This hook is invoked by git-receive-pack(1) when it reacts to git +# push and updates reference(s) in its repository, and when the push +# tries to update the branch that is currently checked out and the +# receive.denyCurrentBranch configuration variable is set to +# updateInstead. +# +# By default, such a push is refused if the working tree and the index +# of the remote repository has any difference from the currently +# checked out commit; when both the working tree and the index match +# the current commit, they are updated to match the newly pushed tip +# of the branch. This hook is to be used to override the default +# behaviour; however the code below reimplements the default behaviour +# as a starting point for convenient modification. +# +# The hook receives the commit with which the tip of the current +# branch is going to be updated: +commit=$1 + +# It can exit with a non-zero status to refuse the push (when it does +# so, it must not modify the index or the working tree). +die () { + echo >&2 "$*" + exit 1 +} + +# Or it can make any necessary changes to the working tree and to the +# index to bring them to the desired state when the tip of the current +# branch is updated to the new commit, and exit with a zero status. +# +# For example, the hook can simply run git read-tree -u -m HEAD "$1" +# in order to emulate git fetch that is run in the reverse direction +# with git push, as the two-tree form of git read-tree -u -m is +# essentially the same as git switch or git checkout that switches +# branches while keeping the local changes in the working tree that do +# not interfere with the difference between the branches. + +# The below is a more-or-less exact translation to shell of the C code +# for the default behaviour for git's push-to-checkout hook defined in +# the push_to_deploy() function in builtin/receive-pack.c. +# +# Note that the hook will be executed from the repository directory, +# not from the working tree, so if you want to perform operations on +# the working tree, you will have to adapt your code accordingly, e.g. +# by adding "cd .." or using relative paths. + +if ! git update-index -q --ignore-submodules --refresh +then + die "Up-to-date check failed" +fi + +if ! git diff-files --quiet --ignore-submodules -- +then + die "Working directory has unstaged changes" +fi + +# This is a rough translation of: +# +# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX +if git cat-file -e HEAD 2>/dev/null +then + head=HEAD +else + head=$(git hash-object -t tree --stdin &2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --type=bool hooks.allowunannotated) +allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch) +denycreatebranch=$(git config --type=bool hooks.denycreatebranch) +allowdeletetag=$(git config --type=bool hooks.allowdeletetag) +allowmodifytag=$(git config --type=bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero=$(git hash-object --stdin &2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/info/exclude b/info/exclude new file mode 100644 index 00000000..a5196d1b --- /dev/null +++ b/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/pyinstaller.spec b/pyinstaller.spec index 1ca37a90..615bcc15 100644 --- a/pyinstaller.spec +++ b/pyinstaller.spec @@ -2,6 +2,7 @@ import sys, site, os from path import Path +from PyInstaller.utils.hooks import collect_all, collect_submodules block_cipher = None @@ -18,22 +19,39 @@ elif sys.platform == 'win32': occt_dir = os.path.join(Path(sys.prefix), 'Library', 'share', 'opencascade') ocp_path = (os.path.join(HOMEPATH, 'OCP.cp38-win_amd64.pyd'), '.') +datas1, binaries1, hiddenimports1 = collect_all('debugpy') +hiddenimports2 = collect_submodules('xmlrpc') + a = Analysis(['run.py'], pathex=['.'], - binaries=[ocp_path], + binaries=[ocp_path] + binaries1, datas=[(spyder_data, 'spyder'), (occt_dir, 'opencascade')] + - [(p, 'parso/python') for p in parso_grammar], - hiddenimports=['ipykernel.datapub'], + [(p, 'parso/python') for p in parso_grammar] + datas1, + hiddenimports=['ipykernel.datapub', 'vtkmodules', 'vtkmodules.all', + 'pyqtgraph.graphicsItems.ViewBox.axisCtrlTemplate_pyqt5', + 'pyqtgraph.graphicsItems.PlotItem.plotConfigTemplate_pyqt5', + 'pyqtgraph.imageview.ImageViewTemplate_pyqt5', 'debugpy', 'xmlrpc'] + hiddenimports1 + hiddenimports2, hookspath=[], runtime_hooks=['pyinstaller/pyi_rth_occ.py', 'pyinstaller/pyi_rth_fontconfig.py'], - excludes=['_tkinter',], + excludes=['_tkinter'], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher, noarchive=False) +# There is an issue that keeps the OpenSSL libraries from being copied to the output directory. +# This should work if nothing else, but does not with GitHub Actions +if sys.platform == 'win32': + from PyInstaller.depend.bindepend import getfullnameof + rel_data_path = ['PyQt5', 'Qt', 'bin'] + a.datas += [ + (getfullnameof('libssl-1_1-x64.dll'), os.path.join(*rel_data_path), 'DATA'), + (getfullnameof('libcrypto-1_1-x64.dll'), os.path.join(*rel_data_path), 'DATA'), + ] + + pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE(pyz, @@ -48,7 +66,8 @@ exe = EXE(pyz, console=True, icon='icons/cadquery_logo_dark.ico') -exclude = ('libGL','libEGL','libbsd') +exclude = () +#exclude = ('libGL','libEGL','libbsd') a.binaries = TOC([x for x in a.binaries if not x[0].startswith(exclude)]) coll = COLLECT(exe, diff --git a/pyinstaller/CQ-editor.cmd b/pyinstaller/CQ-editor.cmd new file mode 100644 index 00000000..954e27b1 --- /dev/null +++ b/pyinstaller/CQ-editor.cmd @@ -0,0 +1 @@ +call .\CQ-editor\CQ-editor.exe \ No newline at end of file diff --git a/pyinstaller/CQ-editor.sh b/pyinstaller/CQ-editor.sh new file mode 100644 index 00000000..9b94e254 --- /dev/null +++ b/pyinstaller/CQ-editor.sh @@ -0,0 +1,4 @@ +#!/bin/sh +export QT_MAC_WANTS_LAYER=1 +chmod u+x ./CQ-editor/CQ-editor +./CQ-editor/CQ-editor \ No newline at end of file diff --git a/tests/test_app.py b/tests/test_app.py index c99750c3..168c540f 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -14,7 +14,7 @@ from PyQt5.QtWidgets import QFileDialog, QMessageBox from cq_editor.__main__ import MainWindow -from cq_editor.widgets.editor import Editor +from cq_editor.widgets.editor import Editor, get_imported_module_paths from cq_editor.cq_utils import export, get_occ_color code = \ @@ -1320,108 +1320,13 @@ def filename(*args, **kwargs): # I don't really care what the title is, as long as it's not a filename assert(not win.windowTitle().endswith('.py')) -def test_module_discovery(tmp_path, editor): - qtbot, editor = editor +def test_module_discovery(tmp_path): with open(tmp_path.joinpath('main.py'), 'w') as f: f.write('import b') - assert editor.get_imported_module_paths(str(tmp_path.joinpath('main.py'))) == [] + assert get_imported_module_paths(str(tmp_path.joinpath('main.py'))) == [] tmp_path.joinpath('b.py').touch() - assert editor.get_imported_module_paths(str(tmp_path.joinpath('main.py'))) == [str(tmp_path.joinpath('b.py'))] - -def test_launch_syntax_error(tmp_path): - - # verify app launches when input file is bad - win = MainWindow() - - inputfile = Path(tmp_path).joinpath("syntax_error.py") - modify_file("print(", inputfile) - editor = win.components["editor"] - editor.autoreload(True) - editor.preferences["Autoreload: watch imported modules"] = True - editor.load_from_file(inputfile) - - win.show() - assert(win.isVisible()) - -code_import_module_makebox = \ -""" -from module_makebox import * -z = 1 -r = makebox(z) -""" - -code_module_makebox = \ -""" -import cadquery as cq -def makebox(z): - zval = z + 1 - return cq.Workplane().box(1, 1, zval) -""" - -def test_reload_import_handle_error(tmp_path, main): - - TIMEOUT = 500 - qtbot, win = main - editor = win.components["editor"] - debugger = win.components["debugger"] - traceback_view = win.components["traceback_viewer"] - - editor.autoreload(True) - editor.preferences["Autoreload: watch imported modules"] = True - - # save the module and top level script files - module_file = Path(tmp_path).joinpath("module_makebox.py") - script = Path(tmp_path).joinpath("main.py") - modify_file(code_module_makebox, module_file) - modify_file(code_import_module_makebox, script) - - # run, verify that no exception was generated - editor.load_from_file(script) - debugger._actions["Run"][0].triggered.emit() - assert(traceback_view.current_exception.text() == "") - - # save the module with an error - with qtbot.waitSignal(editor.triggerRerender, timeout=TIMEOUT): - lines = code_module_makebox.splitlines() - lines.remove(" zval = z + 1") # introduce NameError - lines = "\n".join(lines) - modify_file(lines, module_file) - - # verify NameError is generated - debugger._actions["Run"][0].triggered.emit() - assert("NameError" in traceback_view.current_exception.text()) - - # revert the error, verify rerender is triggered - with qtbot.waitSignal(editor.triggerRerender, timeout=TIMEOUT): - modify_file(code_module_makebox, module_file) - - # verify that no exception was generated - debugger._actions["Run"][0].triggered.emit() - assert(traceback_view.current_exception.text() == "") - -def test_modulefinder(tmp_path, main): - - TIMEOUT = 500 - qtbot, win = main - editor = win.components["editor"] - debugger = win.components["debugger"] - traceback_view = win.components["traceback_viewer"] - log = win.components['log'] - - editor.autoreload(True) - editor.preferences["Autoreload: watch imported modules"] = True - - script = Path(tmp_path).joinpath("main.py") - Path(tmp_path).joinpath("emptydir").mkdir() - modify_file("#import emptydir", script) - editor.load_from_file(script) - with qtbot.waitSignal(editor.triggerRerender, timeout=TIMEOUT): - modify_file("import emptydir", script) - - qtbot.wait(100) - assert("Cannot determine imported modules" in log.toPlainText().splitlines()[-1]) - + assert get_imported_module_paths(str(tmp_path.joinpath('main.py'))) == [str(tmp_path.joinpath('b.py'))]