2013-07-09 19:39:07 +00:00
|
|
|
# coding=utf-8
|
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
2014-06-21 22:41:03 +00:00
|
|
|
import versioneer
|
|
|
|
|
versioneer.VCS = 'git'
|
|
|
|
|
versioneer.versionfile_source = 'src/octoprint/_version.py'
|
|
|
|
|
versioneer.versionfile_build = 'octoprint/_version.py'
|
|
|
|
|
versioneer.tag_prefix = ''
|
2014-06-23 08:35:59 +00:00
|
|
|
versioneer.parentdir_prefix = ''
|
2014-06-21 22:41:03 +00:00
|
|
|
|
2014-06-23 11:09:54 +00:00
|
|
|
from setuptools import setup, find_packages, Command
|
2014-06-23 08:35:59 +00:00
|
|
|
import os
|
2014-06-23 11:09:54 +00:00
|
|
|
import shutil
|
|
|
|
|
import glob
|
|
|
|
|
|
2014-08-27 12:46:46 +00:00
|
|
|
from babel.messages import frontend as babel
|
|
|
|
|
import po2json
|
|
|
|
|
|
|
|
|
|
I18N_MAPPING_FILE = "babel.cfg"
|
|
|
|
|
I18N_DOMAIN = "messages"
|
|
|
|
|
I18N_INPUT_DIRS = "."
|
|
|
|
|
I18N_OUTPUT_DIR_PY = os.path.join("src", "octoprint", "translations")
|
|
|
|
|
I18N_OUTPUT_DIR_JS = os.path.join("src", "octoprint", "static", "js", "i18n")
|
|
|
|
|
I18N_POT_FILE = os.path.join(I18N_OUTPUT_DIR_PY, "messages.pot")
|
2014-06-23 08:35:59 +00:00
|
|
|
|
|
|
|
|
def package_data_dirs(source, sub_folders):
|
|
|
|
|
dirs = []
|
|
|
|
|
|
|
|
|
|
for d in sub_folders:
|
|
|
|
|
for dirname, _, files in os.walk(os.path.join(source, d)):
|
|
|
|
|
dirname = os.path.relpath(dirname, source)
|
|
|
|
|
for f in files:
|
|
|
|
|
dirs.append(os.path.join(dirname, f))
|
|
|
|
|
|
|
|
|
|
return dirs
|
2013-07-09 19:39:07 +00:00
|
|
|
|
2014-06-23 11:09:54 +00:00
|
|
|
|
|
|
|
|
class CleanCommand(Command):
|
|
|
|
|
description = "clean build artifacts"
|
|
|
|
|
user_options = []
|
|
|
|
|
boolean_options = []
|
|
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
if os.path.exists('build'):
|
|
|
|
|
print "Deleting build directory"
|
|
|
|
|
shutil.rmtree('build')
|
|
|
|
|
eggs = glob.glob('OctoPrint*.egg-info')
|
|
|
|
|
for egg in eggs:
|
|
|
|
|
print "Deleting %s directory" % egg
|
|
|
|
|
shutil.rmtree(egg)
|
|
|
|
|
|
|
|
|
|
|
2014-08-27 12:46:46 +00:00
|
|
|
class NewTranslation(Command):
|
|
|
|
|
description = "create a new translation"
|
|
|
|
|
user_options = [
|
|
|
|
|
('locale=', 'l', 'locale for the new translation'),
|
|
|
|
|
]
|
|
|
|
|
boolean_options = []
|
|
|
|
|
|
|
|
|
|
def __init__(self, dist, **kw):
|
|
|
|
|
self.babel_init_messages = babel.init_catalog(dist)
|
|
|
|
|
Command.__init__(self, dist, **kw)
|
|
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
|
self.locale = None
|
|
|
|
|
self.babel_init_messages.initialize_options()
|
|
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
|
self.babel_init_messages.locale = self.locale
|
|
|
|
|
self.babel_init_messages.input_file = I18N_POT_FILE
|
|
|
|
|
self.babel_init_messages.output_dir = I18N_OUTPUT_DIR_PY
|
|
|
|
|
self.babel_init_messages.finalize_options()
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
self.babel_init_messages.run()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RefreshTranslation(Command):
|
|
|
|
|
description = "refresh translations"
|
|
|
|
|
user_options = []
|
|
|
|
|
boolean_options = []
|
|
|
|
|
|
|
|
|
|
def __init__(self, dist, **kw):
|
|
|
|
|
self.babel_extract_messages = babel.extract_messages(dist)
|
|
|
|
|
self.babel_update_messages = babel.update_catalog(dist)
|
|
|
|
|
Command.__init__(self, dist, **kw)
|
|
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
|
self.babel_extract_messages.initialize_options()
|
|
|
|
|
self.babel_update_messages.initialize_options()
|
|
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
|
self.babel_extract_messages.mapping_file = I18N_MAPPING_FILE
|
|
|
|
|
self.babel_extract_messages.output_file = I18N_POT_FILE
|
|
|
|
|
self.babel_extract_messages.input_dirs = I18N_INPUT_DIRS
|
|
|
|
|
self.babel_extract_messages.msgid_bugs_address = "i18n@octoprint.org"
|
|
|
|
|
self.babel_extract_messages.copyright_holder = "The OctoPrint Project"
|
|
|
|
|
self.babel_extract_messages.finalize_options()
|
|
|
|
|
|
|
|
|
|
self.babel_update_messages.input_file = I18N_MAPPING_FILE
|
|
|
|
|
self.babel_update_messages.output_dir = I18N_OUTPUT_DIR_PY
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
self.babel_extract_messages.run()
|
|
|
|
|
self.babel_update_messages.run()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CompileTranslation(Command):
|
|
|
|
|
description = "compile translations"
|
|
|
|
|
user_options = []
|
|
|
|
|
boolean_options = []
|
|
|
|
|
|
|
|
|
|
def __init__(self, dist, **kw):
|
|
|
|
|
self.babel_compile_messages = babel.compile_catalog(dist)
|
|
|
|
|
Command.__init__(self, dist, **kw)
|
|
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
|
self.babel_compile_messages.initialize_options()
|
|
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
|
self.babel_compile_messages.directory = I18N_OUTPUT_DIR_PY
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
self.babel_compile_messages.run()
|
|
|
|
|
|
|
|
|
|
for lang_code in os.listdir(I18N_OUTPUT_DIR_PY):
|
|
|
|
|
full_path = os.path.join(I18N_OUTPUT_DIR_PY, lang_code)
|
|
|
|
|
|
|
|
|
|
if os.path.isdir(full_path):
|
|
|
|
|
client_po_dir = os.path.join(full_path, "LC_MESSAGES")
|
|
|
|
|
|
|
|
|
|
po2json.update_js_file(
|
|
|
|
|
"%s/%s.po" % (client_po_dir, I18N_DOMAIN),
|
|
|
|
|
lang_code,
|
|
|
|
|
I18N_OUTPUT_DIR_JS,
|
|
|
|
|
I18N_DOMAIN
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2014-06-23 11:09:54 +00:00
|
|
|
def get_cmdclass():
|
|
|
|
|
cmdclass = versioneer.get_cmdclass()
|
|
|
|
|
cmdclass.update({
|
2014-08-27 12:46:46 +00:00
|
|
|
'clean': CleanCommand,
|
|
|
|
|
'babel_new': NewTranslation,
|
|
|
|
|
'babel_refresh': RefreshTranslation,
|
|
|
|
|
'babel_compile': CompileTranslation
|
2014-06-23 11:09:54 +00:00
|
|
|
})
|
|
|
|
|
return cmdclass
|
|
|
|
|
|
|
|
|
|
|
2013-07-09 19:39:07 +00:00
|
|
|
def params():
|
|
|
|
|
name = "OctoPrint"
|
2014-06-23 08:35:59 +00:00
|
|
|
version = versioneer.get_version()
|
2014-06-23 11:09:54 +00:00
|
|
|
cmdclass = get_cmdclass()
|
2014-06-23 08:35:59 +00:00
|
|
|
|
2013-07-09 19:39:07 +00:00
|
|
|
description = "A responsive web interface for 3D printers"
|
|
|
|
|
long_description = open("README.md").read()
|
|
|
|
|
classifiers = [
|
|
|
|
|
"Development Status :: 4 - Beta",
|
|
|
|
|
"Environment :: Web Environment",
|
|
|
|
|
"Framework :: Flask",
|
|
|
|
|
"Intended Audience :: Education",
|
|
|
|
|
"Intended Audience :: End Users/Desktop",
|
|
|
|
|
"Intended Audience :: Manufacturing",
|
|
|
|
|
"Intended Audience :: Science/Research",
|
|
|
|
|
"License :: OSI Approved :: GNU Affero General Public License v3",
|
|
|
|
|
"Natural Language :: English",
|
|
|
|
|
"Operating System :: OS Independent",
|
|
|
|
|
"Programming Language :: Python :: 2.7",
|
|
|
|
|
"Programming Language :: JavaScript",
|
|
|
|
|
"Topic :: Internet :: WWW/HTTP",
|
|
|
|
|
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
|
|
|
|
|
"Topic :: Internet :: WWW/HTTP :: WSGI",
|
|
|
|
|
"Topic :: Printing",
|
|
|
|
|
"Topic :: System :: Networking :: Monitoring"
|
|
|
|
|
]
|
|
|
|
|
author = "Gina Häußge"
|
|
|
|
|
author_email = "osd@foosel.net"
|
|
|
|
|
url = "http://octoprint.org"
|
|
|
|
|
license = "AGPLv3"
|
|
|
|
|
|
2013-09-15 19:45:31 +00:00
|
|
|
packages = find_packages(where="src")
|
|
|
|
|
package_dir = {"octoprint": "src/octoprint"}
|
2014-06-23 08:35:59 +00:00
|
|
|
package_data = {"octoprint": package_data_dirs('src/octoprint', ['static', 'templates'])}
|
2013-09-15 19:45:31 +00:00
|
|
|
|
2013-07-09 19:39:07 +00:00
|
|
|
include_package_data = True
|
|
|
|
|
zip_safe = False
|
|
|
|
|
install_requires = open("requirements.txt").read().split("\n")
|
|
|
|
|
|
2013-09-15 19:45:31 +00:00
|
|
|
entry_points = {
|
|
|
|
|
"console_scripts": [
|
|
|
|
|
"octoprint = octoprint:main"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#scripts = {
|
|
|
|
|
# "scripts/octoprint.init": "/etc/init.d/octoprint"
|
|
|
|
|
#}
|
|
|
|
|
|
2013-07-09 19:39:07 +00:00
|
|
|
return locals()
|
|
|
|
|
|
|
|
|
|
setup(**params())
|