Skip to content

Commit

Permalink
Merge branch '1.0.x' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Jun 2, 2017
2 parents 5a934c5 + 22e8ff5 commit 39d093d
Show file tree
Hide file tree
Showing 15 changed files with 215 additions and 53 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ nosetests.xml
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ Bugfixes:
* Overwrite tty prompt works correctly on Python 3
* Fix /proc in vagrant-chroot and chroot having outside mounts
* Fix ANSI escapes showing in Qt terminal dialog
* Fix reprozip combine crash on Python 3.6 (patch from James Clarke)
* Using `graph --packages drop` together with `--json` no longer crashes

Enhancements:
* Add `--docker-cmd` to reprounzip-docker to select the Docker command (for example `--docker-cmd="sudo docker"`)
* Implement `--expose-port` option for Vagrant and Docker (no need for `--docker-option=-p...`)
* Add docker-machine support to GUI (select which machine to use)
* Better binaries for MacOS

1.0.9 (2017-01-10)
------------------
Expand Down
32 changes: 31 additions & 1 deletion reprounzip-qt/reprounzip_qt/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,37 @@

from __future__ import division, print_function, unicode_literals

from PyQt4 import QtGui
from PyQt4 import QtCore, QtGui

from reprounzip_qt.gui.unpack import UnpackTab
from reprounzip_qt.gui.run import RunTab


class Application(QtGui.QApplication):
def __init__(self, argv):
QtGui.QApplication.__init__(self, argv)
self.first_window = None
self.windows = set()

def event(self, event):
if event.type() == QtCore.QEvent.FileOpen:
# Create new window for this RPZ
window = ReprounzipUi(unpack=dict(package=event.file()))
window.setVisible(True)
self.windows.add(window)
# Close first window if it exists
if self.first_window and self.first_window.replaceable():
self.first_window.close()
self.first_window.deleteLater()
self.first_window = None
return True
return QtGui.QApplication.event(self, event)

def set_first_window(self, window):
self.first_window = window
self.windows.add(window)


class ReprounzipUi(QtGui.QMainWindow):
def __init__(self, unpack={}, run={}, tab=None, **kwargs):
super(ReprounzipUi, self).__init__(**kwargs)
Expand All @@ -28,6 +53,11 @@ def _unpacked(self, directory, root):

def closeEvent(self, event):
if self.tabs.widget(1).should_exit():
Application.instance().windows.discard(self)
event.accept()
else:
event.ignore()

def replaceable(self):
return (self.tabs.widget(0).replaceable() and
self.tabs.widget(1).replaceable())
3 changes: 3 additions & 0 deletions reprounzip-qt/reprounzip_qt/gui/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,6 @@ def should_exit(self):
return r == QtGui.QMessageBox.Yes
else:
return True

def replaceable(self):
return not self.unpacker
3 changes: 3 additions & 0 deletions reprounzip-qt/reprounzip_qt/gui/unpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ def __init__(self, package='', **kwargs):

self._package_changed()

def replaceable(self):
return not self.package_widget.text()

def _browse_pkg(self):
picked = QtGui.QFileDialog.getOpenFileName(
self, "Pick package file",
Expand Down
11 changes: 6 additions & 5 deletions reprounzip-qt/reprounzip_qt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def qt_init():
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)

from PyQt4 import QtGui

return QtGui.QApplication(sys.argv)
from PyQt4 import QtGui # noqa


def main():
Expand All @@ -38,9 +36,11 @@ def main():

args = parser.parse_args()

app = qt_init()
qt_init()

from reprounzip_qt.gui import Application, ReprounzipUi

from reprounzip_qt.gui import ReprounzipUi
app = Application(sys.argv)

window_args = {}
if args.package and args.unpacked:
Expand All @@ -57,6 +57,7 @@ def main():
sys.exit(2)

window = ReprounzipUi(**window_args)
app.set_first_window(window)
window.setVisible(True)

app.exec_()
Expand Down
14 changes: 1 addition & 13 deletions reprounzip-qt/setup.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
import io
import os
from setuptools import setup
import sys


# pip workaround
os.chdir(os.path.abspath(os.path.dirname(__file__)))


# MacOS .app with py2app
if sys.platform == 'darwin':
extra_options = dict(
setup_requires=['py2app'],
app=['reprounzip_qt/main.py'],
options=dict(py2app=dict(argv_emulation=True)))
else:
extra_options = {}


# Need to specify encoding for PY3, which has the worst unicode handling ever
with io.open('README.rst', encoding='utf-8') as fp:
description = fp.read()
Expand Down Expand Up @@ -45,5 +34,4 @@
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2.7',
'Topic :: Scientific/Engineering',
'Topic :: System :: Archiving'],
**extra_options)
'Topic :: System :: Archiving'])
33 changes: 27 additions & 6 deletions reprounzip/reprounzip/unpackers/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ def dot_endpoint(self, f, level_pkgs):
else:
return '"%s"' % escape(unicode_(f))

def json_endpoint(self, f, level_pkgs):
if level_pkgs == LVL_PKG_PACKAGE:
return self.name
else:
return unicode_(f)

