|
| 1 | +"""A setuptools based setup module. |
| 2 | +
|
| 3 | +See: |
| 4 | +https://packaging.python.org/en/latest/distributing.html |
| 5 | +https://github.com/pypa/sampleproject |
| 6 | +""" |
| 7 | + |
| 8 | +# Always prefer setuptools over distutils |
| 9 | +from setuptools import setup, find_packages |
| 10 | +# To use a consistent encoding |
| 11 | +from codecs import open |
| 12 | +from os import path, environ |
| 13 | +from distutils.extension import Extension |
| 14 | +from distutils.util import get_platform, check_environ |
| 15 | + |
| 16 | +here = path.abspath(path.dirname(__file__)) |
| 17 | + |
| 18 | +# Get the long description from the README file |
| 19 | +with open(path.join(here, 'README.rst'), encoding='utf-8') as f: |
| 20 | + long_description = f.read() |
| 21 | +description = 'A free opensource globalplatform library for java card and smartcard.' |
| 22 | + |
| 23 | + |
| 24 | +include_dirs = [] |
| 25 | +define_macros = [] |
| 26 | +library_dirs = [] |
| 27 | + |
| 28 | +if 'win32' == get_platform(): |
| 29 | + gp_include_dir = '' |
| 30 | + gp_library_dir = '' |
| 31 | + |
| 32 | + import sys |
| 33 | + if 'install' in sys.argv: |
| 34 | + if environ.has_key('GLOBALPLATFORM_ROOT'): |
| 35 | + gp_include_dir = environ['GLOBALPLATFORM_ROOT'] |
| 36 | + gp_library_dir = environ['GLOBALPLATFORM_ROOT'] |
| 37 | + else: |
| 38 | + print 'Please set system environ variable GLOBALPLATFORM_ROOT first!' |
| 39 | + exit(-1) |
| 40 | + |
| 41 | + include_dirs = [gp_include_dir, ] |
| 42 | + define_macros = [('_WIN32', 1), ('WIN32', 1), ] |
| 43 | + library_dirs = [gp_library_dir, ] |
| 44 | +else: |
| 45 | + include_dirs = ['/usr/include/PCSC'] |
| 46 | + define_macros = [] |
| 47 | + library_dirs = [] |
| 48 | + |
| 49 | +setup( |
| 50 | + name='pyGlobalPlatform', |
| 51 | + |
| 52 | + # Versions should comply with PEP440. For a discussion on single-sourcing |
| 53 | + # the version across setup.py and the project code, see |
| 54 | + # https://packaging.python.org/en/latest/single_source_version.html |
| 55 | + version='1.2.16', |
| 56 | + |
| 57 | + description=description, |
| 58 | + long_description=long_description, |
| 59 | + |
| 60 | + # The project's main homepage. |
| 61 | + url='http://www.javacardos.com/', |
| 62 | + |
| 63 | + # Author details |
| 64 | + author='www.JavaCardOS.com', |
| 65 | + |
| 66 | + |
| 67 | + # Choose your license |
| 68 | + license='MIT', |
| 69 | + |
| 70 | + # See https://pypi.python.org/pypi?%3Aaction=list_classifiers |
| 71 | + classifiers=[ |
| 72 | + # How mature is this project? Common values are |
| 73 | + # 3 - Alpha |
| 74 | + # 4 - Beta |
| 75 | + # 5 - Production/Stable |
| 76 | + 'Development Status :: 5 - Production/Stable', |
| 77 | + |
| 78 | + # Indicate who your project is intended for |
| 79 | + 'Intended Audience :: Developers', |
| 80 | + 'Topic :: Software Development :: Build Tools', |
| 81 | + |
| 82 | + # Pick your license as you wish (should match "license" above) |
| 83 | + 'License :: OSI Approved :: MIT License', |
| 84 | + |
| 85 | + # Specify the Python versions you support here. In particular, ensure |
| 86 | + # that you indicate whether you support Python 2, Python 3 or both. |
| 87 | + 'Programming Language :: Python :: 2', |
| 88 | + 'Programming Language :: Python :: 2.6', |
| 89 | + 'Programming Language :: Python :: 2.7', |
| 90 | + 'Programming Language :: Python :: 3', |
| 91 | + 'Programming Language :: Python :: 3.3', |
| 92 | + 'Programming Language :: Python :: 3.4', |
| 93 | + 'Programming Language :: Python :: 3.5', |
| 94 | + ], |
| 95 | + |
| 96 | + # What does your project relate to? |
| 97 | + keywords='smartcard javacard globalplatform', |
| 98 | + |
| 99 | + # You can just specify the packages manually here if your project is |
| 100 | + # simple. Or you can use find_packages(). |
| 101 | + packages=find_packages(exclude=['contrib', 'docs', 'tests']), |
| 102 | + |
| 103 | + # Alternatively, if you want to distribute just a my_module.py, uncomment |
| 104 | + # this: |
| 105 | + # py_modules=["my_module"], |
| 106 | + |
| 107 | + # List run-time dependencies here. These will be installed by pip when |
| 108 | + # your project is installed. For an analysis of "install_requires" vs pip's |
| 109 | + # requirements files see: |
| 110 | + # https://packaging.python.org/en/latest/requirements.html |
| 111 | + install_requires=['peppercorn'], |
| 112 | + |
| 113 | + # List additional groups of dependencies here (e.g. development |
| 114 | + # dependencies). You can install these using the following syntax, |
| 115 | + # for example: |
| 116 | + # $ pip install -e .[dev,test] |
| 117 | + # extras_require={ |
| 118 | + # 'dev': ['check-manifest'], |
| 119 | + # 'test': ['coverage'], |
| 120 | + # }, |
| 121 | + |
| 122 | + # If there are data files included in your packages that need to be |
| 123 | + # installed, specify them here. If using Python 2.6 or less, then these |
| 124 | + # have to be included in MANIFEST.in as well. |
| 125 | + package_data={ |
| 126 | + # 'sample': ['package_data.dat'], |
| 127 | + }, |
| 128 | + |
| 129 | + # Although 'package_data' is the preferred approach, in some case you may |
| 130 | + # need to place data files outside of your packages. See: |
| 131 | + # http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa |
| 132 | + # In this case, 'data_file' will be installed into '<sys.prefix>/my_data' |
| 133 | + # data_files=[('my_data', ['data/data_file'])], |
| 134 | + |
| 135 | + # To provide executable scripts, use entry points in preference to the |
| 136 | + # "scripts" keyword. Entry points provide cross-platform support and allow |
| 137 | + # pip to create the appropriate form of executable for the target platform. |
| 138 | + entry_points={ |
| 139 | + # 'console_scripts': [ |
| 140 | + # 'sample=sample:main', |
| 141 | + # ], |
| 142 | + }, |
| 143 | + |
| 144 | + ext_modules = [ |
| 145 | + Extension( |
| 146 | + 'pyGlobalPlatform.pyglobalplatform' |
| 147 | + , ['./src/main.cpp', './src/gp_functions.cpp', ] |
| 148 | + , include_dirs = include_dirs |
| 149 | + , define_macros = define_macros |
| 150 | + , libraries = ['globalplatform', ] |
| 151 | + , library_dirs = library_dirs |
| 152 | + ) |
| 153 | + ], |
| 154 | + |
| 155 | +) |
0 commit comments