cihologramas / pyoptools

Python tools for optical design
GNU General Public License v3.0
137 stars 46 forks source link

Simplify setup.py; enable build for Windows, MacOS and every major Linux system; add actions to build wheel files #127

Closed semiversus closed 2 years ago

semiversus commented 2 years ago

The major goal for this pull request is to be able to compile pyoptools for Windows, MacOS and any major Linux system.

setup.py

This file was simplified and uses the Cython functionality to compile the given files. There is a problem with MacOS and Windows compilers not supporting inline on data declarations - in this case the CYTHON_INLINE macro is redefined.

Github Actions

With the added workflow packages are automatically build for Windows, MacOS and Linux for Python3.7, 3.8, 3.9 and 3.10.

Others

Next steps (will be pull requests, when this one is accepted)

rdgraham commented 2 years ago

This is great. I checked out the pull request and installed via pip in a new conda environment.

Installed without issue. First time I have had operational pyoptools in windows.

As of now I still don't have the 3d view via pythreejs in jupyter working, even though I have installed and enabled it. Getting 404 errors in the terminal when I try to use plot3D. Though I suspect that is probably a conda problem or something not directly related to pyoptools.

Thanks!

semiversus commented 2 years ago

I did the following in my conda environment and it was working with that:

pip install jupyterlab pythreejs
jupyter nbextension install --py pythreejs
jupyter nbextension enable pythreejs --py
jupyter-lab
rdgraham commented 2 years ago

Thank you, with those exact commands I have it working. Seems like it should be equivalent to what I did, but anyway ..

Now that I have the display working I am seeing a strange issue with this build.

Looks like what is happening is that rotations are not being applied to surfaces correctly. For example the cylindrical 'wall' sections of lenses are not being rotated correctly as shown in the screenshot below from the tutorial.

I have tried the latest build on linux and am not seeing this issue. Is this maybe a strange numerical showing up with the different cython compiler or something? Anyone else seeing this?

I can split this off into a new issue if there isn't some immediate fix like a compiler flag or something.

image

semiversus commented 2 years ago

Could you please try one of the attached wheel files (depenting on your python version). You can use pip install pyoptools-0.1.1-cp37-cp37m-win_amd64.whl (example for Python 3.7). These are the wheel files created by the github actions workflow.

pyoptools-0.1.1_windows_wheels.zip

rdgraham commented 2 years ago

Thanks for that, I downloaded and tried it out with python 3.10, installed with the --force-reinstall option and that went without issue.

But I am still seeing the same problem.

On looking at the polychromatic prism example, it seems like the actual underlying calculation and raytracing is probably correct, and the problem is just in the rendering of the surfaces. So this might be a openGL problem or problem in ipynbplotutils.py renderer. I will try some different versions and see if I can debug this when I get a chance.

image

semiversus commented 2 years ago

Ok, thanks for testing. I'll have a look too. I also guess it's a rendering problem. We may put this into a issue by it's own.