diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e13e2dd --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +build/ +dist/ +venv/ + +gamera/toolkits/skeleton/plugins/*.cpp +*.egg-info + +# IDEs +.idea/ \ No newline at end of file diff --git a/INSTALL b/INSTALL index 8d644aa..89c6b85 100644 --- a/INSTALL +++ b/INSTALL @@ -25,11 +25,10 @@ In addition, your Linux installation should also have: Standard Build and Install -------------------------- -Gamera toolkits are built using the Python-standard Distutils system. Open a -terminal and type:: +Gamera toolkits are can be installed, throw pip. Open a +terminal in the folder and type:: - python setup.py build - sudo python setup.py install + pip install . Mac OS-X ======== diff --git a/README b/README index 8035cad..a526a66 100644 --- a/README +++ b/README @@ -27,11 +27,11 @@ Python package. Creating a toolkit ------------------ -The directory heirarchy +The directory hierarchy ``````````````````````` Toolkits require a number of different files in a directory -heirarchy. Here we assume the toolkit is called ``my_toolkit``. +hierarchy. Here we assume the toolkit is called ``my_toolkit``. +----------+----------------------------------------------------------------+ | ./ | Basic information files for building the toolkit | diff --git a/build/scripts-3.7/skeleton b/build/scripts-3.7/skeleton deleted file mode 100755 index a44eaf1..0000000 --- a/build/scripts-3.7/skeleton +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/local/bin/python3.7 - -# This just simply runs the skeleton toolkits main function - -from gamera.toolkits.skeleton import main - -main.main() diff --git a/rename.py b/rename.py index c9837d2..e2c43a5 100755 --- a/rename.py +++ b/rename.py @@ -1,12 +1,21 @@ #!/usr/bin/env python -from os import rename +from os import rename, walk from os.path import * from sys import argv +ignoreFiles = ["rename.py", "turtle.jpg", "__pycache__"] + + +def change_content(dirname, names): + # ignore some dirs + if basename(dirname) in ignoreFiles: + return -def change_content(change_to, dirname, names): for name in names: + # ignore some files + if name in ignoreFiles: + continue full_path = join(dirname, name) if isfile(full_path): print("Adjusting content in %s" % full_path) @@ -16,16 +25,33 @@ def change_content(change_to, dirname, names): content = content.replace(change_from, change_to) open(full_path, "w").write(content) elif isdir(full_path): - walk(full_path, change_content, change_to) + for baseDir, dirName, fileNames in walk(full_path): + change_content(baseDir, fileNames) + + +def rename_files(dirname, names): + # ignore some dirs + if basename(dirname) in ignoreFiles: + return + # rename dir + if basename(dirname).__eq__(change_from): + newdirname = dirname.replace(change_from, change_to) + rename(dirname, newdirname) + for baseDir, dirName, fileNames in walk(newdirname): + rename_files(baseDir, fileNames) + return -def rename_files(change_to, dirname, names): for name in names: + # ignore some files + if name in ignoreFiles: + continue full_path = join(dirname, name) if isdir(full_path): - walk(full_path, rename_files, change_to) + for baseDir, dirName, fileNames in walk(full_path): + rename_files(baseDir, fileNames) if name.find(change_from) != -1: - new_name = name.replace(change_from, change_to) + new_name = name.replace(change_from) print("Renaming %s to %s" % (full_path, join(dirname, new_name))) rename(full_path, join(dirname, new_name)) @@ -33,5 +59,7 @@ def rename_files(change_to, dirname, names): change_from = 'skeleton' change_to = argv[-1].lower() print("Changing name of toolkit project to '%s'." % change_to) -walk(".", change_content, change_to) -walk(".", rename_files, change_to) +for directory, dirnames, filenames in walk("."): + change_content(directory, filenames) +for directory, dirnames, filenames in walk("."): + rename_files(directory, filenames) diff --git a/setup.py b/setup.py index f64756c..874034c 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ -#!/usr/bin/env python +from pathlib import Path -from distutils.core import setup +from setuptools import setup from gamera import gamera_setup @@ -20,12 +20,15 @@ plugins = gamera_setup.get_plugin_filenames(PLUGIN_PATH) plugin_extensions = gamera_setup.generate_plugins(plugins, PLUGIN_PACKAGE) -# This is a standard distutils setup initializer. If you need to do -# anything more complex here, refer to the Python distutils documentation. -setup(name=TOOLKIT_NAME, - version="3.0.1", - ext_modules=plugin_extensions, - packages=[PACKAGE, PLUGIN_PACKAGE], - scripts=['scripts/skeleton'], - requires=['gamera'] - ) +# This is a standard setuptools setup initializer. If you need to do +# anything more complex here, refer to the Python setuptools documentation. +if __name__ == "__main__": + setup(name=TOOLKIT_NAME, + version="4.1.0", + ext_modules=plugin_extensions, + packages=[PACKAGE, PLUGIN_PACKAGE], + include_dirs=['include/plugins'], + python_requires='>=3.5', + scripts=['scripts/skeleton'], + install_requires=['gamera>=4.1.0'] + )