114 lines
3.4 KiB
Python
Executable File
114 lines
3.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU General Public License
|
|
# as published by the Free Software Foundation; either version 2
|
|
# of the License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
#
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
# setup.py adapted from blender_cloud addon
|
|
|
|
import glob
|
|
import sys
|
|
import zipfile
|
|
|
|
from distutils import log
|
|
from distutils.core import Command
|
|
from distutils.command.bdist import bdist
|
|
from distutils.command.install import install
|
|
from distutils.command.install_egg_info import install_egg_info
|
|
from setuptools import setup, find_packages
|
|
|
|
# sys.dont_write_bytecode = True
|
|
|
|
# noinspection PyAttributeOutsideInit
|
|
class BlenderAddonBdist(bdist):
|
|
"""Ensures that 'python setup.py bdist' creates a zip file."""
|
|
|
|
def initialize_options(self):
|
|
super().initialize_options()
|
|
self.formats = ['zip']
|
|
self.plat_name = 'addon' # use this instead of 'linux-x86_64' or similar.
|
|
|
|
def run(self):
|
|
self.run_command('wheels')
|
|
super().run()
|
|
|
|
|
|
# noinspection PyAttributeOutsideInit
|
|
class BlenderAddonFdist(BlenderAddonBdist):
|
|
"""Ensures that 'python setup.py fdist' creates a plain folder structure."""
|
|
|
|
user_options = [
|
|
('dest-path=', None, 'addon installation path'),
|
|
]
|
|
|
|
def initialize_options(self):
|
|
super().initialize_options()
|
|
self.dest_path = None # path that will contain the addon
|
|
|
|
def run(self):
|
|
super().run()
|
|
|
|
# dist_files is a list of tuples ('bdist', 'any', 'filepath')
|
|
filepath = self.distribution.dist_files[0][2]
|
|
|
|
# if dest_path is not specified use the filename as the dest_path (minus the .zip)
|
|
assert filepath.endswith('.zip')
|
|
target_folder = self.dest_path or filepath[:-4]
|
|
|
|
print('Unzipping the package on {}.'.format(target_folder))
|
|
|
|
with zipfile.ZipFile(filepath, 'r') as zip_ref:
|
|
zip_ref.extractall(target_folder)
|
|
|
|
|
|
# noinspection PyAttributeOutsideInit
|
|
class BlenderAddonInstall(install):
|
|
"""Ensures the module is placed at the root of the zip file."""
|
|
|
|
def initialize_options(self):
|
|
super().initialize_options()
|
|
self.prefix = ''
|
|
self.install_lib = ''
|
|
|
|
|
|
class AvoidEggInfo(install_egg_info):
|
|
"""Makes sure the egg-info directory is NOT created.
|
|
|
|
If we skip this, the user's addon directory will be polluted by egg-info
|
|
directories, which Blender doesn't use anyway.
|
|
"""
|
|
|
|
def run(self):
|
|
pass
|
|
|
|
|
|
setup(
|
|
cmdclass={'bdist': BlenderAddonBdist,
|
|
'fdist': BlenderAddonFdist,
|
|
'install': BlenderAddonInstall,
|
|
'install_egg_info': AvoidEggInfo},
|
|
name='bpkg',
|
|
description='Integrated package manager for Blender',
|
|
version='0.0.1',
|
|
author='Ellwood Zwovic',
|
|
author_email='gandalf3@blendermonkey.com',
|
|
packages=['bpkg'],
|
|
url='https://developer.blender.org/diffusion/BPMA/',
|
|
platforms='',
|
|
zip_safe=False,
|
|
)
|
|
|