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

nsound does not work with swig3, ubuntu 16 #5

Open
weegreenblobbie opened this issue Jun 25, 2016 · 23 comments
Open

nsound does not work with swig3, ubuntu 16 #5

weegreenblobbie opened this issue Jun 25, 2016 · 23 comments

Comments

@weegreenblobbie
Copy link
Owner

@weegreenblobbie weegreenblobbie commented Jun 25, 2016

I'm having all kinds of problems on ubuntu 16 out of the box:

Ubuntu 16 default swig package is 3.X, which doesn't seem to work with nsound 0.9.4. After building and installing the python package with swig3, I get strange errors, as simple trying to construct a Sine generator:

import Nsound as ns
g = ns.Sine(44100)
#...
AttributeError: type object 'object' has no attribute '__getattr__'

Nsound partially works after installing the swig2.0 package:

sudo apt-get install swig2.0

Running unit tests from the git clone works as expeted:

python -m unittest discover
.....................................
----------------------------------------------------------------------
Ran 37 tests in 2.971s

OK

However trying to run one of the examples hangs in what appears to be an infinite loop:

cd src/examples
python example1.py
# no output, just hangs

Please fix for Ubuntu 16!

@ghost
Copy link

@ghost ghost commented Feb 10, 2017

Hello, wegreenblobbie.

I'm having the same issue in Fedora 24. Is there any solution at this moment besides downgrading swig?
Cheers

@weegreenblobbie
Copy link
Owner Author

@weegreenblobbie weegreenblobbie commented Feb 10, 2017

I haven't looked into this, I could take a look this weekend.

@ghost
Copy link

@ghost ghost commented Feb 11, 2017

That would be awesome!

@weegreenblobbie
Copy link
Owner Author

@weegreenblobbie weegreenblobbie commented Feb 11, 2017

Partial success. It turns out that swig 3.08 (the packaged version in ubuntu 16.04) is buggy.

I manually installed swig 3.0.12, some things are working, unit tests are passing (I don't have much coverage), but some of the examples still hang.

@ghost
Copy link

@ghost ghost commented Feb 11, 2017

I searched similar errors online and swig does seem buggy. I think this is useful:
swig/swig#553

@weegreenblobbie
Copy link
Owner Author

@weegreenblobbie weegreenblobbie commented Feb 11, 2017

Yeah, I saw that too, but the -modern doesn't seem to have any impact with swig 3.0.12.

@weegreenblobbie
Copy link
Owner Author

@weegreenblobbie weegreenblobbie commented Feb 12, 2017

@weegreenblobbie
Copy link
Owner Author

@weegreenblobbie weegreenblobbie commented Feb 12, 2017

work in progress ...

@weegreenblobbie
Copy link
Owner Author

@weegreenblobbie weegreenblobbie commented Feb 13, 2017

@respinha try out the branch "bugfix/issue5", you will need swig 3.0.12, let me know if it works for you.

My long term plan is to completely rewrite Nsound in c++14, the existing code base is very old and difficult to maintain. SWIG is also very painful, I may look into alternatives like cython, boost::python, or pybind11.

:)

@ghost
Copy link

@ghost ghost commented Feb 13, 2017

@weegreenblobbie I removed the previously generated python files with a 'pip uninstall' and then tried the new branch and still doesn't work when I create a Sine.

PS: indeed, swig seems troublesome.

@weegreenblobbie
Copy link
Owner Author

@weegreenblobbie weegreenblobbie commented Feb 13, 2017

How did you install? You can check what version is installed by looking at Nsound.__version__. Make sure it reports 0.9.5.dev1.

You can also try to see if the unittests run with: scons --pytest

@ghost
Copy link

@ghost ghost commented Feb 14, 2017

I installed as you suggest in the INSTALL file, running scons and then sudo python setup.py install.
I also tried running unittests and they all fail with the same error.

PS: yes, my version is 0.9.5.dev1

@weegreenblobbie
Copy link
Owner Author

@weegreenblobbie weegreenblobbie commented Feb 14, 2017

Perhaps there is another issue, can you paste in the error. I'll try to run Fedora 24 in a VM to see if I can duplicate the error you're seeing.

@ghost
Copy link

@ghost ghost commented Feb 14, 2017

@weegreenblobbie it's the same error in all tests. Whenever an object of any type is created, it always crashes with this stacktrace:

File ".local/lib/python2.7/site-packages/Nsound-0.9.5.dev1-py2.7-linux-x86_64.egg/Nsound.py", line 7522, in __init__
    self.this.append(this)
  File ".local/lib/python2.7/site-packages/Nsound-0.9.5.dev1-py2.7-linux-x86_64.egg/Nsound.py", line 7515, in <lambda>
    __getattr__ = lambda self, name: _swig_getattr(self, Sine, name)
  File ".local/lib/python2.7/site-packages/Nsound-0.9.5.dev1-py2.7-linux-x86_64.egg/Nsound.py", line 74, in _swig_getattr
    return _swig_getattr_nondynamic(self, class_type, name, 0)
  File ".local/lib/python2.7/site-packages/Nsound-0.9.5.dev1-py2.7-linux-x86_64.egg/Nsound.py", line 69, in _swig_getattr_nondynamic
    return object.__getattr__(self, name)
@weegreenblobbie
Copy link
Owner Author

@weegreenblobbie weegreenblobbie commented Feb 14, 2017

What does swig -version report?

@ghost
Copy link

@ghost ghost commented Feb 14, 2017

3.0.8

@weegreenblobbie
Copy link
Owner Author

@weegreenblobbie weegreenblobbie commented Feb 14, 2017

3.0.8 is buggy, can you install the latest? 3.012?

@ghost
Copy link

@ghost ghost commented Feb 14, 2017

Updated swig, removed all instances of Nsound and installed 0.9.5.dev1 and it still doesn't work.

@weegreenblobbie
Copy link
Owner Author

@weegreenblobbie weegreenblobbie commented Feb 14, 2017

Same error? I guess I'll just have to get fedora 24 and see what's up. Thanks for the testing.

@ghost
Copy link

@ghost ghost commented Feb 14, 2017

I really doubt that it's something to do with Fedora but you can always check it out! I am planning to get started on the 'audio programming' world and Nsound really seems an interesting solution.

@weegreenblobbie
Copy link
Owner Author

@weegreenblobbie weegreenblobbie commented Feb 15, 2017

@respinha I just built nsound in a docker container using fedora:24, unittests ran fine. I suspect that swig 3.0.8 is somehow still getting used during the build. Here's my Dockerfile:

FROM fedora:24


RUN \
    dnf install  -vy     \
        gcc-c++.x86_64 \
        make.x86_64 \
        pcre-devel.x86_64 \
        python-devel.x86_64 \
        python.x86_64 \
        python2-matplotlib-tk.x86_64 \
        python2-numpy.x86_64 \
        redhat-rpm-config.noarch \
        scons.noarch \
        tar.x86_64 \
        unzip.x86_64 \
        wget.x86_64


RUN \
    cd /tmp/                                                              && \
    export SWIG_URL='https://downloads.sourceforge.net/project/swig/swig/swig-3.0.12/swig-3.0.12.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fswig%2Ffiles%2Fswig%2Fswig-3.0.12%2Fswig-3.0.12.tar.gz%2Fdownload%3Fuse_mirror%3Dsuperb-sea2&ts=1487115624&use_mirror=svwh' && \
    wget -O swig-3.0.12.tar.gz "$SWIG_URL"                                && \
    tar xf swig*                                                          && \
    cd swig*                                                              && \
    ./configure --prefix=/usr                                             && \
    make -j 4                                                             && \
    make install


RUN \
    cd /tmp/                                                              && \
    wget https://github.com/weegreenblobbie/nsound/archive/bugfix/issue5.zip && \
    unzip issue5.zip                                                      && \
    ls -lh                                                                && \
    cd nsound*                                                            && \
    scons --pytest

Here's the output:

# ...
creating dist
creating 'dist/Nsound-0.9.5.dev1-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing Nsound-0.9.5.dev1-py2.7-linux-x86_64.egg
creating /root/.local/lib/python2.7/site-packages/Nsound-0.9.5.dev1-py2.7-linux-x86_64.egg
Extracting Nsound-0.9.5.dev1-py2.7-linux-x86_64.egg to /root/.local/lib/python2.7/site-packages
Adding Nsound 0.9.5.dev1 to easy-install.pth file

Installed /root/.local/lib/python2.7/site-packages/Nsound-0.9.5.dev1-py2.7-linux-x86_64.egg
Processing dependencies for Nsound==0.9.5.dev1
Finished processing dependencies for Nsound==0.9.5.dev1
.........sss.........................
----------------------------------------------------------------------
Ran 37 tests in 0.591s

OK (skipped=3)
@ghost
Copy link

@ghost ghost commented Feb 15, 2017

It seems like I hadn't totally removed swig 3.0.8. It is now working!

@weegreenblobbie
Copy link
Owner Author

@weegreenblobbie weegreenblobbie commented Feb 15, 2017

Who hoo! 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.