Coder Social home page Coder Social logo

chdkptp.py's Introduction

chdkptp.py

Python bindings for chdkptp via an embedded, thread-safe Lua runtime (thanks to Stefan Behnel's lupa).

Requirements

  • C compiler
  • Lua 5.2, with headers
  • libusb, with headers
  • lupa, installed with the --no-luajit flag

Currently chdkptp.py only works when the lupa package is linked to Lua. However, by default the package links to LuaJIT, so make sure that you install it with the --no-luajit flag. It is best to do this via pip, before you install chdkptp.py:

$ pip install lupa --install-option='--no-luajit'

Documentation

Please refer to the API documentation on readthedocs.org

chdkptp.py's People

Contributors

duerig avatar jbaiter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

chdkptp.py's Issues

Can't install on raspberry pi 3b+

Hi,

I tried to install on my raspberry pi but it can't finish the following command:
sudo pip install chdkptp.py

I get this error:
Failed to build wheel for chdkptp.py
and then:
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-e68krr/chdkptp.py/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-nAn0pP/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-e68krr/chdkptp.py/

I found that the `encode=None` at the lua runtime was the cause of the issue, but now I can't install the package.

How did you solve this issue? I am currently dealing with the exact same error message

I found that the encode=None at the lua runtime was the cause of the issue, but now I can't install the package.

lupa._lupa.LuaError: [string "<python>"]:2: module 'chdkptp' not found:
	no field package.preload['chdkptp']
	no file '/home/sd/Documents/HACKPLACE/chdkptp.py/chdkptp/vendor/chdkptp/lua/chdkptp.lua'
	no file '/usr/local/share/lua/5.2/chdkptp.lua'
	no file '/usr/local/share/lua/5.2/chdkptp/init.lua'
	no file '/usr/local/lib/lua/5.2/chdkptp.lua'
	no file '/usr/local/lib/lua/5.2/chdkptp/init.lua'
	no file '/usr/share/lua/5.2/chdkptp.lua'
	no file '/usr/share/lua/5.2/chdkptp/init.lua'
	no file './chdkptp.lua'
	no file '/home/sd/Documents/HACKPLACE/chdkptp.py/chdkptp/vendor/chdkptp/chdkptp.so'
	no file '/home/sd/Documents/HACKPLACE/chdkptp.py/chdkptp/vendor/chdkptp/lua/chdkptp.lua'
	no file '/usr/local/share/lua/5.2/chdkptp.lua'
	no file '/usr/local/share/lua/5.2/chdkptp/init.lua'
	no file '/usr/local/lib/lua/5.2/chdkptp.lua'
	no file '/usr/local/lib/lua/5.2/chdkptp/init.lua'
	no file '/usr/share/lua/5.2/chdkptp.lua'
	no file '/usr/share/lua/5.2/chdkptp/init.lua'
	no file './chdkptp.lua'
stack traceback:
	[C]: in function 'require'
	[string "<python>"]:2: in main chunk

Looks like the package is looking for the lua files at my relative path not inside the chdkptp installation path.

Originally posted by @5up3rD4n1 in #6 (comment)

Installing on MacOS 10.13

I've been fiddling with trying to get this to install on mac os x 10.13. Here is some documentation of what I've got working so far, if I go all the way, this may result in a pull request.

I've been able to build chdkptp by itself, by following these directions: simonswine/chdkptp#1 plus using gsed instead of sed (brew install gsed; and modify one line in the Makefile to gsed instead of sed)
The latest chdkptp has a sample mac script which works fine after following these directions.

Now for getting pip install to work, based on that:

  1. be sure to use lua-5.2 available from macports
  2. modify config-sample-linux.mk according to those directions
  3. add this to chdkptp_module.diff:
@@ -6,7 +6,7 @@ TOPDIR=.
 include include.mk
 
 ifdef USE_SVNREV
-SVNREV=$(shell svnversion -n |sed -r -e's/^([0-9]+:)?([0-9]+)[MSP]?/\2/')
+SVNREV=$(shell svnversion -n |gsed -r -e's/^([0-9]+:)?([0-9]+)[MSP]?/\2/')
 ifeq ("$(SVNREV)","")
 SVNREV=0
 endif
  1. pip install lupa --install-option='--no-luajit'
  2. pip install [chdkptp.py directory]

Now the build appears to proceed normally with all your standard build messages, no errors some innocuous looking warnings: https://gist.github.com/meelash/9482e70ebe43cde821bd61cb7d2a6829
I notice a binary does not appear to be created like it does when using the standard Makefile, I assume this is by design, but I also don't notice the creation of any native libraries, which is interesting giving the problem I have next.

Opening a python shell and typing
import chdkptp.py
Throws an error that is apparently related to lua being unable to require a chdkptp module:
https://gist.github.com/meelash/a180c71592b0b90a4b097827fdf085c7
I assume this must have something to do with the changes being made in chdkptp_module.diff because, otherwise nothing else being done is different from when I just built chdk by itself.

I'll continue to look into this but any suggestions would certainly be nice...

Python3.6 compatibility

Hi Baiter, I'm trying to import chdkptp with python 3.6 (I know it is not supported yet) but maybe you can help me out wit this.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sd/.pyenv/versions/3.6.0/lib/python3.6/site-packages/chdkptp/__init__.py", line 1, in <module>
    from chdkptp.device import ChdkDevice, list_devices, DeviceInfo
  File "/home/sd/.pyenv/versions/3.6.0/lib/python3.6/site-packages/chdkptp/device.py", line 3, in <module>
    import StringIO
ModuleNotFoundError: No module named 'StringIO'

So, StringIO is deprecated on Python3.6 so I try to 'hack' the system modules with

>>> import sys, io
>>> sys.modules['StringIO'] = io

and I'm getting now the following Traceback when I import chdkptp

>>> import sys, io
>>> sys.modules['StringIO'] = io
>>> import chdkptp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sd/.pyenv/versions/3.6.0/lib/python3.6/site-packages/chdkptp/__init__.py", line 1, in <module>
    from chdkptp.device import ChdkDevice, list_devices, DeviceInfo
  File "/home/sd/.pyenv/versions/3.6.0/lib/python3.6/site-packages/chdkptp/device.py", line 8, in <module>
    from chdkptp.lua import LuaContext, global_lua, parse_table
  File "/home/sd/.pyenv/versions/3.6.0/lib/python3.6/site-packages/chdkptp/lua.py", line 141, in <module>
    global_lua = LuaContext()
  File "/home/sd/.pyenv/versions/3.6.0/lib/python3.6/site-packages/chdkptp/lua.py", line 92, in __init__
    self._setup_runtime()
  File "/home/sd/.pyenv/versions/3.6.0/lib/python3.6/site-packages/chdkptp/lua.py", line 100, in _setup_runtime
    """)
  File "lupa/_lupa.pyx", line 262, in lupa._lupa.LuaRuntime.execute
  File "lupa/_lupa.pyx", line 1279, in lupa._lupa.run_lua
  File "lupa/_lupa.pyx", line 1288, in lupa._lupa.call_lua
  File "lupa/_lupa.pyx", line 1314, in lupa._lupa.execute_lua_call
  File "lupa/_lupa.pyx", line 1250, in lupa._lupa.raise_lua_error
lupa._lupa.LuaError: [string "<python>"]:3: attempt to concatenate global 'CHDKPTP_PATH' (a userdata value)
stack traceback:
	[string "<python>"]:3: in main chunk

Do you have an idea how can I solve this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.