11#!/usr/bin/env python
22# -*- coding: utf-8 -*-
33
4- # Note: To use the "upload" functionality of this file, you must:
5- # $ pip install twine
4+ from typing import Iterable , Union
5+ from pathlib import Path
66
7- import io
8- import os
9- from shutil import rmtree
10- import sys
11-
12- from setuptools import Command , find_packages , setup
7+ from setuptools import find_packages , setup
138
149# Package meta-data.
1510NAME = "catalyst-codestyle"
2015AUTHOR = "Sergey Kolesnikov"
2116REQUIRES_PYTHON = ">=3.6.0"
2217
23- PROJECT_ROOT = os . path . abspath ( os . path . dirname ( __file__ ) )
18+ PROJECT_ROOT = Path ( __file__ ). parent . resolve ( )
2419
2520
26- def load_requirements (filename ) :
21+ def load_requirements (filename : Union [ Path , str ] = "requirements.txt" ) -> Iterable [ str ] :
2722 """Load package requirements."""
28- with open (os . path . join ( PROJECT_ROOT , filename ), "r" ) as f :
23+ with open (PROJECT_ROOT / filename ) as f :
2924 return f .read ().splitlines ()
3025
3126
32- def load_readme () :
27+ def load_readme (filename : Union [ Path , str ] = "README.md" ) -> str :
3328 """Load package readme."""
34- readme_path = os .path .join (PROJECT_ROOT , "README.md" )
35- with io .open (readme_path , encoding = "utf-8" ) as f :
29+ with open (PROJECT_ROOT / filename , encoding = "utf-8" ) as f :
3630 return f"\n { f .read ()} "
3731
3832
39- class UploadCommand (Command ):
40- """Support setup.py upload."""
41-
42- description = "Build and publish the package."
43- user_options = []
44-
45- @staticmethod
46- def status (s ):
47- """Prints things in bold."""
48- print (f"\033 [1m{ s } \033 [0m" )
49-
50- def initialize_options (self ):
51- """@TODO: Docs. Contribution is welcome"""
52- pass
53-
54- def finalize_options (self ):
55- """@TODO: Docs. Contribution is welcome"""
56- pass
57-
58- def run (self ):
59- """Run upload command."""
60- try :
61- self .status ("Removing previous builds…" )
62- rmtree (os .path .join (PROJECT_ROOT , "dist" ))
63- except OSError :
64- pass
65-
66- self .status ("Building Source and Wheel (universal) distribution…" )
67- os .system (f"{ sys .executable } setup.py sdist bdist_wheel --universal" ) # noqa: E501, S605
68-
69- self .status ("Uploading the package to PyPI via Twine…" )
70- os .system ("twine upload dist/*" ) # noqa: S605, S607
71-
72- self .status ("Pushing git tags…" )
73- os .system (f"git tag v{ VERSION } " ) # noqa: S605
74- os .system ("git push --tags" ) # noqa: S605, S607
75-
76- sys .exit ()
77-
78-
7933setup (
8034 name = NAME ,
8135 version = VERSION ,
@@ -92,14 +46,14 @@ def run(self):
9246 "Documentation" : "https://catalyst-team.github.io/catalyst" ,
9347 "Source Code" : "https://github.com/catalyst-team/codestyle" ,
9448 },
95- packages = find_packages (exclude = ("tests" , )),
49+ packages = find_packages (exclude = ("tests" ,)),
9650 scripts = [
9751 "bin/catalyst-check-codestyle" ,
9852 "bin/catalyst-make-codestyle" ,
9953 "bin/catalyst-codestyle-flake8" ,
10054 "bin/catalyst-codestyle-isort" ,
10155 ],
102- install_requires = load_requirements ("requirements.txt" ),
56+ install_requires = load_requirements (),
10357 include_package_data = True ,
10458 license = "Apache License 2.0" ,
10559 classifiers = [
@@ -115,10 +69,8 @@ def run(self):
11569 "Programming Language :: Python" ,
11670 "Programming Language :: Python :: 3.6" ,
11771 "Programming Language :: Python :: 3.7" ,
72+ "Programming Language :: Python :: 3.8" ,
73+ "Programming Language :: Python :: 3.9" ,
11874 "Programming Language :: Python :: Implementation :: CPython" ,
11975 ],
120- # $ setup.py publish support.
121- cmdclass = {
122- "upload" : UploadCommand ,
123- },
12476)
0 commit comments