Skip to content

Instantly share code, notes, and snippets.

@chck
Created September 26, 2017 02:47
Show Gist options
  • Save chck/0ee9a057e6c865143702733d7baf0e49 to your computer and use it in GitHub Desktop.
Save chck/0ee9a057e6c865143702733d7baf0e49 to your computer and use it in GitHub Desktop.
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import subprocess
from distutils.command.build import build as _build
import setuptools
class build(_build): # pylint: disable=invalid-name
sub_commands = _build.sub_commands + [('CustomCommands', None)]
class CustomCommands(setuptools.Command):
def initialize_options(self):
pass
def finalize_options(self):
pass
def RunCustomCommand(self, command_list):
print 'Running command: %s' % command_list
p = subprocess.Popen(
command_list,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
# Can use communicate(input='y\n'.encode()) if the command run requires
# some confirmation.
stdout_data, _ = p.communicate()
print 'Command output: %s' % stdout_data
if p.returncode != 0:
raise RuntimeError(
'Command %s failed: exit code: %s' % (command_list, p.returncode))
def run(self):
for command in CUSTOM_COMMANDS:
self.RunCustomCommand(command)
CUSTOM_COMMANDS = []
# 'pip', 'install',
# 'https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.1-cp27-none-linux_x86_64.whl']]
REQUIRED_PACKAGES = [
'keras',
'theano',
'h5py',
]
setuptools.setup(
name='keras-module',
version='0.0.1',
description='keras model prediction package.',
install_requires=REQUIRED_PACKAGES,
packages=setuptools.find_packages(),
cmdclass={'build': build, 'CustomCommands': CustomCommands})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment