1# coding: utf-8 2 3from setuptools import setup, find_packages 4 5from distutils.command.build_py import build_py 6 7import os 8 9with open("README.rst", "r", encoding="utf8") as file: 10 long_description = file.read() 11 12# Get __version__ from libpysal/__init__.py without importing the package 13# __version__ has to be defined in the first line 14with open("libpysal/__init__.py", "r") as f: 15 exec(f.readline()) 16 17# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly 18# update it when the contents of directories change. 19if os.path.exists("MANIFEST"): 20 os.remove("MANIFEST") 21 22 23def _get_requirements_from_files(groups_files): 24 groups_reqlist = {} 25 26 for k, v in groups_files.items(): 27 with open(v, "r") as f: 28 pkg_list = f.read().splitlines() 29 groups_reqlist[k] = pkg_list 30 31 return groups_reqlist 32 33 34def setup_package(): 35 # get all file endings and copy whole file names without a file suffix 36 # assumes nested directories are only down one level 37 _groups_files = { 38 "base": "requirements.txt", 39 "plus_conda": "requirements_plus_conda.txt", 40 "plus_pip": "requirements_plus_pip.txt", 41 "dev": "requirements_dev.txt", 42 "docs": "requirements_docs.txt", 43 } 44 45 reqs = _get_requirements_from_files(_groups_files) 46 install_reqs = reqs.pop("base") 47 extras_reqs = reqs 48 49 # get all file endings and copy whole file names without a file suffix 50 # assumes nested directories are only down one level 51 example_data_files = set() 52 for i in os.listdir("libpysal/examples"): 53 if i.endswith(("py", "pyc")): 54 continue 55 if not os.path.isdir("libpysal/examples/" + i): 56 if "." in i: 57 glob_name = "examples/*." + i.split(".")[-1] 58 else: 59 glob_name = "examples/" + i 60 else: 61 glob_name = "examples/" + i + "/*" 62 63 example_data_files.add(glob_name) 64 65 setup( 66 name="libpysal", 67 version=__version__, 68 description="Core components of PySAL A library of spatial analysis functions.", 69 long_description=long_description, 70 long_description_content_type="text/x-rst", 71 maintainer="PySAL Developers", 72 maintainer_email="pysal-dev@googlegroups.com", 73 url="http://pysal.org/libpysal", 74 download_url="https://pypi.python.org/pypi/libpysal", 75 license="BSD", 76 py_modules=["libpysal"], 77 packages=find_packages(), 78 tests_require=["pytest"], 79 keywords="spatial statistics", 80 classifiers=[ 81 "Development Status :: 5 - Production/Stable", 82 "Intended Audience :: Science/Research", 83 "Intended Audience :: Developers", 84 "Intended Audience :: Education", 85 "Topic :: Scientific/Engineering", 86 "Topic :: Scientific/Engineering :: GIS", 87 "License :: OSI Approved :: BSD License", 88 "Programming Language :: Python", 89 "Programming Language :: Python :: 3.7", 90 "Programming Language :: Python :: 3.8", 91 "Programming Language :: Python :: 3.9", 92 ], 93 package_data={"libpysal": list(example_data_files)}, 94 install_requires=install_reqs, 95 extras_require=extras_reqs, 96 cmdclass={"build_py": build_py}, 97 python_requires=">=3.7", 98 ) 99 100 101if __name__ == "__main__": 102 setup_package() 103