LudovicRousseau / pyscard

pyscard smartcard library for python
http://pyscard.sourceforge.net/
GNU Lesser General Public License v2.1
383 stars 110 forks source link

Error while installing from PyPi #25

Closed lburg closed 8 years ago

lburg commented 8 years ago

I tried installing pyscard 1.9.3 through PyPi since the pip install bug seemed to be fixed, however I'm still having problems. I first downloaded the archive from sourceforge and try to build the wheel by myself:

$ tar xvzf pyscard-1.9.3.tar.gz
$ cd pyscard-1.9.3
$ pip wheel .
$ cd /path/to/my/project/
$ pip install /path/to/pyscard-1.9.3-cp34-cp34m-linux_x86_64.whl
$ ipython
In [1]: import smartcard
...
ImportError: No module named 'smartcard.scard.scard'

Running a simple pip install pyscard fails with the same error too. I then tried the same process straight from the master branch to see if I could reproduce the error:

$ cd /path/to/pyscard/repo/
$ pip wheel .
$ cd /path/to/my/project/
$ pip install /path/to/pyscard-1.9.3-cp34-cp34m-linux_x86_64.whl
$ ipython
In [1]: import smartcard

In [2]: 

I got no error when building the wheel from the cloned repository.

Is there a problem with the archive uploaded to the official PyPi?

LudovicRousseau commented 8 years ago

Yes, there is still a problem with PyPi. Can you compare the 2 .whl files to see what the differences are?

lburg commented 8 years ago

I've extracted the wheels in separate folders and compared their tree output, the scard.py file is missing from the PyPi release:

$ tree git > git.tree
$ tree pypi > pypi.tree
$ diff git.tree pypi.tree
1c1
< git
---
> pypi
5a6
> │   ├── pbr.json
50,51c51
<     │   ├── _scard.cpython-34m.so
<     │   └── scard.py
---
>     │   └── _scard.cpython-34m.so
LudovicRousseau commented 8 years ago

If you have a patch to fix the problem that would be perfect :-) What is strange is that you used the pip command in the two installs. One worked and not the other.

lburg commented 8 years ago

Well I don't know how you uploaded the package to PyPi, but I uploaded it myself to a private PyPi and it worked fine, so I'm not sure a patch is required, maybe just reuploading it? Here is what I did:

$ cd /path/to/pyscard/repo/
$ python setup.py register -r <our_pypi_index>
$ python setup.py sdist upload -r <our_pypi_index>

Then I was able to successfully download and install pyscard 1.9.3 in our project.

LudovicRousseau commented 8 years ago

I use make pypithat does some file cleanup and then:

$(PYTHON) setup.py sdist upload

See https://github.com/LudovicRousseau/pyscard/blob/master/Makefile#L10

I remove the generated scard.py and scard_wrap.c files because different SWIG will generate different versions. I had problems with this before. Maybe that explain why it works for you. I guess the swig generated files are present in the archive you send to Pypi.

lburg commented 8 years ago

Oh I see, so the problem is that the scard.py file is not generated upon installing the package. Weird, wasn't that fixed with PR #21?

ccpost commented 8 years ago

Yeah, I believe this should be fixed via #21, which isn't in 1.9.3. @LudovicRousseau you might want to do another release.

The original problem with #20 was that those overridden build steps don't happen with a PyPi install since it downloads the sdist, does bdist_wheel to build a local wheel for the PyPi cache, then installs the wheel. Overriding build_py should hit any build method.

LudovicRousseau commented 8 years ago

OK. I will plan a new release of PySCard. Thanks.

LudovicRousseau commented 8 years ago

The version 1.9.4 is now available. I hope the problem is now fixed. https://pypi.python.org/pypi/pyscard/1.9.4

lburg commented 8 years ago

Just tried installing version 1.9.4, no problem when importing the module, thanks!

LudovicRousseau commented 8 years ago

@lburg thanks for the feed back. I am happy we finally made it work from Pypi. Thanks to all the contributors.