pyunity / pyunity Goto Github PK
View Code? Open in Web Editor NEWA pure Python 3D Game Engine that was inspired by the structure of the Unity Game Engine
Home Page: https://docs.pyunity.x10.bz/
License: MIT License
A pure Python 3D Game Engine that was inspired by the structure of the Unity Game Engine
Home Page: https://docs.pyunity.x10.bz/
License: MIT License
Importing is broken, meshes are broken, setup.py is broken, compiling is broken, everything is broken. I need some time to fix it all.
I have no idea when or where this happens
Hello Ray I could not run the zip file you gave using the package pyuunity-editor
Loaded config
Detected settings.json entry
Using window provider GLFW
Loaded PyUnity version 0.9.0
##############################
VERSION INFO
##############################
PyUnity version: v0.9.0
Python version: v3.10.4-final
Operating system: Windows 10
Machine: AMD64
Python architecture: 64bit
Dependencies:
- pyopengl version: 3.1.6
- pillow version: 9.1.1
- pysdl2 version: 0.9.11
- pysdl2-dll version: 2.0.20
- pyglm version: 2.5.7
- importlib-resources version: None
- glfw version: 2.5.3
Physics is broken, when two cubes collide head-on they collide into each other
Collision point is offset by 1 unit in the Z axis in example 2
Example 3, red cube has infinite inertia yet it still rotates
Run examples 2 and 3, observe
For example 2 pressing Space and R starts and resets the cubes respectively
No response
No response
Using GJK and EPA algorithm, pretty expensive and still doesnt work
The README, docs and just everything documentation-related is not good. The README is too full of documentation and not actually what PyUnity is about, and the first impression to it is that PyUnity is just a set of bindings to the Unity Game Engine. Half the docstrings are missing and tutorials lack detail.
When built with bdist_wheel
, all data files are not included. However, they are specified in setup.py
.
It's not even installed!
When I use pip install pyunity
, the error bellow happened.
Just Enter pip install pyunity
in a macOS inv
No response
Using cached pysdl2_dll-2.28.5-py2.py3-none-macosx_10_11_universal2.whl (5.8 MB)
Building wheels for collected packages: pyunity
Building wheel for pyunity (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pyunity (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [80 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-14-arm64-cpython-311
creating build/lib.macosx-14-arm64-cpython-311/pyunity
copying src/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity
copying src/__main__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity
copying src/notes.txt -> build/lib.macosx-14-arm64-cpython-311/pyunity
creating build/lib.macosx-14-arm64-cpython-311/pyunity/scenes
copying src/scenes/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/scenes
creating build/lib.macosx-14-arm64-cpython-311/pyunity/values
copying src/values/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/values
creating build/lib.macosx-14-arm64-cpython-311/pyunity/primitives
copying src/primitives/capsule.mesh -> build/lib.macosx-14-arm64-cpython-311/pyunity/primitives
copying src/primitives/double_quad.mesh -> build/lib.macosx-14-arm64-cpython-311/pyunity/primitives
copying src/primitives/quad.mesh -> build/lib.macosx-14-arm64-cpython-311/pyunity/primitives
copying src/primitives/cube.mesh -> build/lib.macosx-14-arm64-cpython-311/pyunity/primitives
copying src/primitives/sphere.mesh -> build/lib.macosx-14-arm64-cpython-311/pyunity/primitives
copying src/primitives/cylinder.mesh -> build/lib.macosx-14-arm64-cpython-311/pyunity/primitives
creating build/lib.macosx-14-arm64-cpython-311/pyunity/window
copying src/window/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/window
creating build/lib.macosx-14-arm64-cpython-311/pyunity/examples
copying src/examples/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/examples
creating build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example2
copying src/examples/example2/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example2
creating build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example5
copying src/examples/example5/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example5
creating build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example4
copying src/examples/example4/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example4
creating build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example3
copying src/examples/example3/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example3
creating build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example10
copying src/examples/example10/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example10
creating build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example6
copying src/examples/example6/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example6
creating build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example1
copying src/examples/example1/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example1
creating build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example8
copying src/examples/example8/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example8
copying src/examples/example8/logo.png -> build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example8
creating build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example9
copying src/examples/example9/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example9
creating build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example7
copying src/examples/example7/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example7
copying src/examples/example7/explode.ogg -> build/lib.macosx-14-arm64-cpython-311/pyunity/examples/example7
creating build/lib.macosx-14-arm64-cpython-311/pyunity/shaders
creating build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/standard
copying src/shaders/standard/fragment.glsl -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/standard
copying src/shaders/standard/vertex.glsl -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/standard
creating build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/gui
copying src/shaders/gui/fragment.glsl -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/gui
copying src/shaders/gui/vertex.glsl -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/gui
copying src/shaders/gui/button.png -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/gui
creating build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/gui/textures
copying src/shaders/gui/textures/checkboxOff.png -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/gui/textures
copying src/shaders/gui/textures/checkboxOn.png -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/gui/textures
copying src/shaders/gui/textures/button.png -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/gui/textures
creating build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/skybox
copying src/shaders/skybox/fragment.glsl -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/skybox
copying src/shaders/skybox/vertex.glsl -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/skybox
creating build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/skybox/textures
copying src/shaders/skybox/textures/bottom.jpg -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/skybox/textures
copying src/shaders/skybox/textures/left.jpg -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/skybox/textures
copying src/shaders/skybox/textures/top.jpg -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/skybox/textures
copying src/shaders/skybox/textures/back.jpg -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/skybox/textures
copying src/shaders/skybox/textures/right.jpg -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/skybox/textures
copying src/shaders/skybox/textures/front.jpg -> build/lib.macosx-14-arm64-cpython-311/pyunity/shaders/skybox/textures
creating build/lib.macosx-14-arm64-cpython-311/pyunity/physics
copying src/physics/__init__.py -> build/lib.macosx-14-arm64-cpython-311/pyunity/physics
running build_ext
building 'loader' extension
creating build/temp.macosx-14-arm64-cpython-311
creating build/temp.macosx-14-arm64-cpython-311/src
clang -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -I/Users/yousifaladwani/Documents/code/python/tests/pyunity_test1/venv/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c src/loader.c -o build/temp.macosx-14-arm64-cpython-311/src/loader.o
src/loader.c:265:12: fatal error: 'longintrepr.h' file not found
#include "longintrepr.h"
^~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyunity
Failed to build pyunity
ERROR: Could not build wheels for pyunity, which is required to install pyproject.toml-based projects
Python version: 3.11.6 (In a venv)
OS: macOS Sonoma v14.2.1
Pip version: v23.2.1
Loaded config
Detected settings.json entry
Using window provider GLFW
Loaded PyUnity version 0.9.0
##############################
VERSION INFO
##############################
PyUnity version: v0.9.0
Python version: v3.9.4-final
Operating system: Windows 10
Machine: AMD64
Python architecture: 32bit
Dependencies:
- pyopengl version: 3.1.5
- pillow version: 9.0.1
- pysdl2 version: 0.9.11
- pysdl2-dll version: 2.0.20
- pyglm version: 2.5.7
- importlib-resources version: None
- glfw version: 2.5.3
Program quits with a large error yet KeyboardInterrupt is not raised and so cannot be caught normally by SceneManager.__loadScene
.
Run examples
Press Ctrl+C while an example is running
Repeat until KeyboardInterrupt is raised while an OpenGL function is being called
No response
Loaded config
Detected settings.json entry
Using window provider GLFW
Loaded PyUnity version 0.9.0
Example 1
/Cube
/Floor
/Light
/Main Camera
Launching window manager
Compiling objects
Starting scene
Physics is on
Scene 'Scene' has started
Example 2
Launching window manager
Compiling objects
Starting scene
Physics is on
Scene 'Scene' has started
Traceback (most recent call last):
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Ray-Data\python\pyunity\pyunity\__main__.py", line 60, in <module>
examples.show()
File "C:\Ray-Data\python\pyunity\pyunity\examples\__init__.py", line 36, in show
loadExample(i)
File "C:\Ray-Data\python\pyunity\pyunity\examples\__init__.py", line 20, in loadExample
module.main()
File "C:\Ray-Data\python\pyunity\pyunity\examples\example2\__init__.py", line 55, in main
SceneManager.LoadScene(scene)
File "C:\Ray-Data\python\pyunity\pyunity\scenes\sceneManager.py", line 243, in LoadScene
__loadScene(copy.deepcopy(scene))
File "C:\Ray-Data\python\pyunity\pyunity\scenes\sceneManager.py", line 308, in __loadScene
windowObject.start(scene.update)
File "C:\Ray-Data\python\pyunity\pyunity\window\providers\glfw\window.py", line 145, in start
self.updateFunc()
File "C:\Ray-Data\python\pyunity\pyunity\scenes\scene.py", line 502, in update
self.Render()
File "C:\Ray-Data\python\pyunity\pyunity\scenes\scene.py", line 518, in Render
self.mainCamera.Render(renderers, lights)
File "C:\Ray-Data\python\pyunity\pyunity\render.py", line 732, in Render
self.RenderScene(renderers, lights)
File "C:\Ray-Data\python\pyunity\pyunity\render.py", line 727, in RenderScene
self.SetupShader(lights)
File "C:\Ray-Data\python\pyunity\pyunity\render.py", line 637, in SetupShader
self.shader.setVec3(b"viewPos", list(
File "C:\Ray-Data\python\pyunity\pyunity\render.py", line 292, in setVec3
location = gl.glGetUniformLocation(self.program, var)
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\site-packages\OpenGL\latebind.py", line 63, in __call__
return self.wrapperFunction( self.baseFunction, *args, **named )
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\site-packages\OpenGL\GL\VERSION\GL_2_0.py", line 430, in glGetUniformLocation
return baseOperation( program, name )
ctypes.ArgumentError: argument 2: <class 'KeyboardInterrupt'>:
To do with raising KeyboardInterrupt while running an OpenGL function
Loaded config
Detected settings.json entry
Using window provider PySDL2
Loaded PyUnity version 0.9.0
##############################
VERSION INFO
##############################
PyUnity version: v0.9.0
Python version: v3.10.4-final
Operating system: Windows 10
Machine: AMD64
Python architecture: 64bit
Dependencies:
- pyopengl version: 3.1.6
- pillow version: 9.1.1
- pysdl2 version: 0.9.11
- pysdl2-dll version: 2.0.20
- pyglm version: 2.5.7
- importlib-resources version: None
- glfw version: None
The skybox is flipped, rotating seems flipped along the Y-axis.
Run example 1 and watch the cube rotate anticlockwise.
No response
No response
No response
Functions are constantly being renamed, changed etc and it's better to have a constant API that contains deprecations which notify the user when certain functions will no longer be used.
Is your feature request related to a problem? Please describe.
When saving a Scene, SavedAttribute
s can only be saved properly if they are one of the following types: str
, int
, float
, SavesProjectID
(including Asset
), Vector
, Quaternion
, RGB
, HSV
. However, it is also useful to support saving lists or dicts of these types, which could even support nesting.
Describe the solution you'd like
Such a format would be similar to YAML, with a few differences: the list
format would have a different prefix other than -
, the dict
keys would be any of the above types properly formatted (maybe apart from the floating-point classes since they would rarely match) and indents would be 4 spaces instead of 2.
Describe alternatives you've considered
Currently, the SavableStruct
has a similar format but does not support nesting.
Additional context
This would make Button
be able to save the kwargs
argument in the Scene file.
If RenderTarget.canvas
is true, it may try to render itself in PreRender
. Whether this is wanted or not, there needs to be a limit to the depth of recursion.
The tests in tests.py
have not been changed for about 6 months and codecov depressingly says 41% coverage. One problem with testing is that on headless servers, window testing is not the easiest but the new EGL window provider should fix that (if I can make it find libEGL.so
). Another problem is how to test if the rendering is correct, but I think that won't need to be included.
Cool idea for a project :) I suspect that as far as the name there are two situations:
I suppose you could just change the name at that point, but, might be as easy to just change the name now? (e.g. Mono, which Unity uses, didn't call themselves "Linux .Net Framework", they called themselves "mono", and everyone knew that it was a cross platform version of the windows .net framework).
this would also avoid having to state twice, in the first two paragraphs of your front page, that pyunity is not a wrapper around unity :)
(And it's natural to assume pyunity is a wrapper. My pytorch project, https://github.com/hughperkins/pytorch (which predates the Facebook pytorch by a year or two), was a wrapper around Facebook's lua torch)
Loading example 8 always gives an error:
Traceback (most recent call last):
File "C:\Users\Ray\AppData\Local\Programs\Python\Python39-32\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Ray\AppData\Local\Programs\Python\Python39-32\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "D:\Ray\python\pyunity\__main__.py", line 2, in <module>
examples.show()
File "D:\Ray\python\pyunity\examples\__init__.py", line 32, in show
example.main()
File "D:\Ray\python\pyunity\examples\example8\__init__.py", line 9, in main
source = scene.mainCamera.AddComponent(AudioSource)
File "D:\Ray\python\pyunity\core.py", line 327, in AddComponent
return self.gameObject.AddComponent(component)
File "D:\Ray\python\pyunity\core.py", line 186, in AddComponent
component = componentClass(self.transform)
File "D:\Ray\python\pyunity\audio.py", line 58, in __init__
mixer.Mix_AllocateChannels(channels)
OSError: exception: access violation reading 0x00000074
This doesnt happen when I run python -m pyunity 8
, only when I run all examples. This happens on the develop
branch.
Sometimes MemoryError
is encountered when copying the scene at runtime, especially with shaders and skyboxes duplicated (which they aren't meant to be).
I am a new user to pyunity..
i installed it with
pip install pyunity
I was trying out the examples..
python -m pyunity 1
it resulted in error:
Error log:
PS C:\Users\Lenovo> python -m pyunity 1
Loaded config
Trying GLFW as a window provider
Using window provider GLFW
Traceback (most recent call last):
File "C:\Program Files\Python38-32\lib\runpy.py", line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Program Files\Python38-32\lib\runpy.py", line 144, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\Program Files\Python38-32\lib\runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "C:\Program Files\Python38-32\lib\site_packages\pyunity\__init__.py", line 131, in <module>
from .audio import *
File "audio.py", line 13, in init pyunity.audio
File "core.py", line 1, in init pyunity.core
ModuleNotFoundError: No module named 'vector3'
I have tried whatever i can do.. but i can't fix it nor find any module with name "vector3" on the internet..
Specs (if you need):
Python Version: Python 3.8.9
OS: Windows 7 SP 1
Processor: Intel core i3 (x86)
Python 3.8 wheel is a bit broken:
Directory of C:\Users\raych\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pyunity
25/04/2021 10:07 <DIR> .
25/04/2021 10:07 <DIR> ..
25/04/2021 10:07 94,208 audio.cp37-win32.pyd
25/04/2021 10:07 102,400 audio.cp38-win32.pyd
25/04/2021 10:07 103,936 audio.cp39-win32.pyd
25/04/2021 10:07 30,208 config.cp37-win32.pyd
25/04/2021 10:07 31,232 config.cp38-win32.pyd
25/04/2021 10:07 30,720 config.cp39-win32.pyd
25/04/2021 10:07 233,984 core.cp37-win32.pyd
25/04/2021 10:07 256,000 core.cp38-win32.pyd
25/04/2021 10:07 258,048 core.cp39-win32.pyd
25/04/2021 10:07 26,112 errors.cp37-win32.pyd
25/04/2021 10:07 26,112 errors.cp38-win32.pyd
25/04/2021 10:07 26,624 errors.cp39-win32.pyd
25/04/2021 10:07 <DIR> examples
25/04/2021 10:07 124,928 input.cp37-win32.pyd
25/04/2021 10:07 129,536 input.cp38-win32.pyd
25/04/2021 10:07 138,240 input.cp39-win32.pyd
25/04/2021 10:07 125,440 loader.cp37-win32.pyd
25/04/2021 10:07 134,656 loader.cp38-win32.pyd
25/04/2021 10:07 136,704 loader.cp39-win32.pyd
25/04/2021 10:07 86,528 meshes.cp37-win32.pyd
25/04/2021 10:07 94,208 meshes.cp38-win32.pyd
25/04/2021 10:07 101,888 meshes.cp39-win32.pyd
25/04/2021 10:07 <DIR> physics
25/04/2021 10:07 <DIR> primitives
25/04/2021 10:07 141,312 quaternion.cp37-win32.pyd
25/04/2021 10:07 154,112 quaternion.cp38-win32.pyd
25/04/2021 10:07 155,648 quaternion.cp39-win32.pyd
25/04/2021 10:07 261,632 scene.cp37-win32.pyd
25/04/2021 10:07 276,992 scene.cp38-win32.pyd
25/04/2021 10:07 281,600 scene.cp39-win32.pyd
25/04/2021 10:07 214,528 vector3.cp37-win32.pyd
25/04/2021 10:07 237,056 vector3.cp38-win32.pyd
25/04/2021 10:07 239,616 vector3.cp39-win32.pyd
25/04/2021 10:07 <DIR> window
25/04/2021 10:07 4,710 __init__.py
25/04/2021 10:07 41 __main__.py
25/04/2021 10:07 <DIR> __pycache__
32 File(s) 4,258,959 bytes
7 Dir(s) 129,689,518,080 bytes free
How in Earth's name are there about 30 files in there?! this is the pyunity directory in site-packages btw if you didn't realize
For PyUnity to be importable from a zip or egg, __file__
is disallowed. importlib.resources
solves this with context managers such as importlib.resources.path
that use pathlib
, which requires #33 to be implemented too. PyInstaller would work much better and possibly the one-file bundler that I made could find resources better.
Another approach is to use a custom file finder, which internally uses importlib
. This makes it easier to translate what is already being used to the new custom file finder which would have its own submodule. Hopefully it would not depend on anything else (like pyunity.Logger
does right now) and then it could be loaded by itself without loading the entire PyUnity module. (This isn't final however, just an idea.)
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Instead of having global variables under pyunity/config.py
, using a class that can be modified is more portable. This way we can separate flags and actual configs, whereas right now config.audio
can be modified.
Describe the solution you'd like
A clear and concise description of what you want to happen.
Config
class created that can be loaded and saved from the .pyunity
file in projects
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Cannot import pyunity due to error below:
Loaded config
Trying GLFW as a window provider
Using window provider GLFW
Traceback (most recent call last):
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\runpy.py", line 188, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\runpy.py", line 147, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\site-packages\pyunity\__init__.py", line 156, in <module>
from .audio import *
File "audio.py", line 13, in init pyunity.audio
File "core.py", line 1, in init pyunity.core
ModuleNotFoundError: No module named 'vector3'
In the current state, importing PyUnity will cause this error:
Loaded config
Traceback (most recent call last):
File "C:\Users\Ray\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 184, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\Ray\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 143, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "C:\Users\Ray\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "C:\Users\Ray\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyunity\__init__.py", line 125, in <module>
from .audio import *
File "audio.py", line 12, in init pyunity.audio
File "config.py", line 17, in init pyunity.config
File "C:\Users\Ray\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyunity\window\__init__.py", line 34, in <module>
from .glutWindow import Window as glutWindow
ImportError: DLL load failed while importing glutWindow: The specified module could not be found.
Describe the bug
Trying to import PyUnity from an egg file errors out.
To Reproduce
Run cython=0 python setup.py bdist_egg
Go to dist
folder
Run code
Expected behavior
Successful import
Code
import sys
sys.path.insert(0, "pyunity-0.9.0-py3.9.egg")
import pyunity
System info
##############################
VERSION INFO
##############################
PyUnity version: v0.9.0
Python version: v3.9.4-final
Operating system: Windows 10
Architecture: 32bit
Requirements:
- pyopengl version: 3.1.5
- pillow version: 9.0.1
- pysdl2 version: 0.9.11
- pysdl2-dll version: 2.0.20
- pyglm version: 2.5.7
- importlib-resources version: None
- glfw version: 2.5.0
Traceback
Traceback (most recent call last):
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\importlib\_common.py", line 35, in _tempfile
os.write(fd, reader())
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\zipfile.py", line 2322, in read_bytes
with self.open('rb') as strm:
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\zipfile.py", line 2306, in open
stream = self.root.open(self.at, zip_mode, pwd=pwd)
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\zipfile.py", line 1502, in open
zinfo = self.getinfo(name)
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\zipfile.py", line 1429, in getinfo
raise KeyError(
KeyError: "There is no item named 'pyunity/shaders/skybox/textures/' in the archive"
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 259, in load_module
File "pyunity-0.9.0-py3.9.egg\pyunity\__init__.py", line 209, in <module>
from .render import __all__ as _render_all
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 259, in load_module
File "pyunity-0.9.0-py3.9.egg\pyunity\render.py", line 324, in <module>
skyboxes["Water"] = Skybox(stack.enter_context(as_file(ref / "skybox/textures")))
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\contextlib.py", line 429, in enter_context
result = _cm_type.__enter__(cm)
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\contextlib.py", line 117, in __enter__
return next(self.gen)
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\importlib\_common.py", line 52, in as_file
with _tempfile(path.read_bytes, suffix=path.name) as local:
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\contextlib.py", line 117, in __enter__
return next(self.gen)
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\importlib\_common.py", line 40, in _tempfile
os.remove(raw_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\raych\\AppData\\Local\\Temp\\tmpbrwljrmttextures'
Additional context
Add any other context about the problem here.
Example 8 gives error:
Traceback (most recent call last):
File "C:\Users\Ray\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Ray\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\Ray\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyunity\__main__.py", line 2, in <module>
examples.show()
File "C:\Users\Ray\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyunity\examples\__init__.py", line 28, in show
example_list[num - 1].main()
File "C:\Users\Ray\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyunity\examples\example8\__init__.py", line 9, in main
clip = AudioClip(os.path.join(path, "explode.ogg"))
File "audio.py", line 46, in pyunity.audio.AudioClip.__init__
File "audio.py", line 77, in pyunity.audio.AudioClip.SetSound
pyunity.errors.PyUnityException: Cannot find file: C:\Users\D\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pyunity\examples\example8\explode.ogg
It is caused by the lack of an else
statement for checking if the file exists. Also, the OGG file does not get included in the source and wheels.
The current approach makes it hard to maintain the project's types since the docstrings and stub files has to be in sync so I think the project should convert to inline type hints as defined in PEP 448 and note that a py.typed
file will need to be added to /pyunity
for PEP 561.
Since pyunity
only supports Python3.6+ there will be no compatibility issues what's however.
I would like to know your opinion on this :)
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
The main loop code in the window providers is almost exactly the same thing: run some init, create a clock, infinite loop, quit etc. but it's hard to create something like VSync that can be toggled on and off. This really shouldn't be handled by the window providers.
Describe the solution you'd like
A clear and concise description of what you want to happen.
The main loop code should be either in SceneManager.__loadScene
or (more preferably) another ABCMeta
that can be subclassed and implemented, given an update function and set to chug along nicely.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
pathlib
is available as part of the Python standard library, and takes a more OOP-based approach for path manipulation. It is also less clunky and results in neater code.
Loaded config
Warning: Testing PyUnity, audio is disabled
Loaded PyUnity version 0.9.0
##############################
VERSION INFO
##############################
PyUnity version: v0.9.0
Python version: v3.8.10-final
Operating system: Windows 10
Machine: AMD64
Python architecture: 64bit
Warning: PyUnity not ran as an installed package
Dependencies:
- pyopengl version: 3.1.6
- pillow version: 9.1.0
- pysdl2 version: 0.9.11
- pysdl2-dll version: 2.0.20
- pyglm version: 2.5.7
- importlib-resources version: 5.7.1
Windows and MacOS GitHub actions freeze when running prepare.py
.
Run workflows/windows.yml
or workflows/macos.yml
action
No response
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\multiprocessing\spawn.py", line 125, in _main
prepare(preparation_data)
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\runpy.py", line 265, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "D:\a\pyunity\pyunity\setup.py", line 22, in <module>
prepare.cythonize()
File "D:\a\pyunity\pyunity\prepare.py", line 231, in cythonize
pool = multiprocessing.Pool(nthreads, initWorker)
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\multiprocessing\context.py", line 119, in Pool
return Pool(processes, initializer, initargs, maxtasksperchild,
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\multiprocessing\pool.py", line 212, in __init__
self._repopulate_pool()
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\multiprocessing\pool.py", line 303, in _repopulate_pool
return self._repopulate_pool_static(self._ctx, self.Process,
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\multiprocessing\pool.py", line 326, in _repopulate_pool_static
w.start()
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\multiprocessing\context.py", line 327, in _Popen
return Popen(process_obj)
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
_check_not_importing_main()
File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
Multiprocessing seems to not be working.
Is your feature request related to a problem? Please describe.
Currently resources are dynamically found and only specific to the default ones provided by PyUnity, however if this is to become a standalone then said resources would be located differently. The current method of project loading only facilitates loading Asset
files and doesn't have an interface for other file creations, such as config files or caches.
Describe the solution you'd like
A resource management system extending resources.py
that also ties into the Project
class.
Describe alternatives you've considered
Something similar to what Unity does, which is to bundle all the assets into a single compressed file that is distributed with the rest of the executable.
Additional context
This could also be useful in a PyUnity editor for when assets are modified, renamed etc. It also needs to take into account any project UUIDs it has to modify.
Loaded config
Detected settings.json entry
Using window provider GLFW
Loaded PyUnity version 0.9.0
##############################
VERSION INFO
##############################
PyUnity version: v0.9.0
Python version: v3.9.4-final
Operating system: Windows 10
Machine: AMD64
Python architecture: 32bit
Dependencies:
Warning: PyUnity not ran as an installed package
- pyopengl version: 3.1.5
- pillow version: 9.0.1
- pysdl2 version: 0.9.11
- pysdl2-dll version: 2.0.20
- pyglm version: 2.5.7
- importlib-resources version: None
EGL window provider throws OSError when running multiple examples in sequence
Use PYUNITY_WINDOW_PROVIDER=egl
and run python -m pyunity
.
No response
Loaded config
Trying EGL as a window provider
Using window provider EGL
Loaded PyUnity version 0.9.0
Warning: Currently broken examples: 3
Example 1
/Cube
/Floor
/Light
/Main Camera
Launching window manager
[<EGLDisplay object at 0x020F8BF8>, <pyunity.window.providers.egl.egl.EGLint_Array_13 object at 0x04F661D8>, <pyunity.window.providers.egl.egl.EGLConfig_Array_1 object at 0x04F66190>, 1, <EGLint object at 0x04F66148>]
Compiling objects
Starting scene
Physics is on
Scene 'Scene' has started
Exiting
Example 2
Launching window manager
[<EGLDisplay object at 0x020F8BF8>, <pyunity.window.providers.egl.egl.EGLint_Array_13 object at 0x0D2FFB20>, <pyunity.window.providers.egl.egl.EGLConfig_Array_1 object at 0x0D2FFD18>, 1, <EGLint object at 0x0D2FFF58>]
Compiling objects
Warning: Detected settings.json entry
Warning: windowCache entry has been set, indicating window checking happened on this import
Warning: settings.json entry may be faulty, removing
Traceback (most recent call last):
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\raych\AppData\Local\Programs\Python\Python39-32\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Ray-Data\python\pyunity\pyunity\__main__.py", line 60, in <module>
examples.show()
File "C:\Ray-Data\python\pyunity\pyunity\examples\__init__.py", line 36, in show
load_example(i)
File "C:\Ray-Data\python\pyunity\pyunity\examples\__init__.py", line 20, in load_example
module.main()
File "C:\Ray-Data\python\pyunity\pyunity\examples\example2\__init__.py", line 55, in main
SceneManager.LoadScene(scene)
File "C:\Ray-Data\python\pyunity\pyunity\scenes\sceneManager.py", line 244, in LoadScene
__loadScene(copy.deepcopy(scene))
File "C:\Ray-Data\python\pyunity\pyunity\scenes\sceneManager.py", line 282, in __loadScene
render.compileSkyboxes()
File "C:\Ray-Data\python\pyunity\pyunity\render.py", line 338, in compileSkyboxes
skybox.compile()
File "C:\Ray-Data\python\pyunity\pyunity\files.py", line 313, in compile
gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, gl.GL_RGBA,
File "src/latebind.pyx", line 39, in OpenGL_accelerate.latebind.LateBind.__call__
File "src/wrapper.pyx", line 311, in OpenGL_accelerate.wrapper.Wrapper.__call__
OSError: exception: access violation reading 0x00000004
Could be caused by using a terminated display but in pyunity/window/providers/window.py
eglInitialize is called every time the window provider is instantiated. Similar issues also happen when using 32-bit python on 64-bit machine.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.