|
| 1 | +from setuptools import setup, find_packages, Distribution |
| 2 | +from setuptools.command import build_py |
| 3 | +import distutils.cmd |
| 4 | +from codecs import open |
| 5 | +import os |
| 6 | +from os import path |
| 7 | +import textwrap |
| 8 | +import sys |
| 9 | +import shutil |
| 10 | +import subprocess |
| 11 | + |
| 12 | +wip_version = "0.1.0" |
| 13 | + |
| 14 | +def get_platform(): |
| 15 | + |
| 16 | + platforms = { |
| 17 | + 'linux' : 'Linux', |
| 18 | + 'linux1' : 'Linux', |
| 19 | + 'linux2' : 'Linux', |
| 20 | + 'darwin' : 'OS X', |
| 21 | + 'win32' : 'Windows' |
| 22 | + } |
| 23 | + if sys.platform not in platforms: |
| 24 | + return sys.platform |
| 25 | + |
| 26 | + return platforms[sys.platform] |
| 27 | + |
| 28 | +class BinaryDistribution(Distribution): |
| 29 | + def has_ext_modules(var): |
| 30 | + return True |
| 31 | + |
| 32 | +class DPGBuildCommand(distutils.cmd.Command): |
| 33 | + |
| 34 | + description = 'DPG Build Command' |
| 35 | + user_options = [] |
| 36 | + |
| 37 | + def initialize_options(self): |
| 38 | + pass |
| 39 | + |
| 40 | + def finalize_options(self): |
| 41 | + pass |
| 42 | + |
| 43 | + def run(self): |
| 44 | + pass |
| 45 | + |
| 46 | +class BuildPyCommand(build_py.build_py): |
| 47 | + def run(self): |
| 48 | + self.run_command('dpg_build') |
| 49 | + build_py.build_py.run(self) |
| 50 | + |
| 51 | +def setup_package(): |
| 52 | + |
| 53 | + src_path = os.path.dirname(os.path.abspath(__file__)) |
| 54 | + old_path = os.getcwd() |
| 55 | + os.chdir(src_path) |
| 56 | + sys.path.insert(0, src_path) |
| 57 | + |
| 58 | + metadata = dict( |
| 59 | + name='pilotlight', # Required |
| 60 | + version=wip_version, # Required |
| 61 | + author="Jonathan Hoffstadt", # Optional |
| 62 | + author_email="jonathanhoffstadt@yahoo.com", # Optional |
| 63 | + description='Pilot Light', # Required |
| 64 | + # long_description=long_description, # Optional |
| 65 | + # long_description_content_type='text/markdown', # Optional |
| 66 | + # url='https://github.com/PilotLightTech/pilotlight-python', # Optional |
| 67 | + license = 'MIT', |
| 68 | + python_requires='>=3.14', |
| 69 | + classifiers=[ |
| 70 | + 'Development Status :: 5 - Production/Stable', |
| 71 | + 'Intended Audience :: Education', |
| 72 | + 'Intended Audience :: Developers', |
| 73 | + 'Intended Audience :: Science/Research', |
| 74 | + 'License :: OSI Approved :: MIT License', |
| 75 | + 'Operating System :: Microsoft :: Windows :: Windows 10', |
| 76 | + 'Programming Language :: Python :: 3.14', |
| 77 | + 'Programming Language :: Python :: Implementation :: CPython', |
| 78 | + 'Programming Language :: Python :: 3 :: Only', |
| 79 | + 'Topic :: Software Development :: User Interfaces', |
| 80 | + 'Topic :: Software Development :: Libraries :: Python Modules', |
| 81 | + ], |
| 82 | + packages=['pilotlight'], |
| 83 | + package_dir = {'': 'out'}, |
| 84 | + package_data={}, |
| 85 | + distclass=BinaryDistribution, |
| 86 | + cmdclass={ |
| 87 | + 'dpg_build': DPGBuildCommand, |
| 88 | + 'build_py': BuildPyCommand, |
| 89 | + }, |
| 90 | + ) |
| 91 | + |
| 92 | + if get_platform() == "Windows": |
| 93 | + metadata['package_data']['pilotlight'] = ["__init__.py", "pilotlight.pyd", "pilotlight.pyi", "pl_core.py", "pl_draw_ext.py", "pl_starter_ext.py", "pl_ui_ext.py", "pl_vfs_ext.py", "spirv-cross-c-shared.dll"] |
| 94 | + |
| 95 | + if "--force" in sys.argv: |
| 96 | + sys.argv.remove('--force') |
| 97 | + |
| 98 | + try: |
| 99 | + setup(**metadata) |
| 100 | + finally: |
| 101 | + del sys.path[0] |
| 102 | + os.chdir(old_path) |
| 103 | + return |
| 104 | + |
| 105 | +if __name__ == '__main__': |
| 106 | + setup_package() |
| 107 | + |
0 commit comments