Skip to content

Commit 2baa6a6

Browse files
author
David Noble
committed
Working through release steps
* Confirmed that with this change this command produces the desired results: ./setup.py build dist sdist bdist_egg
1 parent b8ad580 commit 2baa6a6

File tree

2 files changed

+70
-81
lines changed

2 files changed

+70
-81
lines changed

examples/searchcommands_app/setup.py

Lines changed: 57 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def symlink(source, link_name):
5757
patch_os()
5858
del locals()['patch_os'] # since this function has done its job
5959

60-
6160
from collections import OrderedDict
6261
from glob import glob
6362
from itertools import chain
@@ -423,54 +422,60 @@ def run(self):
423422

424423
# endregion
425424

426-
setup(
427-
description='Custom Search Command examples',
428-
name=os.path.basename(project_dir),
429-
version='1.5.0',
430-
author='Splunk, Inc.',
431-
author_email='devinfo@splunk.com',
432-
url='http://github.com/splunk/splunk-sdk-python',
433-
license='http://www.apache.org/licenses/LICENSE-2.0',
434-
classifiers=[
435-
'Development Status :: 5 - Production/Stable',
436-
'Environment :: Other Environment',
437-
'Intended Audience :: Information Technology',
438-
'License :: Other/Proprietary License',
439-
'Operating System :: OS Independent',
440-
'Programming Language :: Python',
441-
'Topic :: System :: Logging',
442-
'Topic :: System :: Monitoring'],
443-
packages=[
444-
b'bin.packages.splunklib', b'bin.packages.splunklib.searchcommands'
445-
],
446-
package_dir={
447-
b'bin': os.path.join('package', 'bin'),
448-
b'bin.packages': os.path.join('package', 'bin', 'packages'),
449-
b'bin.packages.splunklib': os.path.join('..', '..', 'splunklib'),
450-
b'bin.packages.splunklib.searchcommands': os.path.join('..', '..', 'splunklib', 'searchcommands')
451-
},
452-
package_data={
453-
b'bin': [
454-
os.path.join('package', 'bin', 'app.py'),
455-
os.path.join('package', 'bin', 'countmatches.py'),
456-
os.path.join('package', 'bin', 'filter.py'),
457-
os.path.join('package', 'bin', 'generatehello.py'),
458-
os.path.join('package', 'bin', 'generatetext.py'),
459-
os.path.join('package', 'bin', 'pypygeneratetext.py'),
460-
os.path.join('package', 'bin', 'simulate.py'),
461-
os.path.join('package', 'bin', 'sum.py')
462-
]
463-
},
464-
data_files=[
465-
(b'README', [os.path.join('package', 'README', '*.conf.spec')]),
466-
(b'default', [os.path.join('package', 'default', '*.conf')]),
467-
(b'lookups', [os.path.join('package', 'lookups', '*.csv.gz')]),
468-
(b'metadata', [os.path.join('package', 'metadata', 'default.meta')])
469-
],
470-
requires=[],
471-
472-
cmdclass=OrderedDict((
473-
('analyze', AnalyzeCommand),
474-
('build', BuildCommand),
475-
('link', LinkCommand),
476-
('test', TestCommand))))
425+
current_directory = os.getcwdu()
426+
os.chdir(project_dir)
427+
428+
try:
429+
setup(
430+
description='Custom Search Command examples',
431+
name=os.path.basename(project_dir),
432+
version='1.5.0',
433+
author='Splunk, Inc.',
434+
author_email='devinfo@splunk.com',
435+
url='http://github.com/splunk/splunk-sdk-python',
436+
license='http://www.apache.org/licenses/LICENSE-2.0',
437+
classifiers=[
438+
'Development Status :: 5 - Production/Stable',
439+
'Environment :: Other Environment',
440+
'Intended Audience :: Information Technology',
441+
'License :: Other/Proprietary License',
442+
'Operating System :: OS Independent',
443+
'Programming Language :: Python',
444+
'Topic :: System :: Logging',
445+
'Topic :: System :: Monitoring'],
446+
packages=[
447+
b'bin.packages.splunklib', b'bin.packages.splunklib.searchcommands'
448+
],
449+
package_dir={
450+
b'bin': os.path.join('package', 'bin'),
451+
b'bin.packages': os.path.join('package', 'bin', 'packages'),
452+
b'bin.packages.splunklib': os.path.join('..', '..', 'splunklib'),
453+
b'bin.packages.splunklib.searchcommands': os.path.join('..', '..', 'splunklib', 'searchcommands')
454+
},
455+
package_data={
456+
b'bin': [
457+
os.path.join('package', 'bin', 'app.py'),
458+
os.path.join('package', 'bin', 'countmatches.py'),
459+
os.path.join('package', 'bin', 'filter.py'),
460+
os.path.join('package', 'bin', 'generatehello.py'),
461+
os.path.join('package', 'bin', 'generatetext.py'),
462+
os.path.join('package', 'bin', 'pypygeneratetext.py'),
463+
os.path.join('package', 'bin', 'simulate.py'),
464+
os.path.join('package', 'bin', 'sum.py')
465+
]
466+
},
467+
data_files=[
468+
(b'README', [os.path.join('package', 'README', '*.conf.spec')]),
469+
(b'default', [os.path.join('package', 'default', '*.conf')]),
470+
(b'lookups', [os.path.join('package', 'lookups', '*.csv.gz')]),
471+
(b'metadata', [os.path.join('package', 'metadata', 'default.meta')])
472+
],
473+
requires=[],
474+
475+
cmdclass=OrderedDict((
476+
('analyze', AnalyzeCommand),
477+
('build', BuildCommand),
478+
('link', LinkCommand),
479+
('test', TestCommand))))
480+
finally:
481+
os.chdir(current_directory)

setup.py

100644100755
Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616

1717
from setuptools import setup, Command
1818
from contextlib import closing
19-
from fnmatch import fnmatch
19+
from subprocess import check_call, STDOUT
2020

2121
import os
22-
import splunklib
22+
import sys
23+
import shutil
2324
import tarfile
2425

26+
import splunklib
27+
2528

2629
def run_test_suite():
2730
try:
@@ -102,7 +105,7 @@ def run(self):
102105
class DistCommand(Command):
103106
"""setup.py command to create .spl files for modular input and search
104107
command examples"""
105-
description = "Build modular input and search command example .spl files."
108+
description = "Build modular input and search command example tarballs."
106109
user_options = []
107110

108111
def initialize_options(self):
@@ -163,35 +166,16 @@ def run(self):
163166

164167
spl.close()
165168

166-
# Create searchcommands_app.spl
167-
168-
sdk_dir = os.path.abspath('.')
169-
170-
def exclude(path):
171-
# TODO: DVPL-5866 - Replace with filter function because exclude is deprecated
172-
basename = os.path.basename(path)
173-
for pattern in ['.DS_Store', '.idea', '*.log', '*.py[co]']:
174-
if fnmatch(basename, pattern):
175-
return True
176-
return False
177-
178-
tarball = os.path.join(sdk_dir, 'build', 'searchcommands_app.spl')
179-
180-
splunklib_arcname = os.path.join(
181-
'searchcommands_app', 'bin', 'splunklib')
169+
# Create searchcommands_app-<three-part-version-number>-private.tar.gz
182170

183-
manifest = [
184-
(os.path.join(sdk_dir, 'examples', 'searchcommands_app'),
185-
'searchcommands_app'),
186-
(os.path.join(sdk_dir, 'splunklib'),
187-
splunklib_arcname)
188-
]
171+
setup_py = os.path.join('examples', 'searchcommands_app', 'setup.py')
189172

190-
with closing(tarfile.open(tarball, 'w')) as spl:
191-
for source, target in manifest:
192-
# Args here are: name, arcname, recursive, and [exclude|filter]
193-
spl.add(source, target, True, exclude)
173+
check_call((setup_py, 'build', '--force'), stderr=STDOUT, stdout=sys.stdout)
174+
tarball = 'searchcommands_app-{0}-private.tar.gz'.format(self.distribution.metadata.version)
175+
source = os.path.join('examples', 'searchcommands_app', 'build', tarball)
176+
target = os.path.join('build', tarball)
194177

178+
shutil.copyfile(source, target)
195179
return
196180

197181
setup(

0 commit comments

Comments
 (0)