Skip to content

Commit 8d468f8

Browse files
authored
Merge pull request asappresearch#11 from ajsyp/master
Module can now be installed as a regular Python package.
2 parents 8642196 + c27add4 commit 8d468f8

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

setup.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
###############################################################################
2+
from setuptools import setup, find_packages
3+
import shutil
4+
import os
5+
import filecmp
6+
7+
PACKAGE = 'sru'
8+
9+
################################################################################
10+
def readme():
11+
""" Return the README text.
12+
"""
13+
with open('README.md') as fh:
14+
return fh.read()
15+
16+
################################################################################
17+
def get_version():
18+
""" Gets the current version of the package.
19+
"""
20+
version_py = os.path.join(os.path.dirname(__file__), 'version.py')
21+
with open(version_py) as fh:
22+
for line in fh:
23+
if line.startswith('__version__'):
24+
return line.split('=')[-1].strip() \
25+
.replace('"', '').replace("'", '')
26+
raise ValueError('Failed to parse version from: {}'.format(version_py))
27+
28+
################################################################################
29+
def get_requirements():
30+
with open('requirements.txt') as fh:
31+
lines = fh.readlines()
32+
lines = [line.strip() for line in lines]
33+
return [line for line in lines if line]
34+
35+
################################################################################
36+
if not os.path.isfile('sru/cuda_functional.py'):
37+
shutil.copy('cuda_functional.py', 'sru')
38+
needs_delete = True
39+
elif not filecmp.cmp(
40+
'sru/cuda_functional.py', 'cuda_functional.py', shallow=False
41+
):
42+
raise ValueError('Running setup would overwrite the file '
43+
'"sru/cuda_functional.py". Ensure that any changes to the file are '
44+
'present in "./cuda_functional.py", delete "sru/cuda_functional.py", '
45+
'and then try again.')
46+
else:
47+
needs_delete = False
48+
49+
try:
50+
setup(
51+
# Package information
52+
name=PACKAGE,
53+
version=get_version(),
54+
description='Training RNNs as Fast as CNNs',
55+
long_description=readme(),
56+
keywords='deep learning rnn lstm cudnn sru fast',
57+
classifiers=[
58+
],
59+
60+
# Author information
61+
url='https://github.com/taolei87/sru',
62+
author='Tao Lei, Yu Zhang',
63+
author_email='[email protected]',
64+
license='MIT',
65+
66+
# What is packaged here.
67+
packages=['sru'],
68+
69+
# What to include
70+
package_data={
71+
'': ['*.txt', '*.rst', '*.md']
72+
},
73+
74+
# Dependencies
75+
install_requires=get_requirements(),
76+
dependency_links=[
77+
],
78+
79+
zip_safe=False
80+
)
81+
finally:
82+
if needs_delete:
83+
os.unlink('sru/cuda_functional.py')
84+
85+
#### EOF.EOF.EOF.EOF.EOF.EOF.EOF.EOF.EOF.EOF.EOF.EOF.EOF.EOF.EOF.EOF.EOF.EOF.EOF

sru/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .version import __version__
2+
from .cuda_functional import *

sru/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '0.0.1'

0 commit comments

Comments
 (0)