python: importing libpci raises SyntaxError
<p>I just installed libpci on my machine:  </p>

<pre><code>$ pip2.7 install libpci
</code></pre>

<p>And tried to run this:  </p>

<pre><code>#!/usr/local/bin/python2.7
import libpci

print('hello libpci')
</code></pre>

<p>but this raises the following syntax error:</p>

<pre><code>Traceback (most recent call last):
  File "./test.py", line 2, in &lt;module&gt;
    import libpci
  File "/usr/local/lib/python2.7/site-packages/libpci/__init__.py", line 26, in &lt;module&gt;
    from libpci.wrapper import LibPCI
  File "/usr/local/lib/python2.7/site-packages/libpci/wrapper.py", line 26, in &lt;module&gt;
    from libpci._functions import pci_alloc
  File "/usr/local/lib/python2.7/site-packages/libpci/_functions.py", line 39
    def pci_alloc() -&gt; ctypes.POINTER(pci_access):
                    ^
SyntaxError: invalid syntax
</code></pre>

<p>How is it possible to have SyntaxError raised in libpci?<br>
Is it because I am missing some dependencies? </p>

<p>The <a href="https://pypi.python.org/pypi/libpci" rel="nofollow"><code>libpci</code> project</a> requires Python 3.4 or newer. From the project tags:</p>

<blockquote>
<pre><code>Categories
[...]
Programming Language :: Python :: 3
Programming Language :: Python :: 3.4
</code></pre>
</blockquote>

<p>The syntax error is thrown because the project uses <a href="https://www.python.org/dev/peps/pep-3107/" rel="nofollow">annotations</a>, a Python 3 feature, to configure the <code>ctypes</code> layer, see the <a href="https://github.com/zyga/libpci/blob/master/libpci/_native.py#L54" rel="nofollow"><code>_ctypes_metadata()</code> function</a>.</p>

python python-2.7