electronstudio / raylib-python-cffi

Python CFFI bindings for Raylib
http://electronstudio.github.io/raylib-python-cffi
Eclipse Public License 2.0
142 stars 29 forks source link

Module 'version.py' not found while installing via pip #49

Closed pkulev closed 2 years ago

pkulev commented 2 years ago

Hi, trying to install via pip (python3.9):

╰─$ pip install raylib
Collecting raylib
  Using cached raylib-3.7.0.post9.tar.gz (71 kB)
    ERROR: Command errored out with exit status 1:
     command: /private/tmp/hui/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zf/d8kdk1ln39qf42k6676nb3980000gn/T/pip-install-kx_nuh68/raylib_01e3808c2aff44c09a7600fca69c9898/setup.py'"'"'; __file__='"'"'/private/var/folders/zf/d8kdk1ln39qf42k6676nb3980000gn/T/pip-install-kx_nuh68/raylib_01e3808c2aff44c09a7600fca69c9898/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/zf/d8kdk1ln39qf42k6676nb3980000gn/T/pip-pip-egg-info-f01r36ra
         cwd: /private/var/folders/zf/d8kdk1ln39qf42k6676nb3980000gn/T/pip-install-kx_nuh68/raylib_01e3808c2aff44c09a7600fca69c9898/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/zf/d8kdk1ln39qf42k6676nb3980000gn/T/pip-install-kx_nuh68/raylib_01e3808c2aff44c09a7600fca69c9898/setup.py", line 4, in <module>
        from version import __version__
    ModuleNotFoundError: No module named 'version'

I bet it's because version.py is not included in Manifest.in, I see it included already in https://github.com/electronstudio/raylib-python-cffi/commit/775d2da32df895e4c407d86b7d4a5e826bbd9424.

Please, publish fixed version into PyPI.

pkulev commented 2 years ago

Oops, I finally found that there is prerelease version with fixes, but it failed to install on MacOS. So this issue should be closed.

electronstudio commented 2 years ago

Thanks I did fix this but forgot it was present in 3.7.0post9. I have no idea when 4.0.0 is going to be released so I should backport the fix into 3.7.0.

It’s quite bizarre that there seems to be no way of including a version number in a file in a library that isn’t a nasty hack. Stack over flow shows a bunch of solutions and they are all nasty.

pkulev commented 2 years ago

Oh, packaging is not easy anywhere. Why version should be in separate file? I use pyproject.toml with poetry and bump version using poetry version [patch|minor|major]. Publishing also quite easy, just build and publish commands. But maybe for such complex stuff like CFFI bindings it's not so easy to do...

electronstudio commented 2 years ago

Version doesn't have to be in a separate file, but it does need to be available in raylib/init.py and dynamic/raylib/init.py and in setup.py. So whichever one you put it in, the others now depend on that. So I figured easier to have all three depend on one separate file.

I'll take a look at Poetry.

electronstudio commented 2 years ago

btw what platform are you on that we don't have binary wheels for?

electronstudio commented 2 years ago

And what are the errors when you try to install 4.0a4 ?

pkulev commented 2 years ago

btw what platform are you on that we don't have binary wheels for?

MacOS on m1 (I was going to report this in issue with macos)

And what are the errors when you try to install 4.0a4 ?

      File "raylib/build.py", line 152, in <module>
        build_mac()
      File "raylib/build.py", line 104, in build_mac
        ffibuilder.cdef(mangle("/usr/local/include/raylib.h"))
      File "raylib/build.py", line 31, in mangle
        for line in open(file):
    FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/include/raylib.h'
    BUILDING FOR MAC
    --------------------
pkulev commented 2 years ago

but it does need to be available in raylib/init.py and dynamic/raylib/init.py and in setup.py.

I packaged only easy things and for getting version inside package I used this:

import importlib.metadata
print(importlib.metadata.version('package-name') 

Of course it requires some sort of virtualenv for development (python -m venv .venv or things like poetry can create it transparently) or be installed into system site-packages somehow (via pip or if it packaged for system PM like dnf / portage / brew / etc.).

electronstudio commented 2 years ago

This should be fixed in 3.7.0.post10