11import os
22from glob import glob
33from setuptools import setup , find_packages
4+ import subprocess
5+ import imp
46
5- NAME = "nimfa"
67
7- def read (fname ):
8- return open (os .path .join (os .path .dirname (__file__ ), fname )).read ()
8+ DISTNAME = 'nimfa'
9+ MAINTAINER = 'Marinka Zitnik'
10+ MAINTAINER_EMAIL = '[email protected] ' 11+ DESCRIPTION = 'A Python module for nonnegative matrix factorization'
12+ LONG_DESCRIPTION = open ('README.rst' ).read ()
13+ URL = 'http://nimfa.biolab.si'
14+ DOWNLOAD_URL = 'http://github.com/marinkaz/nimfa'
15+ KEYWORDS = ['matrix factorization' , 'nonnegative matrix factorization' ,
16+ 'bioinformatics' , 'data mining' ]
17+ LICENSE = 'GPLv3'
18+ VERSION = '1.2.2'
19+ ISRELEASED = True
20+
21+ INSTALL_REQUIRES = (
22+ 'numpy>=1.7.0' ,
23+ 'scipy>=0.12.0' ,
24+ )
25+
926
1027def get_package_data (topdir , excluded = set ()):
1128 retval = []
12- for dirname , subdirs , files in os .walk (os .path .join (NAME , topdir )):
29+ for dirname , subdirs , files in os .walk (os .path .join (DISTNAME , topdir )):
1330 for x in excluded :
1431 if x in subdirs :
1532 subdirs .remove (x )
16- retval .append (os .path .join (dirname [len (NAME )+ 1 :], '*.*' ))
33+ retval .append (os .path .join (dirname [len (DISTNAME )+ 1 :], '*.*' ))
1734 return retval
1835
36+
1937def get_data_files (dest , source ):
2038 retval = []
2139 for dirname , subdirs , files in os .walk (source ):
@@ -25,23 +43,103 @@ def get_data_files(dest, source):
2543 return retval
2644
2745
28- setup (
29- name = NAME ,
30- version = "1.2.1" ,
31- author = "Marinka Zitnik" ,
32- author_email = "[email protected] " ,
33- description = "A Python Library for Nonnegative Matrix Factorization Techniques" ,
34- url = "http://nimfa.biolab.si" ,
35- download_url = "https://github.com/marinkaz/MF" ,
36- packages = find_packages (),
37- package_dir = {NAME : "./nimfa" },
38- package_data = {NAME : get_package_data ("datasets" )},
39- license = "OSI Approved :: GNU General Public License (GPL)" ,
40- long_description = read ("README.rst" ),
41- classifiers = [
42- "License :: OSI Approved :: GNU General Public License (GPL)" ,
43- "Natural Language :: English" ,
44- "Programming Language :: Python" ,
45- "Topic :: Scientific/Engineering"
46- ]
47- )
46+ # Return the git revision as a string
47+ def git_version ():
48+ """Return the git revision as a string.
49+
50+ Copied from numpy setup.py
51+ """
52+ def _minimal_ext_cmd (cmd ):
53+ # construct minimal environment
54+ env = {}
55+ for k in ['SYSTEMROOT' , 'PATH' ]:
56+ v = os .environ .get (k )
57+ if v is not None :
58+ env [k ] = v
59+ # LANGUAGE is used on win32
60+ env ['LANGUAGE' ] = 'C'
61+ env ['LANG' ] = 'C'
62+ env ['LC_ALL' ] = 'C'
63+ out = subprocess .Popen (cmd , stdout = subprocess .PIPE , env = env ).communicate ()[0 ]
64+ return out
65+
66+ try :
67+ out = _minimal_ext_cmd (['git' , 'rev-parse' , 'HEAD' ])
68+ GIT_REVISION = out .strip ().decode ('ascii' )
69+ except OSError :
70+ GIT_REVISION = "Unknown"
71+ return GIT_REVISION
72+
73+
74+ def write_version_py (filename = 'nimfa/version.py' ):
75+ # Copied from numpy setup.py
76+ cnt = """
77+ # THIS FILE IS GENERATED FROM NIMFA SETUP.PY
78+ short_version = '%(version)s'
79+ version = '%(version)s'
80+ full_version = '%(full_version)s'
81+ git_revision = '%(git_revision)s'
82+ release = %(isrelease)s
83+
84+ if not release:
85+ version = full_version
86+ short_version += ".dev"
87+ """
88+ FULLVERSION = VERSION
89+ if os .path .exists ('.git' ):
90+ GIT_REVISION = git_version ()
91+ elif os .path .exists ('nimfa/version.py' ):
92+ # must be a source distribution, use existing version file
93+ version = imp .load_source ("nimfa.version" , "nimfa/version.py" )
94+ GIT_REVISION = version .git_revision
95+ else :
96+ GIT_REVISION = "Unknown"
97+
98+ if not ISRELEASED :
99+ FULLVERSION += '.dev0+' + GIT_REVISION [:7 ]
100+
101+ a = open (filename , 'w' )
102+ try :
103+ a .write (cnt % {'version' : VERSION ,
104+ 'full_version' : FULLVERSION ,
105+ 'git_revision' : GIT_REVISION ,
106+ 'isrelease' : str (ISRELEASED )})
107+ finally :
108+ a .close ()
109+
110+
111+
112+ def setup_package ():
113+ write_version_py ()
114+ setup (
115+ name = DISTNAME ,
116+ version = VERSION ,
117+ author = MAINTAINER ,
118+ author_email = MAINTAINER_EMAIL ,
119+ maintainer = MAINTAINER ,
120+ maintainer_email = MAINTAINER_EMAIL ,
121+ description = DESCRIPTION ,
122+ url = URL ,
123+ download_url = DOWNLOAD_URL ,
124+ keywords = KEYWORDS ,
125+ install_requires = INSTALL_REQUIRES ,
126+ packages = find_packages (),
127+ package_dir = {DISTNAME : "./nimfa" },
128+ package_data = {DISTNAME : get_package_data ("datasets" )},
129+ license = LICENSE ,
130+ long_description = LONG_DESCRIPTION ,
131+ classifiers = ['Intended Audience :: Science/Research' ,
132+ 'Intended Audience :: Developers' ,
133+ 'License :: OSI Approved' ,
134+ 'Programming Language :: Python' ,
135+ 'Topic :: Software Development' ,
136+ 'Topic :: Scientific/Engineering' ,
137+ 'Topic :: Scientific/Engineering :: Artificial Intelligence' ,
138+ 'Topic :: Scientific/Engineering :: Bio-Informatics' ,
139+ 'Programming Language :: Python :: 2' ,
140+ 'Programming Language :: Python :: 3' ,],
141+ )
142+
143+
144+ if __name__ == "__main__" :
145+ setup_package ()
0 commit comments