Skip to content

Commit a8458d8

Browse files
authored
Merge pull request #175 from hsorby/rm-setup
Remove setup.py
2 parents fad9a72 + 44ee316 commit a8458d8

5 files changed

Lines changed: 30 additions & 96 deletions

File tree

src/mapclient/tools/pluginwizard/skeleton.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
SERIALIZE_METHOD_STRING,
5252
SET_IDENTIFIER_DEFAULT_CONTENT_STRING,
5353
SET_IDENTIFIER_IDENTIFIER_CONTENT_STRING,
54-
SETUP_PY_TEMPLATE,
5554
STEP_PACKAGE_INIT_STRING,
5655
)
5756

@@ -77,22 +76,13 @@ def __init__(self, options, qt_tool_options):
7776
self._options = options
7877
self._qt_tool_options = qt_tool_options
7978

80-
def _writeSetup(self, target_dir):
79+
def _write_meta_files(self, target_dir):
8180
"""
82-
Write the setup file, for integration with setuptools.
81+
Write the requirements file, for integration with pip install -r requirements.txt.
8382
"""
84-
target_file = os.path.join(target_dir, 'setup.py')
85-
with open(target_file, 'w') as f:
86-
f.write(SETUP_PY_TEMPLATE % dict(
87-
description='',
88-
name=self._options.getFullPackageName(),
89-
package_name=self._options.getPackageName(),
90-
author=self._options.getAuthorName(),
91-
author_email='',
92-
url='',
93-
plugin_namespace=PLUGIN_NAMESPACE,
94-
namespace_packages=[PLUGIN_NAMESPACE],
95-
))
83+
target_file = os.path.join(target_dir, 'requirements.txt')
84+
with open(target_file, 'w') as fh:
85+
fh.write('# List plugin requirements here:\n')
9686

9787
readme_file = os.path.join(target_dir, 'README.rst')
9888
license_file = os.path.join(target_dir, 'LICENSE')
@@ -230,7 +220,6 @@ def _generateConfigureMethod(self):
230220
self._configured = dlg.validate()
231221
self._configuredObserver()
232222
"""
233-
else:
234223
method_string += ' pass\n'
235224

236225
return method_string
@@ -474,7 +463,7 @@ def write(self):
474463
os.mkdir(namespace_dir)
475464
os.mkdir(step_package_dir)
476465

477-
self._writeSetup(package_dir)
466+
self._write_meta_files(package_dir)
478467
self._writeNamespaceInit(namespace_dir)
479468

480469
# Write step package init file

src/mapclient/tools/pluginwizard/skeletonstrings.py

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def __init__(self, parent=None):
126126
# and know how many occurrences of the current identifier there should
127127
# be.
128128
self._previousIdentifier = ''
129-
# Set a place holder for a callable that will get set from the step.
129+
# Set a placeholder for a callable that will get set from the step.
130130
# We will use this method to decide whether the identifier is unique.
131131
self.identifierOccursCount = None
132132
@@ -305,66 +305,6 @@ def validate(self):
305305
"""
306306

307307

308-
SETUP_PY_TEMPLATE = """\
309-
import codecs
310-
import io
311-
import os
312-
import re
313-
314-
from setuptools import setup, find_packages
315-
316-
SETUP_DIR = os.path.dirname(os.path.abspath(__file__))
317-
318-
319-
def read(*parts):
320-
with codecs.open(os.path.join(SETUP_DIR, *parts), 'r') as fp:
321-
return fp.read()
322-
323-
324-
def find_version(*file_paths):
325-
version_file = read(*file_paths)
326-
version_match = re.search(r"^__version__ = ['\\"]([^'\\"]*)['\\"]",
327-
version_file, re.M)
328-
if version_match:
329-
return version_match.group(1)
330-
raise RuntimeError("Unable to find version string.")
331-
332-
333-
def readfile(filename, split=False):
334-
with io.open(filename, encoding="utf-8") as stream:
335-
if split:
336-
return stream.read().split("\\n")
337-
return stream.read()
338-
339-
340-
readme = readfile("README.rst", split=True)[3:] # Skip title
341-
source_license = readfile("LICENSE")
342-
requires = ['PySide6'] # Minimal requirements listing. Insert additional dependencies here.
343-
344-
345-
setup(
346-
name=%(name)r,
347-
version=find_version(%(plugin_namespace)r, %(package_name)r, '__init__.py'),
348-
description=%(description)r,
349-
long_description='\\n'.join(readme) + source_license,
350-
long_description_content_type='text/x-rst',
351-
classifiers=[
352-
"Development Status :: 3 - Alpha",
353-
"License :: OSI Approved :: Apache Software License",
354-
"Programming Language :: Python",
355-
],
356-
author=%(author)r,
357-
author_email=%(author_email)r,
358-
url=%(url)r,
359-
packages=find_packages(exclude=['ez_setup', ]),
360-
namespace_packages=%(namespace_packages)r,
361-
include_package_data=True,
362-
zip_safe=False,
363-
install_requires=requires,
364-
)
365-
"""
366-
367-
368308
NAMESPACE_INIT = """\
369309
__import__('pkg_resources').declare_namespace(__name__)
370310
"""

