Skip to content

Commit e90b86b

Browse files
committed
Stop writing setup.py files in plugin wizard generated code, use requirements.txt instead.
1 parent 7ccfa08 commit e90b86b

2 files changed

Lines changed: 6 additions & 76 deletions

File tree

src/mapclient/tools/pluginwizard/skeleton.py

Lines changed: 6 additions & 16 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')
@@ -474,7 +464,7 @@ def write(self):
474464
os.mkdir(namespace_dir)
475465
os.mkdir(step_package_dir)
476466

477-
self._writeSetup(package_dir)
467+
self._write_meta_files(package_dir)
478468
self._writeNamespaceInit(namespace_dir)
479469

480470
# Write step package init file

src/mapclient/tools/pluginwizard/skeletonstrings.py

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -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
"""

0 commit comments

Comments
 (0)