1
1

setup.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # -*- coding: utf-8 -*-
  2. import os
  3. import platform
  4. import struct
  5. import sys
  6. from setuptools import setup
  7. python_version_major = sys.version_info.major
  8. if python_version_major == 2:
  9. from urllib import urlretrieve
  10. else:
  11. from urllib.request import urlretrieve
  12. with open(os.path.join(os.path.dirname(__file__),
  13. "elephant", "VERSION")) as version_file:
  14. version = version_file.read().strip()
  15. with open("README.md") as f:
  16. long_description = f.read()
  17. with open('requirements/requirements.txt') as fp:
  18. install_requires = fp.read().splitlines()
  19. extras_require = {}
  20. for extra in ['extras', 'docs', 'tests', 'tutorials']:
  21. with open('requirements/requirements-{0}.txt'.format(extra)) as fp:
  22. extras_require[extra] = fp.read()
  23. def download_spade_fim():
  24. """
  25. Downloads SPADE specific PyFIM binary file.
  26. """
  27. if platform.system() == "Windows":
  28. fim_filename = "fim.pyd"
  29. else:
  30. # Linux
  31. fim_filename = "fim.so"
  32. spade_src_dir = os.path.join(os.path.dirname(__file__), "elephant",
  33. "spade_src")
  34. fim_lib_path = os.path.join(spade_src_dir, fim_filename)
  35. if os.path.exists(fim_lib_path):
  36. return
  37. arch_bits = struct.calcsize("P") * 8
  38. url_fim = "http://www.borgelt.net/bin{arch}/py{py_ver}/{filename}". \
  39. format(arch=arch_bits, py_ver=python_version_major,
  40. filename=fim_filename)
  41. try:
  42. urlretrieve(url_fim, filename=fim_lib_path)
  43. print("Successfully downloaded fim lib to {}".format(fim_lib_path))
  44. except Exception:
  45. print("Unable to download {url} module.".format(url=url_fim))
  46. if len(sys.argv) > 1 and sys.argv[1].lower() != 'sdist':
  47. download_spade_fim()
  48. setup(
  49. name="elephant",
  50. version=version,
  51. packages=['elephant', 'elephant.test'],
  52. include_package_data=True,
  53. install_requires=install_requires,
  54. extras_require=extras_require,
  55. author="Elephant authors and contributors",
  56. author_email="andrew.davison@unic.cnrs-gif.fr",
  57. description="Elephant is a package for analysis of electrophysiology"
  58. " data in Python",
  59. long_description=long_description,
  60. license="BSD",
  61. url='http://neuralensemble.org/elephant',
  62. classifiers=[
  63. 'Development Status :: 5 - Production/Stable',
  64. 'Intended Audience :: Science/Research',
  65. 'License :: OSI Approved :: BSD License',
  66. 'Natural Language :: English',
  67. 'Operating System :: OS Independent',
  68. 'Programming Language :: Python :: 2',
  69. 'Programming Language :: Python :: 3',
  70. 'Topic :: Scientific/Engineering']
  71. )