/ setup.py
setup.py
1 # coding=utf-8 2 import os 3 import sys 4 import setuptools 5 import versioneer 6 7 # Versioneer config 8 versioneer.VCS = 'git' 9 versioneer.versionfile_source = 'octoprint_GPX/_version.py' 10 versioneer.versionfile_build = 'octoprint_GPX/_version.py' 11 versioneer.tag_prefix = '' 12 versioneer.parentdir_prefix = '' 13 14 ######################################################################################################################## 15 16 plugin_identifier = "GPX" 17 plugin_package = "octoprint_%s" % plugin_identifier 18 plugin_name = "OctoPrint-GPX" 19 plugin_version = versioneer.get_version() 20 plugin_description = "Emulates the gcode printer protocol by translating to/from x3g." 21 plugin_author = "Mark Walker" 22 plugin_author_email = "markwal@hotmail.com" 23 plugin_url = "http://github.com/markwal/OctoPrint-GPX" 24 plugin_license = "AGPLv3" 25 26 plugin_additional_data = [] 27 28 plugin_ext_sources = [ 29 'GPX/src/pymodule/gpxmodule.c', 30 'GPX/src/shared/machine_config.c', 31 'GPX/src/shared/opt.c', 32 'GPX/src/gpx/vector.c', 33 'GPX/src/gpx/gpx.c', 34 'GPX/src/gpx/gpx-main.c', 35 'GPX/src/gpx/gpxresp.c', 36 ] 37 38 if sys.platform == 'win32': 39 plugin_ext_sources.append('GPX/src/gpx/winsio.c') 40 41 42 ######################################################################################################################## 43 44 def package_data_dirs(source, sub_folders): 45 import os 46 dirs = [] 47 48 for d in sub_folders: 49 folder = os.path.join(source, d) 50 if not os.path.exists(folder): 51 continue 52 53 for dirname, _, files in os.walk(folder): 54 dirname = os.path.relpath(dirname, source) 55 for f in files: 56 dirs.append(os.path.join(dirname, f)) 57 58 return dirs 59 60 def requirements(filename): 61 return filter(lambda line: line and not line.startswith("#"), map(lambda line: line.strip(), open(filename).read().split("\n"))) 62 63 def params(): 64 # Our metadata, as defined above 65 name = plugin_name 66 version = plugin_version 67 cmdclass = versioneer.get_cmdclass() 68 description = plugin_description 69 author = plugin_author 70 author_email = plugin_author_email 71 url = plugin_url 72 license = plugin_license 73 74 # we only have our plugin package to install 75 packages = [plugin_package] 76 77 # we might have additional data files in sub folders that need to be installed too 78 package_data = {plugin_package: package_data_dirs(plugin_package, ['static', 'templates', 'translations'] + plugin_additional_data)} 79 include_package_data = True 80 81 # If you have any package data that needs to be accessible on the file system, such as templates or static assets 82 # this plugin is not zip_safe. 83 zip_safe = False 84 85 # Read the requirements from our requirements.txt file 86 install_requires = requirements("requirements.txt") 87 88 # Hook the plugin into the "octoprint.plugin" entry point, mapping the plugin_identifier to the plugin_package. 89 # That way OctoPrint will be able to find the plugin and load it. 90 entry_points = { 91 "octoprint.plugin": ["%s = %s" % (plugin_identifier, plugin_package)] 92 } 93 94 ext_modules = [ 95 setuptools.Extension('gpx', 96 sources = plugin_ext_sources, 97 extra_compile_args = ['-DGPX_VERSION="\\"OctoPrint\\""', '-DSERIAL_SUPPORT', '-fvisibility=hidden', '-IGPX/build/src/shared', '-IGPX/src/shared', '-IGPX/src/gpx'], 98 extra_link_args = ['-fvisibility=hidden']) 99 ] 100 101 return locals() 102 103 os.environ['LANG'] = 'C' 104 setuptools.setup(**params())