#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
$Id$

Copyright 2010 Lars Kruse <devel@sumpfralle.de>
Copyright 2010 Arthur Magill

This file is part of pyMKcam.

pyMKcam 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 3 of the License, or
(at your option) any later version.

pyMKcam 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 pyMKcam.  If not, see <http://www.gnu.org/licenses/>.
"""

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

import distutils.sysconfig
import glob
import os.path
import sys
import shutil

BASE_DIR = os.path.realpath(os.path.abspath(os.path.dirname(__file__)))

from pymkcam import VERSION

WINDOWS_START_SCRIPT = os.path.join("scripts", "pymkcam-loader.py")
DEFAULT_START_SCRIPT = os.path.join("scripts", "pymkcam")

# we don't want to include the windows postinstall script in other installers
is_windows_installer = "bdist_wininst" in sys.argv or "bdist_msi" in sys.argv

if is_windows_installer:
    shutil.copy2(os.path.join(BASE_DIR, DEFAULT_START_SCRIPT),
            os.path.join(BASE_DIR, WINDOWS_START_SCRIPT))
    PLATFORM_SCRIPTS = [WINDOWS_START_SCRIPT,
            os.path.join("scripts", "pymkcam_win32_postinstall.py")]
else:
    PLATFORM_SCRIPTS = [DEFAULT_START_SCRIPT]


setup(
    name="pymkcam",
    version=VERSION,
    license="GPL v3",
    description="Open Source CAM - Toolpath Generation for 3-Axis CNC machining based on MK4duo firmware",
    author="Franco (nextime) Lanza",
    author_email="franco@nexlab.net",
    provides=["pymkcam"],
    requires=["ode", "gtk", "gtk.gtkgl", "OpenGL"],
    url="https://git.nexlab.net/machinery/pyMKcam",
    download_url="https://git.nexlab.net/machinery/pyMKcam",
    keywords=["3-axis", "cnc", "cam", "toolpath", "machining", "g-code"],
    long_description="""Python CAM for MK4duo based controllers
    Toolpath Generation for 3-Axis CNC machining based on MK4duo controllers forked from the well known pymkcam

""",
    # full list of classifiers at:
    #   http://pypi.python.org/pypi?:action=list_classifiers
    classifiers=[
        "Programming Language :: Python",
        "Programming Language :: Python :: 2",
        "Development Status :: 4 - Beta",
        "License :: OSI Approved :: GNU General Public License (GPL)",
        "Topic :: Scientific/Engineering",
        "Environment :: Win32 (MS Windows)",
        "Environment :: X11 Applications :: GTK",
        "Intended Audience :: Manufacturing",
        "Operating System :: Microsoft :: Windows",
        "Operating System :: MacOS :: MacOS X",
        "Operating System :: POSIX",
    ],
    packages=[
        "pymkcam",
        "pymkcam.Cutters",
        "pymkcam.Exporters",
        "pymkcam.Geometry",
        "pymkcam.Gui",
        "pymkcam.Importers",
        "pymkcam.PathGenerators",
        "pymkcam.PathProcessors",
        "pymkcam.Physics",
        "pymkcam.Plugins",
        "pymkcam.Simulation",
        "pymkcam.Toolpath",
        "pymkcam.Utils",
    ],
    scripts = PLATFORM_SCRIPTS,
    data_files=[("share/pymkcam/doc", [
            "COPYING.TXT",
            "INSTALL.TXT",
            "LICENSE",
            "README.md",
            "Changelog",
            "release_info.txt"]),
        ("share/pymkcam/ui", glob.glob(os.path.join("share", "ui", "*"))),
        ("share/pymkcam/fonts", glob.glob(os.path.join("share", "fonts", "*"))),
        ("share/pymkcam", [os.path.join("share", "pymkcam.ico"), os.path.join("share", "misc", "DXF.gpl")]),
        ("share/pymkcam/samples", glob.glob(os.path.join("samples", "*"))),
    ],
)

if is_windows_installer:
    os.remove(os.path.join(BASE_DIR, WINDOWS_START_SCRIPT))

# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
