p5py / p5

p5 is a Python package based on the core ideas of Processing.
https://p5.readthedocs.io
GNU General Public License v3.0
736 stars 120 forks source link

Bug: Does not install or get the shaders directory #217

Closed Andy-Python-Programmer closed 4 years ago

Andy-Python-Programmer commented 4 years ago

Describe the bug I forked the repo and downloaded it. I renamed the main directory to main where code is not located so that the main and the local library do not clash.

To Reproduce Just download and run the repo with the original p5 version installed from pip

Expected behavior Should work as the folder was renamed so it should not clash.

Andy-Python-Programmer commented 4 years ago

213

arihantparsoya commented 4 years ago

@ziyaointl

Andy-Python-Programmer commented 4 years ago

Error


FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\p5\\sketch\\shaders\\2d\\default2d.vert'
arihantparsoya commented 4 years ago

I have just tested the latest version of p5py and it works fine.

arihantparsoya commented 4 years ago

Can you pull the master branch again and try?

Andy-Python-Programmer commented 4 years ago

Hi @parsoyaarihant I think I have found the main problem that is I think the Shaders are not provided in the pip release. So it’s trying to find the shaders where it was installed instead of the current directory.

ziyaointl commented 4 years ago

@Andy-Python-Programmer Sorry for the late reply!

I'm guessing this is due to pkgutil trying to lookup p5 and ends up in the pypi installation, though I'm not entirely sure. https://github.com/p5py/p5/blob/3e034c256788e39f38f1190923af18c2e6317db9/p5/sketch/util.py#L8

Could you create a new virtual environment that just contains the requirements for p5py and try again?

arihantparsoya commented 4 years ago

Alternatively you could uninstall the pip version and reinstall p5py from the repository's setup.py

ziyaointl commented 4 years ago

If you want to do it through a virtualenv, here's one way of doing it

git clone https://github.com/p5py/p5
cd p5
pip install --user pipenv
pipenv install -r requirements.txt # The setup.py has not been updated yet, so we'll manually install for now
pipenv install .
pipenv shell
python <p5 script you want to run>
Andy-Python-Programmer commented 4 years ago

Alternatively you could uninstall the pip version and reinstall p5py from the repository's setup.py

@parsoyaarihant @ziyaointl

I tried that and then my projects stopped working and again showed this error:


FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\p5\\sketch\\shaders\\2d\\default2d.vert'```
Andy-Python-Programmer commented 4 years ago

After the gloal repository installation:

Error

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    from p5 import *
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\p5\__init__.py", line 19, in <module>
    from .sketch import *
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\p5\sketch\__init__.py", line 21, in <module>
    from .userspace import *
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\p5\sketch\userspace.py", line 37, in <module>
    from .renderer2d import Renderer2D
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\p5\sketch\renderer2d.py", line 22, in <module>
    from .shaders2d import src_default, src_fbuffer
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\p5\sketch\shaders2d.py", line 25, in <module>
    src_default = ShaderSource(read_shader('2d/default2d.vert'), read_shader('common/default.frag'))
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\p5\sketch\util.py", line 8, in read_shader
    return pkgutil.get_data('p5', os.path.join('sketch/shaders/',filename)).decode()
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\pkgutil.py", line 637, in get_data
    return loader.get_data(resource_name)
  File "<frozen importlib._bootstrap_external>", line 972, in get_data
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages\\p5\\sketch\\shaders\\2d\\default2d.vert'
Andy-Python-Programmer commented 4 years ago

It cannot find the shaders even in a virtual env.

ziyaointl commented 4 years ago

The paths look like python is still referring to the global installation, not a version inside of a virtual env. Could you try the commands in my previous reply and let me know if it works?

Andy-Python-Programmer commented 4 years ago

Hi @ziyaointl I went into the folder and it does not have the shaders in there:

Screenshot

d

Andy-Python-Programmer commented 4 years ago

If I do git+install then it does not get the shaders folder

Andy-Python-Programmer commented 4 years ago

I have fixed this issue but this issue is not closed. Meaning I copied and pasted the folder of shaders in the sitepackages folder that is not ever recommended. I tried installing the library using pip install p5/ AKA current cloned directory. But still it did not install the shaders folder. So if its not able to install it locally then it will also not work in the pip version when the next one is released.

ziyaointl commented 4 years ago

So I tried this again myself, and it seems pip will not copy extra files in a repo when using pip install git+<link>. I'll open a PR that adds the shaders folder to the MANIFEST.in file.

Andy-Python-Programmer commented 4 years ago

How can i import the current directory package not the parent one @ziyaointl

Andy-Python-Programmer commented 4 years ago

Workssss Solved!!!