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

Fix #15 - installing from pip and easy_install (Take 2) #21

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix #15 - installing from pip and easy_install (Take 2)
- 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
commit 55680b2e439f0f3a5afe0c4d693de091956c8395
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