11#!/usr/bin/env python
22
3+ import os
4+ import sys
5+ from pathlib import Path
36from typing import Sequence
7+
48from setuptools import setup , find_packages
59from setuptools .command .build_py import build_py as _build_py
610from setuptools .command .sdist import sdist as _sdist
7- import os
8- import sys
911
10- with open (os .path .join (os .path .dirname (__file__ ), "VERSION" ), encoding = "utf-8" ) as ver_file :
11- VERSION = ver_file .readline ().strip ()
1212
13- with open ( "requirements.txt" , encoding = "utf-8" ) as reqs_file :
14- requirements = reqs_file . read (). splitlines ( )
13+ def _read_content ( path : str ) -> str :
14+ return ( Path ( __file__ ). parent / path ). read_text ( encoding = "utf-8" )
1515
16- with open ("test-requirements.txt" , encoding = "utf-8" ) as reqs_file :
17- test_requirements = reqs_file .read ().splitlines ()
1816
19- with open ("README.md" , encoding = "utf-8" ) as rm_file :
20- long_description = rm_file .read ()
17+ version = _read_content ("VERSION" ).strip ()
18+ requirements = _read_content ("requirements.txt" ).splitlines ()
19+ test_requirements = _read_content ("test-requirements.txt" ).splitlines ()
20+ doc_requirements = _read_content ("doc/requirements.txt" ).splitlines ()
21+ long_description = _read_content ("README.md" )
2122
2223
2324class build_py (_build_py ):
@@ -48,7 +49,7 @@ def _stamp_version(filename: str) -> None:
4849 with open (filename ) as f :
4950 for line in f :
5051 if "__version__ =" in line :
51- line = line .replace ('"git"' , "'%s'" % VERSION )
52+ line = line .replace ('"git"' , "'%s'" % version )
5253 found = True
5354 out .append (line )
5455 except OSError :
@@ -64,7 +65,7 @@ def _stamp_version(filename: str) -> None:
6465setup (
6566 name = "GitPython" ,
6667 cmdclass = {"build_py" : build_py , "sdist" : sdist },
67- version = VERSION ,
68+ version = version ,
6869 description = "GitPython is a Python library used to interact with Git repositories" ,
6970 author = "Sebastian Thiel, Michael Trier" ,
7071 author_email = "byronimo@gmail.com, mtrier@gmail.com" ,
@@ -75,7 +76,10 @@ def _stamp_version(filename: str) -> None:
7576 package_dir = {"git" : "git" },
7677 python_requires = ">=3.7" ,
7778 install_requires = requirements ,
78- extras_require = {"test" : test_requirements },
79+ extras_require = {
80+ "test" : test_requirements ,
81+ "doc" : doc_requirements ,
82+ },
7983 zip_safe = False ,
8084 long_description = long_description ,
8185 long_description_content_type = "text/markdown" ,
0 commit comments