-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup.py
138 lines (116 loc) · 4.8 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
'''
To create the wheel run - python setup.py bdist_wheel
'''
from setuptools import setup
import os, sys
packages = []
root_dir = os.path.dirname(__file__)
if root_dir:
os.chdir(root_dir)
for dirpath, dirnames, filenames in os.walk('lcopt'):
# Ignore dirnames that start with '.'
if '__init__.py' in filenames:
pkg = dirpath.replace(os.path.sep, '.')
if os.path.altsep:
pkg = pkg.replace(os.path.altsep, '.')
packages.append(pkg)
def package_files(directory):
paths = []
for (path, directories, filenames) in os.walk(directory):
for filename in filenames:
paths.append(os.path.join('..', path, filename))
return paths
my_package_files = []
my_package_files.extend(package_files(os.path.join('lcopt', 'assets')))
my_package_files.extend(package_files(os.path.join('lcopt', 'static')))
my_package_files.extend(package_files(os.path.join('lcopt', 'templates')))
my_package_files.extend(package_files(os.path.join('lcopt', 'bin')))
def create_win_shortcuts():
try:
import winreg, sysconfig
from win32com.client import Dispatch
except:
return 1
def get_reg(name,path):
# Read variable from Windows Registry
# From https://stackoverflow.com/a/35286642
try:
registry_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0,
winreg.KEY_READ)
value, regtype = winreg.QueryValueEx(registry_key, name)
winreg.CloseKey(registry_key)
return value
except WindowsError:
return None
def create_shortcut(where, script_name, icon=None):
scriptsDir = sysconfig.get_path('scripts')
target = os.path.join(scriptsDir, script_name + '.exe')
link_name = script_name + '.lnk'
link = os.path.join(where, link_name)
if icon is None:
icon = target
if not os.path.isdir(where):
os.mkdir(where)
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(link)
shortcut.Targetpath = target
shortcut.WorkingDirectory = scriptsDir
shortcut.IconLocation = icon
shortcut.save()
regPath = r'Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders'
desktopFolder = os.path.expandvars(os.path.normpath(get_reg('Desktop',regPath)))
startmenuFolder = os.path.expandvars(os.path.normpath(get_reg('Start Menu',regPath)))
startmenuFolder = os.path.join(startmenuFolder, 'Programs', 'Lcopt')
icon = os.path.join(root_dir, 'lcopt', 'assets', 'lcopt_icon.ico')
#target = "lcopt-launcher"
#create_shortcut(desktopFolder, target, icon)
create_shortcut(startmenuFolder, "lcopt-launcher", icon)
create_shortcut(startmenuFolder, "lcopt-settings", icon)
return 0
setup(
name='lcopt-dev',
version="0.4.3_dev",
packages=packages,
author="P. James Joyce",
author_email="[email protected]",
license=open('LICENSE.txt').read(),
package_data={'lcopt': my_package_files},
entry_points = {
'console_scripts': [
'lcopt-launcher = lcopt.bin.lcopt_launcher:main',
'lcopt-bw2-setup = lcopt.bin.lcopt_bw2_setup:main',
'lcopt-bw2-setup-forwast = lcopt.bin.lcopt_bw2_setup_forwast:main',
'lcopt-settings = lcopt.bin.lcopt_settings:main',
]
},
#install_requires=[
#],
include_package_data=True,
url="https://github.com/pjamesjoyce/lcopt/",
download_url="https://github.com/pjamesjoyce/lcopt/archive/0.4.3.tar.gz",
long_description=open('README.md').read(),
description='An interactive tool for creating fully parameterised Life Cycle Assessment (LCA) foreground models',
keywords=['LCA', 'Life Cycle Assessment', 'Foreground system', 'Background system', 'Foreground model', 'Fully parameterised'],
classifiers=[
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Scientific/Engineering :: Information Analysis',
'Topic :: Scientific/Engineering :: Mathematics',
'Topic :: Scientific/Engineering :: Visualization',
],
)
if sys.platform == 'win32':
shortcuts = create_win_shortcuts()
if shortcuts != 0:
print("Couldn't create shortcuts")
# Also consider:
# http://code.activestate.com/recipes/577025-loggingwebmonitor-a-central-logging-server-and-mon/