-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup of env variable treatment on all platforms
- Loading branch information
Showing
4 changed files
with
159 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1 @@ | ||
#import pypes | ||
#import vtkvmtk | ||
#import vmtkscripts | ||
import sys | ||
import os | ||
|
||
if sys.platform == "win32": | ||
|
||
ldEnvironmentVariable = "PATH" | ||
currentEnviron = dict() | ||
currentEnviron[ldEnvironmentVariable] = "" | ||
currentEnviron["PYTHONPATH"] = "" | ||
|
||
if os.environ.has_key(ldEnvironmentVariable): | ||
currentEnviron[ldEnvironmentVariable] = os.environ[ldEnvironmentVariable] | ||
|
||
if os.environ.has_key("PYTHONPATH"): | ||
currentEnviron["PYTHONPATH"] = os.environ["PYTHONPATH"] | ||
|
||
newEnviron = {} | ||
vmtkhome = os.path.dirname(os.path.abspath(__file__)) | ||
vtkdir = (os.path.join(vmtkhome,"lib")) | ||
newEnviron[ldEnvironmentVariable] = os.path.join(vmtkhome,"bin") + os.path.pathsep + \ | ||
os.path.join(vtkdir) + os.path.pathsep + \ | ||
os.path.join(vmtkhome) + os.path.pathsep + \ | ||
os.path.join(vmtkhome,"vtk") | ||
os.environ[ldEnvironmentVariable] = newEnviron[ldEnvironmentVariable] + os.path.pathsep + currentEnviron[ldEnvironmentVariable] | ||
sys.path.append(os.path.join(vmtkhome,"bin")) | ||
sys.path.append(os.path.join(vtkdir)) | ||
sys.path.append(os.path.join(vmtkhome)) | ||
sys.path.append(os.path.join(vmtkhome,"vtk")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,137 +1,104 @@ | ||
import sys | ||
import os | ||
import glob | ||
import shutil | ||
import urllib | ||
import zipfile | ||
from setuptools import setup, find_packages | ||
from setuptools.command.install import install as _install | ||
from setuptools.command.build_py import build_py as _build | ||
|
||
VMTKPATH = "../../../vmtk-build/Install" | ||
|
||
CLASSIFIERS = ["Development Status :: 5 - Production/Stable", | ||
"Environment :: Console", | ||
"Intended Audience :: Science/Research", | ||
"License :: OSI Approved :: BSD License", | ||
"Operating System :: MacOS", | ||
"Operating System :: POSIX :: Linux", | ||
"Operating System :: Microsoft :: Windows :: Windows 7", | ||
"Programming Language :: C++", | ||
"Programming Language :: Python :: 2 :: Only", | ||
"Topic :: Scientific/Engineering"] | ||
|
||
# Description | ||
description = "vmtk - The Vascular Modeling Toolkit" | ||
fid = file('README', 'r') | ||
long_description = fid.read() | ||
fid.close() | ||
idx = max(0, long_description.find("vmtk - The Vascular Modeling Toolkit")) | ||
long_description = long_description[idx:] | ||
|
||
NAME = 'vmtk' | ||
MAINTAINER = "Simone Manini" | ||
MAINTAINER_EMAIL = "[email protected]" | ||
DESCRIPTION = description | ||
LONG_DESCRIPTION = long_description | ||
URL = "https://github.com/vmtk/vmtk" | ||
DOWNLOAD_URL = "http://pypi.python.org/pypi/vmtk" | ||
LICENSE = "BSD" | ||
CLASSIFIERS = CLASSIFIERS | ||
AUTHOR = "Luca Antiga" | ||
AUTHOR_EMAIL = "[email protected]" | ||
PLATFORMS = "Linux/MacOSX/Windows" | ||
ISRELEASED = True | ||
VERSION = '1.3' | ||
|
||
def list_files(directory): | ||
'''A specialized version of os.walk() that list files only in the current directory | ||
and ignores files whose start with a leading period and cmake files.''' | ||
for root, dirs, files in os.walk(directory): | ||
if root == directory: | ||
return [x for x in files if not (x.startswith('.')) and not (x.endswith('cmake'))] | ||
|
||
class vmtk_build(_build): | ||
'''Build vmtk libraries''' | ||
|
||
def run(self): | ||
#finding absolute path | ||
vmtk_path = os.path.abspath(VMTKPATH) | ||
|
||
#copying install directory | ||
try: | ||
shutil.copytree(os.path.join(vmtk_path,'lib','vmtk','vmtk'), 'vmtk') | ||
except OSError: | ||
shutil.rmtree('vmtk') | ||
shutil.copytree(os.path.join(vmtk_path,'lib','vmtk','vmtk'), 'vmtk') | ||
try: | ||
shutil.copytree(os.path.join(vmtk_path,'bin'), os.path.join('vmtk','bin'), ignore=shutil.ignore_patterns('Python')) | ||
except OSError: | ||
shutil.rmtree('bin') | ||
shutil.copytree(os.path.join(vmtk_path,'bin'), os.path.join('vmtk','bin'), ignore=shutil.ignore_patterns('Python')) | ||
|
||
try: | ||
shutil.copytree(os.path.join(vmtk_path,'bin','Python','vtk'), os.path.join('vmtk','vtk')) | ||
except OSError: | ||
shutil.rmtree('vtk') | ||
shutil.copytree(os.path.join(vmtk_path,'bin','Python','vtk'), os.path.join('vmtk','vtk')) | ||
|
||
shutil.copytree(os.path.join(vmtk_path,'lib'), os.path.join('vmtk','lib'), symlinks=True, ignore=shutil.ignore_patterns('cmake')) | ||
|
||
for file_to_move in list_files(os.path.join('vmtk','lib','vmtk')): | ||
shutil.copy(os.path.join('vmtk','lib','vmtk',file_to_move),os.path.join('vmtk','lib',file_to_move)) | ||
shutil.rmtree(os.path.join('vmtk','lib','vmtk')) | ||
|
||
for file_to_move in list_files(os.path.join('vmtk','lib','vtk-5.10')): | ||
shutil.copy(os.path.join('vmtk','lib','vtk-5.10',file_to_move),os.path.join('vmtk','lib',file_to_move)) | ||
shutil.rmtree(os.path.join('vmtk','lib','vtk-5.10')) | ||
|
||
for file_to_move in list_files(os.path.join('vmtk')): | ||
if file_to_move.endswith('.so') or file_to_move.endswith('.pyd'): | ||
shutil.move(os.path.join('vmtk',file_to_move),os.path.join('vmtk','lib',file_to_move)) | ||
|
||
for file_to_unlink in list_files(os.path.join('vmtk','lib')): | ||
if file_to_unlink == 'hints': | ||
os.remove(os.path.join('vmtk','lib',file_to_unlink)) | ||
if os.path.islink(os.path.join('vmtk','lib',file_to_unlink)): | ||
os.unlink(os.path.join('vmtk','lib',file_to_unlink)) | ||
|
||
if sys.platform == "win32": | ||
#copy favicon | ||
shutil.copy(os.path.join(os.getcwd(),'vmtk-icon.ico'),os.path.join('vmtk','bin','vmtk-icon.ico')) | ||
#copy c++ dll files | ||
if 'PROGRAMFILES(X86)' in os.environ: | ||
windows_architecture = 'x8664' | ||
dll_zip = urllib.urlretrieve('https://dl.dropboxusercontent.com/u/13662777/x8664.zip','x8664.zip') | ||
else: | ||
windows_architecture = 'i386' | ||
dll_zip = urllib.urlretrieve('https://dl.dropboxusercontent.com/u/13662777/i386.zip','i386.zip') | ||
fh = open(dll_zip[0],'rb') | ||
z = zipfile.ZipFile(fh) | ||
z.extractall(os.path.join('vmtk','bin')) | ||
fh.close() | ||
os.remove(dll_zip[0]) | ||
|
||
|
||
setup(name=NAME, | ||
maintainer=MAINTAINER, | ||
maintainer_email=MAINTAINER_EMAIL, | ||
description=DESCRIPTION, | ||
long_description=LONG_DESCRIPTION, | ||
url=URL, | ||
download_url=DOWNLOAD_URL, | ||
license=LICENSE, | ||
classifiers=CLASSIFIERS, | ||
author=AUTHOR, | ||
author_email=AUTHOR_EMAIL, | ||
platforms=PLATFORMS, | ||
version=VERSION, | ||
cmdclass={'vmtk_build':vmtk_build}, | ||
packages = find_packages(), | ||
zip_safe=False, | ||
package_data = { | ||
'vmtk': ["lib/*.so*","lib/*.*lib*","lib/*.pyd*","bin/*"], | ||
'vtk': ["lib/*.so*","lib/*.pyd*"], | ||
}, | ||
scripts = ['vmtk_post_install.py'] | ||
) | ||
import sys | ||
import os | ||
import glob | ||
import shutil | ||
import urllib | ||
import zipfile | ||
from setuptools import setup, find_packages | ||
from setuptools.command.install import install as _install | ||
from setuptools.command.build_py import build_py as _build | ||
|
||
VMTKPATH = "../../../vmtk-build/Install" | ||
|
||
CLASSIFIERS = ["Development Status :: 5 - Production/Stable", | ||
"Environment :: Console", | ||
"Intended Audience :: Science/Research", | ||
"License :: OSI Approved :: BSD License", | ||
"Operating System :: MacOS", | ||
"Operating System :: POSIX :: Linux", | ||
"Operating System :: Microsoft :: Windows :: Windows 7", | ||
"Programming Language :: C++", | ||
"Programming Language :: Python :: 2 :: Only", | ||
"Topic :: Scientific/Engineering"] | ||
|
||
# Description | ||
description = "vmtk - The Vascular Modeling Toolkit" | ||
fid = file('README', 'r') | ||
long_description = fid.read() | ||
fid.close() | ||
idx = max(0, long_description.find("vmtk - The Vascular Modeling Toolkit")) | ||
long_description = long_description[idx:] | ||
|
||
NAME = 'vmtk' | ||
MAINTAINER = "Simone Manini" | ||
MAINTAINER_EMAIL = "[email protected]" | ||
DESCRIPTION = description | ||
LONG_DESCRIPTION = long_description | ||
URL = "https://github.com/vmtk/vmtk" | ||
DOWNLOAD_URL = "http://pypi.python.org/pypi/vmtk" | ||
LICENSE = "BSD" | ||
CLASSIFIERS = CLASSIFIERS | ||
AUTHOR = "Luca Antiga" | ||
AUTHOR_EMAIL = "[email protected]" | ||
PLATFORMS = "Linux/MacOSX/Windows" | ||
ISRELEASED = True | ||
VERSION = '1.3' | ||
|
||
def list_files(directory): | ||
'''A specialized version of os.walk() that list files only in the current directory | ||
and ignores files whose start with a leading period and cmake files.''' | ||
for root, dirs, files in os.walk(directory): | ||
if root == directory: | ||
return [x for x in files if not (x.startswith('.')) and not (x.endswith('cmake'))] | ||
|
||
class vmtk_build(_build): | ||
'''Build vmtk libraries''' | ||
|
||
def run(self): | ||
#finding absolute path | ||
vmtk_path = os.path.abspath(VMTKPATH) | ||
|
||
shutil.copytree(os.path.join(vmtk_path,'lib','python2.7','site-packages','vmtk'), 'vmtk') | ||
shutil.copytree(os.path.join(vmtk_path,'lib','python2.7','site-packages','vtk'), os.path.join('vmtk','vtk')) | ||
shutil.copytree(os.path.join(vmtk_path,'lib'), os.path.join('vmtk','lib'), symlinks=True, ignore=shutil.ignore_patterns('cmake','python2.7')) | ||
shutil.copytree(os.path.join(vmtk_path,'bin'), os.path.join('vmtk','bin')) | ||
|
||
if sys.platform == "win32": | ||
#copy favicon | ||
shutil.copy(os.path.join(os.getcwd(),'vmtk-icon.ico'),os.path.join('vmtk','bin','vmtk-icon.ico')) | ||
#copy c++ dll files | ||
if 'PROGRAMFILES(X86)' in os.environ: | ||
windows_architecture = 'x8664' | ||
dll_zip = urllib.urlretrieve('https://s3.amazonaws.com/vmtk-installers/1.3/x8664.zip','x8664.zip') | ||
else: | ||
windows_architecture = 'i386' | ||
dll_zip = urllib.urlretrieve('https://s3.amazonaws.com/vmtk-installers/1.3/i386.zip','i386.zip') | ||
fh = open(dll_zip[0],'rb') | ||
z = zipfile.ZipFile(fh) | ||
z.extractall(os.path.join('vmtk','bin')) | ||
fh.close() | ||
os.remove(dll_zip[0]) | ||
|
||
|
||
setup(name=NAME, | ||
maintainer=MAINTAINER, | ||
maintainer_email=MAINTAINER_EMAIL, | ||
description=DESCRIPTION, | ||
long_description=LONG_DESCRIPTION, | ||
url=URL, | ||
download_url=DOWNLOAD_URL, | ||
license=LICENSE, | ||
classifiers=CLASSIFIERS, | ||
author=AUTHOR, | ||
author_email=AUTHOR_EMAIL, | ||
platforms=PLATFORMS, | ||
version=VERSION, | ||
cmdclass={'vmtk_build':vmtk_build}, | ||
packages = find_packages(), | ||
zip_safe=False, | ||
package_data = { | ||
'vmtk': ["lib/*.so*","lib/*.*lib*","lib/*.pyd*","bin/*","*.pyd","*.so","vtk/*.pyd","vtk/*.so"], | ||
'vtk': ["lib/*.so*","lib/*.pyd*","*.pyd","*.so"], | ||
}, | ||
scripts = ['vmtk_post_install.py'] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,28 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
import os | ||
import shutil | ||
home = os.path.expanduser("~") | ||
|
||
VERSION = "1.3" | ||
|
||
if __name__ == '__main__': | ||
|
||
if sys.platform == "win32": | ||
try: | ||
import pkg_resources | ||
package_path = pkg_resources.get_distribution("vmtk").location | ||
except: | ||
package_path = [f for f in sys.path if 'Python27\\lib\\site-packages' in f][0] | ||
vmtk_exe_path = os.path.join(package_path,"vmtk","bin","vmtk-exe.py") | ||
DESKTOP_FOLDER = get_special_folder_path("CSIDL_DESKTOPDIRECTORY") | ||
target = vmtk_exe_path | ||
description = "vmtk-launcher" | ||
filename = "vmtk-%s.lnk" % VERSION | ||
iconpath = os.path.join(package_path,"vmtk","bin","vmtk-icon.ico") | ||
create_shortcut(target,description,filename,'','',iconpath) | ||
#move shortcut to Desktop | ||
shutil.move(os.path.join(os.getcwd(),filename),os.path.join(DESKTOP_FOLDER,filename)) | ||
file_created(os.path.join(DESKTOP_FOLDER,filename)) | ||
else: | ||
import pkg_resources | ||
package_name = 'vmtk-'+VERSION+'-py2.7.egg-info' | ||
package_path = pkg_resources.get_distribution("vmtk").location | ||
print "Please run this script with sudo\n" | ||
bin_path = os.path.join(package_path,'vmtk','bin') | ||
print "chmod+x on binary scripts...%s"% bin_path | ||
os.system('chmod -R +x '+bin_path) | ||
vmtkHomeEnvironmentVariable="VMTKHOME=%s" % package_path | ||
vmtkPathEnvironmentVariable="export PATH=$VMTKHOME/vmtk/bin:$PATH" | ||
vmtkPythonPath="export PYTHONPATH=$VMTKHOME/vmtk/lib:$VMTKHOME/vmtk:$PYTHONPATH" | ||
if sys.platform == 'darwin': | ||
append_decision = raw_input('Do you want to append vmtk environment variables in your .bash_profile? yes/no: ') | ||
elif sys.platform == 'linux2': | ||
append_decision = raw_input('Do you want to append vmtk environment variables in your .bashrc? yes/no: ') | ||
else: | ||
sys.exit("Unknown platform.") | ||
while True: | ||
if append_decision.lower() == 'y' or append_decision.lower() == 'yes': | ||
if sys.platform == 'darwin': | ||
ldEnvironmentVariable="export DYLD_LIBRARY_PATH=$VMTKHOME/vmtk/lib:$DYLD_LIBRARY_PATH" | ||
with open(home+'/.bash_profile','aw') as bash_profile: | ||
bash_profile.write('\n#VMTK\n') | ||
bash_profile.write(vmtkHomeEnvironmentVariable+'\n') | ||
bash_profile.write(vmtkPathEnvironmentVariable+'\n') | ||
bash_profile.write(ldEnvironmentVariable+'\n') | ||
bash_profile.write(vmtkPythonPath+'\n') | ||
elif sys.platform == 'linux2': | ||
ldEnvironmentVariable="export LD_LIBRARY_PATH=$VMTKHOME/vmtk/lib:$LD_LIBRARY_PATH" | ||
with open(home+'/.bashrc','aw') as bashrc: | ||
bashrc.write('\n#VMTK\n') | ||
bashrc.write(vmtkHomeEnvironmentVariable+'\n') | ||
bashrc.write(vmtkPathEnvironmentVariable+'\n') | ||
bashrc.write(ldEnvironmentVariable+'\n') | ||
bashrc.write(vmtkPythonPath+'\n') | ||
else: | ||
sys.exit("Unknown platform.") | ||
break | ||
elif append_decision.lower() == 'n' or append_decision.lower() == 'no': | ||
break | ||
else: | ||
if sys.platform == 'darwin': | ||
append_decision = raw_input('Do you want to append vmtk environment variables in your .bash_profile? yes/no: ') | ||
elif sys.platform == 'linux2': | ||
append_decision = raw_input('Do you want to append vmtk environment variables in your .bashrc? yes/no: ') | ||
else: | ||
sys.exit("Unknown platform.") | ||
#!${PYTHON_SHEBANG} | ||
|
||
import sys | ||
import os | ||
import shutil | ||
home = os.path.expanduser("~") | ||
|
||
VERSION = "1.3" | ||
|
||
if __name__ == '__main__': | ||
|
||
if sys.platform == "win32": | ||
try: | ||
import pkg_resources | ||
package_path = pkg_resources.get_distribution("vmtk").location | ||
except: | ||
package_path = [f for f in sys.path if 'Python27\\lib\\site-packages' in f][0] | ||
vmtk_exe_path = os.path.join(package_path,"vmtk","bin","vmtk-exe.py") | ||
DESKTOP_FOLDER = get_special_folder_path("CSIDL_DESKTOPDIRECTORY") | ||
target = vmtk_exe_path | ||
description = "vmtk-launcher" | ||
filename = "vmtk-%s.lnk" % VERSION | ||
iconpath = os.path.join(package_path,"vmtk","bin","vmtk-icon.ico") | ||
create_shortcut(target,description,filename,'','',iconpath) | ||
#move shortcut to Desktop | ||
shutil.move(os.path.join(os.getcwd(),filename),os.path.join(DESKTOP_FOLDER,filename)) | ||
file_created(os.path.join(DESKTOP_FOLDER,filename)) | ||
|
Oops, something went wrong.