src/mapclient/tools/pmr/pmrtool.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ def __init__(self, pmr_info=None, use_external_git=False):
145145
def set_info(self, info):
146146
self._pmr_info = info
147147

148-
def set_use_external_git(self, use_external_git):
148+
@staticmethod
149+
def set_use_external_git(use_external_git):
149150
name = 'authenticated_git' if use_external_git else 'authenticated_dulwich'
150151
return get_cmd_by_name(name)
151152

src/mapclient/view/workflow/workflowcommands.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,27 @@ class CommandSelection(QtGui.QUndoCommand):
6060
don't end up in a recursive loop.
6161
"""
6262

63-
def __init__(self, scene, selection, previous):
63+
def __init__(self, scene, current, previous):
6464
super(CommandSelection, self).__init__()
65-
logger.debug("Selection Command created ...")
6665
self._scene = scene
67-
self._selection = selection
68-
self._previousSelection = previous
66+
self._current = list(current)
67+
self._previous = list(previous)
6968

7069
def redo(self):
71-
self._scene.blockSignals(True)
72-
for item in list(self._scene.items()):
73-
item.setSelected(item in self._selection)
74-
self._scene.blockSignals(False)
70+
self._apply_selection(self._current)
7571

7672
def undo(self):
73+
self._apply_selection(self._previous)
74+
75+
def _apply_selection(self, items_to_select):
7776
self._scene.blockSignals(True)
78-
for item in list(self._scene.items()):
79-
item.setSelected(item in self._previousSelection)
77+
78+
self._scene.clearSelection()
79+
for item in items_to_select:
80+
# Check if item still belongs to scene (handle deleted items)
81+
if item.scene() == self._scene:
82+
item.setSelected(True)
83+
8084
self._scene.blockSignals(False)
8185

8286

src/mapclient/view/workflow/workflowgraphicsview.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,10 @@ def connectNodes(self, src_port, dest_port):
129129
self._errorIconTimer.start()
130130

131131
def selectionChanged(self):
132-
currentSelection = self.scene().selectedItems()
133-
previousSelection = self.scene().previouslySelectedItems()
134-
command = CommandSelection(self.scene(), currentSelection, previousSelection)
135-
self._undoStack.push(command)
136-
self.scene().setPreviouslySelectedItems(currentSelection)
132+
current_selection = self.scene().selectedItems()
133+
previous_selection = self.scene().previouslySelectedItems()
134+
self._undoStack.push(CommandSelection(self.scene(), current_selection, previous_selection))
135+
self.scene().setPreviouslySelectedItems(current_selection)
137136

138137
def nodeSelected(self, node, state):
139138
if state and node not in self._selectedNodes:
@@ -370,9 +369,10 @@ def mouseReleaseEvent(self, event):
370369
QtWidgets.QGraphicsView.mouseReleaseEvent(self, event)
371370
if self._selectionStartPos:
372371
diff = event.pos() - self._selectionStartPos
373-
if diff.x() != 0 and diff.y() != 0:
372+
selected_items = self.scene().selectedItems()
373+
if diff.x() != 0 and diff.y() != 0 and selected_items:
374374
self._undoStack.beginMacro('Move Step(s)')
375-
for item in self.scene().selectedItems():
375+
for item in selected_items:
376376
if item.type() == Node.Type:
377377
self._undoStack.push(CommandMove(item, item.pos() - diff, item.pos()))
378378
self._undoStack.endMacro()

0 commit comments

Comments
 (0)