Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named '_sounddevice' (--record doesn't record it) #116

Open
yurivict opened this issue Jan 15, 2018 · 15 comments

Comments

@yurivict
Copy link

import sounddevice as sd fails with this message.

Installed as a FreeBSD port using version 0.3.10.

@mgeier
Copy link
Member

mgeier commented Jan 15, 2018

This might be a packaging issue, please report this to the package maintainer.

@yurivict
Copy link
Author

yurivict commented Jan 15, 2018

Sorry, forgot to mention: I am trying to create a FreeBSD port. When the package is built by the FreeBSD ports framework, the resulting package has this problem.

Such things virtually never happen. Packages normally work as intended. python-sounddevice turned out broken, which leads me to believe that there is some bug.

@yurivict yurivict reopened this Jan 15, 2018
@mgeier
Copy link
Member

mgeier commented Jan 15, 2018

Ah, OK, thanks for the additional information.

I have no idea how FreeBSD ports are created ...

Are you (or some helper function) at some point running something like python setup.py install?
The file _sounddevice.py is created at this step (using the CFFI module).
If not, you probably have to run this command (or similar) before creating the package. Probably you'll also have to specify a custom installation directory.

Or are you using wheels?
In that case, the wheel files (which are just ZIP files) should already contain _sounddevice.py.

Such things virtually never happen.

I assume this will happen with every module using CFFI in "out-of-line" mode, which all create a separate "hidden" module.

@yurivict
Copy link
Author

Are you (or some helper function) at some point running something like python setup.py install?

Yes, this is what is called.

@mgeier
Copy link
Member

mgeier commented Feb 4, 2018

OK, that's good.

Are there any error messages?

You'll have to make sure that the generated file _sounddevice.py will be included in your package.

@yurivict
Copy link
Author

yurivict commented Feb 4, 2018

_sounddevice.py is generated but isn't included.

setup.py is called approximately like this: setyp.py install --record file-list.txt. --record doesn't add _sounddevice.py into the list.

@mgeier
Copy link
Member

mgeier commented Feb 4, 2018

I can't reproduce this. When I try it (on Linux), I get a .egg file that includes _sounddevice.py. When I set zip_safe=False, I get a .egg directory and the file-list.txt contains _sounddevice.py.

Can you provide the exact command?

Probably this is a CFFI bug on FreeBSD?

If you run setup.py install, is the file actually created and copied to the right place?

@yurivict yurivict changed the title ModuleNotFoundError: No module named '_sounddevice' ModuleNotFoundError: No module named '_sounddevice' (--record doesn't record it) Feb 4, 2018
@yurivict
Copy link
Author

yurivict commented Feb 4, 2018

The command line:

/usr/local/bin/python2.7 \
  -c "import sys; import setuptools;  __file__='setup.py'; sys.argv[0]='setup.py';  exec(compile(open(__file__, 'rb').read().replace(b'\\r\\n', b'\\n'), __file__, 'exec'))" \
  install \
  --record XXX.PLIST.pymodtmp \
  -c -O1 \
  --prefix=/usr/local \
  --single-version-externally-managed \
  --root=/usr/ports/audio/py-sounddevice/work-py27/stage

creates the file XXX.PLIST.pymodtmp without _sounddevice.py* in it.

@mgeier
Copy link
Member

mgeier commented Feb 5, 2018

Thanks, now I can reproduce it (on Linux). Both on Python 2 and Python 3.
The file _sounddevice.py is correctly generated and copied to the target directory, but it's entry is missing from the "record" file.

I've reduced the command line to:

python3 setup.py install \
  --record file-list.txt \
  --root=/tmp/staging

I guess the problem happens for all modules that use CFFI in out-of-line ABI mode (like sounddevice), but it doesn't seem to happen in out-of-line API mode.

I've asked at the CFFI mailing list: https://groups.google.com/forum/?hl=en#!topic/python-cffi/oX2T_Y5m99I

@mgeier
Copy link
Member

mgeier commented Feb 11, 2018

There was an answer on the mailing list and the problem was fixed in https://bitbucket.org/cffi/cffi/commits/e59662b013b4b00b410d2df645837d9cf3ad5b52

@mgeier
Copy link
Member

mgeier commented Feb 27, 2018

CFFI 1.11.5 was just released, which should contain the fix.

@yurivict Can you please try if it works for you?

@yurivict
Copy link
Author

yurivict commented May 8, 2018

@mgeier This is still a problem with cffi-1.11.5.

@mgeier
Copy link
Member

mgeier commented May 14, 2018

Thanks @yurivict, I've asked again on the CFFI mailing list: https://groups.google.com/forum/?hl=en#!topic/python-cffi/oX2T_Y5m99I.

@mgeier
Copy link
Member

mgeier commented May 20, 2018

@yurivict Armin responded to my question on the mailing list, but he doesn't know how to fix this. Do you have any ideas?

@yurivict
Copy link
Author

The error I'm getting:

====> Checking for pkg-plist issues (check-plist)
===> Parsing plist
===> Checking for items in STAGEDIR missing from pkg-plist
Error: Orphaned: %%PYTHON_SITELIBDIR%%/_sounddevice.py
Error: Orphaned: %%PYTHON_SITELIBDIR%%/_sounddevice.pyc
Error: Orphaned: %%PYTHON_SITELIBDIR%%/_sounddevice.%%PYTHON_PYOEXTENSION%%
===> Checking for items in pkg-plist which are not in STAGEDIR
===> Error: Plist issues found.
*** Error code 1

For this reason, the FreeBSD port has to add these 3 items to plist by hand.
Unfortunately, I am not an expert in distutils/setuputils.
You likely need to ask on setuputils mailing list.

uqs pushed a commit to freebsd/freebsd-ports that referenced this issue May 27, 2019
  - Update COMMENT, match upstream setup.py:description
  - Update USES=python, now only supports Python 3.x
  - Switch to autoplist (using --record), update pkg-plist to add missing
    files until resolved upstream [1][2][3][4]

Changelog:

  https://github.com/Kozea/cairocffi/blob/v1.0.2/NEWS.rst

[1] Kozea/cairocffi#108
[2] spatialaudio/python-sounddevice#116
[3] tych0/xcffib#92
[4] See Also: https://groups.google.com/forum/#!topic/python-cffi/oX2T_Y5m99I

PR:			237884
Reviewed by:		mat, dch (maintainer)
Approved by:		dch (maintainer)
Differential Revision:	D20352


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@502792 35697150-7ecd-e111-bb59-0022644237b5
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue May 27, 2019
  - Update COMMENT, match upstream setup.py:description
  - Update USES=python, now only supports Python 3.x
  - Switch to autoplist (using --record), update pkg-plist to add missing
    files until resolved upstream [1][2][3][4]

Changelog:

  https://github.com/Kozea/cairocffi/blob/v1.0.2/NEWS.rst

[1] Kozea/cairocffi#108
[2] spatialaudio/python-sounddevice#116
[3] tych0/xcffib#92
[4] See Also: https://groups.google.com/forum/#!topic/python-cffi/oX2T_Y5m99I

PR:			237884
Reviewed by:		mat, dch (maintainer)
Approved by:		dch (maintainer)
Differential Revision:	D20352
Jehops pushed a commit to Jehops/freebsd-ports-legacy that referenced this issue May 27, 2019
  - Update COMMENT, match upstream setup.py:description
  - Update USES=python, now only supports Python 3.x
  - Switch to autoplist (using --record), update pkg-plist to add missing
    files until resolved upstream [1][2][3][4]

Changelog:

  https://github.com/Kozea/cairocffi/blob/v1.0.2/NEWS.rst

[1] Kozea/cairocffi#108
[2] spatialaudio/python-sounddevice#116
[3] tych0/xcffib#92
[4] See Also: https://groups.google.com/forum/#!topic/python-cffi/oX2T_Y5m99I

PR:			237884
Reviewed by:		mat, dch (maintainer)
Approved by:		dch (maintainer)
Differential Revision:	D20352


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@502792 35697150-7ecd-e111-bb59-0022644237b5
swills pushed a commit to swills/freebsd-ports that referenced this issue May 27, 2019
  - Update COMMENT, match upstream setup.py:description
  - Update USES=python, now only supports Python 3.x
  - Switch to autoplist (using --record), update pkg-plist to add missing
    files until resolved upstream [1][2][3][4]

Changelog:

  https://github.com/Kozea/cairocffi/blob/v1.0.2/NEWS.rst

[1] Kozea/cairocffi#108
[2] spatialaudio/python-sounddevice#116
[3] tych0/xcffib#92
[4] See Also: https://groups.google.com/forum/#!topic/python-cffi/oX2T_Y5m99I

PR:			237884
Reviewed by:		mat, dch (maintainer)
Approved by:		dch (maintainer)
Differential Revision:	D20352


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@502792 35697150-7ecd-e111-bb59-0022644237b5
svmhdvn pushed a commit to svmhdvn/freebsd-ports that referenced this issue Jan 10, 2024
  - Update COMMENT, match upstream setup.py:description
  - Update USES=python, now only supports Python 3.x
  - Switch to autoplist (using --record), update pkg-plist to add missing
    files until resolved upstream [1][2][3][4]

Changelog:

  https://github.com/Kozea/cairocffi/blob/v1.0.2/NEWS.rst

[1] Kozea/cairocffi#108
[2] spatialaudio/python-sounddevice#116
[3] tych0/xcffib#92
[4] See Also: https://groups.google.com/forum/#!topic/python-cffi/oX2T_Y5m99I

PR:			237884
Reviewed by:		mat, dch (maintainer)
Approved by:		dch (maintainer)
Differential Revision:	D20352
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants