Skip to content

Commit

Permalink
Fix #15 - installing from pip and easy_install (Take 2)
Browse files Browse the repository at this point in the history
- Ensure that the `build_ext` task is called before `build_py` to
  generate SWIG .py files before the Python copy step happens and we
  miss packaging and installing the generated files.
- Add Makefile target `test_install` for testing multiple build and
  install methods on the active Python installation.
  • Loading branch information
ccpost committed Mar 27, 2016
1 parent d088bc8 commit 55680b2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,24 @@ pypi: clean
test: build
$(PYTHON) setup.py test

test_install:
# Test installing directly from the local checkout
for cmd in "python setup.py install" "pip install ." "easy_install ."; do \
pip uninstall -y pyscard &> /dev/null; \
git clean -dxf &> /dev/null; \
$$cmd &> /dev/null; \
python -c "import sys; sys.path.remove(''); import smartcard"; \
echo "Installed using '$$cmd' - test exit code: $$?"; \
done

# Test installing using the sdist
git clean -dxf &> /dev/null
python setup.py sdist &>/dev/null
for cmd in "pip install dist/*" "easy_install dist/*"; do \
pip uninstall -y pyscard &> /dev/null; \
$$cmd &> /dev/null; \
python -c "import sys; sys.path.remove(''); import smartcard"; \
echo "Installed using '$$cmd' - test exit code: $$?"; \
done

.PHONY: clean build pypi test
10 changes: 10 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import sys

from setuptools import setup, Extension
from setuptools.command.build_py import build_py


if sys.version_info[0:2] < (2, 6):
Expand Down Expand Up @@ -83,6 +84,14 @@
VERSION_ALT = '%i,%01i,%01i,%04i' % VERSION_INFO


class BuildPyBuildExtFirst(build_py):
"""Workaround substitude `build_py` command for SWIG"""
def run(self):
# Run build_ext first so that SWIG generated files are included
self.run_command('build_ext')
return build_py.run(self)


kw = {'name': "pyscard",
'version': VERSION_STR,
'description': "Smartcard module for Python.",
Expand All @@ -106,6 +115,7 @@
"smartcard/wx": ["resources/*.ico"],
},

'cmdclass': {'build_py': BuildPyBuildExtFirst},
# the _scard.pyd extension to build
'ext_modules': [Extension("smartcard.scard._scard",
define_macros=[
Expand Down

0 comments on commit 55680b2

Please sign in to comment.