def json(self, level_pkgs):
if level_pkgs == LVL_PKG_PACKAGE:
logging.critical("JSON output doesn't support --packages package")
Expand Down Expand Up @@ -634,7 +640,10 @@ def graph_json(target, runs, packages, other_files, package_map, edges,
"""Writes a JSON file suitable for further processing.
"""
# Packages
json_packages = [pkg.json(level_pkgs) for pkg in packages]
if level_pkgs in (LVL_PKG_IGNORE, LVL_PKG_DROP):
json_packages = []
else:
json_packages = [pkg.json(level_pkgs) for pkg in packages]

# Other files
json_other_files = [unicode_(fi) for fi in sorted(other_files)]
Expand All @@ -644,15 +653,27 @@ def graph_json(target, runs, packages, other_files, package_map, edges,
json_runs = [run.json(prog_map, level_processes) for run in runs]

# Connect edges
for prog, f, mode, argv in edges:
what = unicode_(f)
done_edges = set()
for prog, fi, mode, argv in edges:
endp_prog = prog_map[prog]
if fi in package_map:
if level_pkgs == LVL_PKG_DROP:
continue
endp_file = package_map[fi].json_endpoint(fi, level_pkgs)
e = endp_prog['name'], endp_file, mode
if e in done_edges:
continue
else:
done_edges.add(e)
else:
endp_file = unicode_(fi)
if mode is None:
prog_map[prog]['reads'].append(what)
endp_prog['reads'].append(endp_file)
# TODO: argv?
elif mode & FILE_WRITE:
prog_map[prog]['writes'].append(what)
endp_prog['writes'].append(endp_file)
elif mode & FILE_READ:
prog_map[prog]['reads'].append(what)
endp_prog['reads'].append(endp_file)

json_other_files.sort()

Expand Down
2 changes: 1 addition & 1 deletion scripts/macos/ReproUnzip.pkgproj
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@
<key>GID</key>
<integer>0</integer>
<key>PATH</key>
<string>../../reprounzip-qt/dist/ReproUnzip.app</string>
<string>app-shim/ReproUnzip.app</string>
<key>PATH_TYPE</key>
<integer>1</integer>
<key>PERMISSIONS</key>
Expand Down
43 changes: 43 additions & 0 deletions scripts/macos/app-shim/ReproUnzip.app/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>ReproUnzip</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>rpz</string>
</array>
<key>CFBundleTypeName</key>
<string>ReproZip Package</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>????</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>reprounzip-qt</string>
<key>CFBundleIdentifier</key>
<string>edu.nyu.engineering.vida.reprounzip</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>reprounzip-qt</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSHasLocalizedDisplayName</key>
<false/>
</dict>
</plist>
15 changes: 15 additions & 0 deletions scripts/macos/app-shim/reprounzip-qt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char **argv) {
char **args = malloc(sizeof(char*) * (argc + 1));
size_t i;
for(i = 1; i < argc; ++i) {
args[i] = argv[i];
}
args[argc] = 0;
execv("/opt/reprounzip/reprounzip-qt", args);
perror("execv failed");
return 1;
}
22 changes: 22 additions & 0 deletions scripts/macos/app-shim/reprounzip-qt.debug.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

/* This version of reprounzip-qt runs from a virtualenv, useful for local
* development on reprounzip-qt while still starting it as a Mac app bundle */

int main(int argc, char **argv) {
char **args = malloc(sizeof(char*) * (argc + 4));
size_t i;
args[0] = "/bin/sh";
args[1] = "-c";
args[2] = ". /Users/remram/Documents/programming/_venvs/reprozip/bin/activate && reprounzip-qt \"$@\"";
args[3] = "-";
for(i = 1; i < argc; ++i) {
args[i + 3] = argv[i];
}
args[argc + 3] = 0;
execv("/bin/sh", args);
perror("execv failed");
return 1;
}
17 changes: 17 additions & 0 deletions scripts/macos/instructions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Reset PATH to not include macports, etc
export DYLD_FRAMEWORK_PATH=/opt/reprounzip/Frameworks
export CFLAGS="-mmacosx-version-min=10.8 -isysroot /Developer/SDKs/MacOSX10.8.sdk"
export LDFLAGS="-mmacosx-version-min=10.8 -isysroot /Developer/SDKs/MacOSX10.8.sdk"
export MACOS_DEPLOYMENT_TARGET=10.8
Build Python with --prefix=/opt/reprounzip/python27
Copy reprounzip and reprounzip-qt to /opt/reprounzip
Install pip with get-pip.py
Install reprounzip, reprounzip-docker, reprounzip-vagrant, reprounzip-vistrails
Install sip and PyQt4
Install reprounzip-qt
Build shim application:
gcc -mmacosx-version-min=10.8 -isysroot /Developer/SDKs/MacOSX10.8.sdk \
reprounzip-qt.c -o ReproUnzip.app/Contents/MacOS/reprounzip-qt
Put QtCore.framework and QtGui.framework in /opt/reprounzip/Frameworks
Build installer using ReproUnzip.pkgproj
Packages application: http://s.sudre.free.fr/Software/Packages/about.html
5 changes: 5 additions & 0 deletions scripts/macos/reprounzip-qt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

DYLD_FRAMEWORK_PATH=/opt/reprounzip/Frameworks; export DYLD_FRAMEWORK_PATH
PATH="/opt/reprounzip:$PATH"
exec "$(dirname "$0")/python27/bin/reprounzip-qt" "$@"

0 comments on commit 39d093d

Please sign in to comment.