1+ import os
12from setuptools import setup
23
3- import codecs
4- import os .path
5- from pathlib import Path
4+ DIR = os .path .abspath (os .path .dirname (__file__ ))
65
7- def read (rel_path ):
8- here = os .path .abspath (os .path .dirname (__file__ ))
9- with codecs .open (os .path .join (here , rel_path ), 'r' ) as fp :
10- return fp .read ()
6+ with open (os .path .join (DIR , 'README.md' )) as fh :
7+ long_description = fh .read ()
118
12- def get_version (rel_path ):
13- for line in read (rel_path ).splitlines ():
14- if line .startswith ('__version__' ):
15- delim = '"' if '"' in line else "'"
16- return line .split (delim )[1 ]
17- else :
18- raise RuntimeError ("Unable to find version string." )
9+ with open (os .path .join (DIR , 'requirements.txt' )) as fh :
10+ requirements = fh .read ().splitlines ()
1911
20- # read the contents of your README file
21- this_directory = Path (__file__ ).parent
22- long_description = (this_directory / "README.md" ).read_text ()
12+ def get_version (initpath : str ) -> str :
13+ """ Get from the init of the source code the version string
14+
15+ Params:
16+ initpath (str): path to the init file of the python package relative to the setup file
17+
18+ Returns:
19+ str: The version string in the form 0.0.1
20+ """
21+
22+ path = os .path .join (os .path .dirname (__file__ ), initpath )
23+
24+ with open (path , "r" ) as handle :
25+ for line in handle .read ().splitlines ():
26+ if line .startswith ("__version__" ):
27+ return line .split ("=" )[1 ].strip ().strip ("\" '" )
28+ else :
29+ raise RuntimeError ("Unable to find version string." )
2330
2431setup (
2532 name = 'mltu' ,
@@ -29,4 +36,11 @@ def get_version(rel_path):
2936 url = 'https://pylessons.com/' ,
3037 author = 'PyLessons' ,
3138 author_email = 'pythonlessons0@gmail.com' ,
39+ install_requires = requirements ,
40+ extras_require = {
41+ 'gpu' : ['onnxruntime-gpu' ],
42+ },
43+ python_requires = '>=3' ,
44+ packages = ['mltu' ],
45+ include_package_data = True ,
3246)
0 commit comments