diff --git a/.conda-recipe/bld.bat b/.conda-recipe/bld.bat new file mode 100644 index 0000000000000000000000000000000000000000..ba2bd5cb6a7e222d7d5b568decf334bdcf6dbecc --- /dev/null +++ b/.conda-recipe/bld.bat @@ -0,0 +1,15 @@ +REM Generate `setup.py` from `pavement.py` definition. +"%PYTHON%" -m paver generate_setup + +REM **Workaround** `conda build` runs a copy of `setup.py` named +REM `conda-build-script.py` with the recipe directory as the only argument. +REM This causes paver to fail, since the recipe directory is not a valid paver +REM task name. +REM +REM We can work around this by wrapping the original contents of `setup.py` in +REM an `if` block to only execute during package installation. +"%PYTHON%" -c "input_ = open('setup.py', 'r'); data = input_.read(); input_.close(); output_ = open('setup.py', 'w'); output_.write('\n'.join(['import sys', 'import path_helpers as ph', '''if ph.path(sys.argv[0]).name == 'conda-build-script.py':''', ' sys.argv.pop()', 'else:', '\n'.join([(' ' + d) for d in data.splitlines()])])); output_.close(); print open('setup.py', 'r').read()" + +REM Install source directory as Python package. +"%PYTHON%" -m pip install --no-cache --find-links http://192.99.4.95/wheels --trusted-host 192.99.4.95 . +if errorlevel 1 exit 1 diff --git a/.conda-recipe/meta.yaml b/.conda-recipe/meta.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4bb00c683e856231c4165f023494a3e22316e6ac --- /dev/null +++ b/.conda-recipe/meta.yaml @@ -0,0 +1,52 @@ +# source will be downloaded prior to filling in jinja templates +# Example assumes that this folder has setup.py in it +source: + git_url: ../ + +package: + name: dstat-interface +{% if GIT_DESCRIBE_NUMBER > '0' %} + version: {{ GIT_DESCRIBE_TAG[1:] }}.post{{ GIT_DESCRIBE_NUMBER }} +{% else %} + version: {{ GIT_DESCRIBE_TAG[1:] }} +{% endif %} + +build: + entry_points: + - dstat-interface = dstat_interface.main:main + + # If this is a new build for the same version, increment the build + # number. If you do not include this key, it defaults to 0. + number: 0 + +requirements: + build: + - python + - paver + - path_helpers + - matplotlib + - pandas + - psutil + - pycairo-gtk2 + - pyserial + - pyyaml + - pyzmq + - seaborn + - si-prefix + - zeo + - zmq-plugin + - zodb + + run: + - matplotlib + - pandas + - psutil + - pycairo-gtk2 + - pyserial + - pyyaml + - pyzmq + - seaborn + - si-prefix + - zeo + - zmq-plugin + - zodb diff --git a/dstat_interface/main.py b/dstat_interface/main.py index 1ad8aac21c1db69f9a35bf5989f8d37dafbf4ba4..62ceaf1b5f93ad8e538ceda26f88dee0019636ce 100755 --- a/dstat_interface/main.py +++ b/dstat_interface/main.py @@ -65,7 +65,16 @@ except ImportError: sys.exit(1) from serial import SerialException import logging -os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) +# Add package directory to Python path. +# +# This is required for relative imports, which are required for running under a +# `multiprocessing` process. +parent_dir = os.path.abspath(os.path.dirname(__file__)) +if parent_dir not in sys.path: + sys.path.insert(0, parent_dir) +# Change directory into package parent directory to support loading glade UI +# files using relative paths. +os.chdir(parent_dir) from version import getVersion import interface.save as save @@ -1031,8 +1040,12 @@ class Main(object): self.plugin = None -if __name__ == "__main__": +def main(): multiprocessing.freeze_support() gobject.threads_init() MAIN = Main() gtk.main() + + +if __name__ == "__main__": + main()