File tree Expand file tree Collapse file tree 2 files changed +49
-5
lines changed
Expand file tree Collapse file tree 2 files changed +49
-5
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
66[project ]
77name = " table2ascii"
8- version = " 1.1.1 "
8+ version = " 1.1.2 "
99authors = [{name = " Jonah Lawrence" , email = " jonah@freshidea.com" }]
1010description = " Convert 2D Python lists into Unicode/ASCII tables"
1111readme = " README.md"
Original file line number Diff line number Diff line change 11# /usr/bin/env python
2+ import re
3+
24from setuptools import setup
35
4- setup (
5- packages = ["table2ascii" ],
6- package_data = {"table2ascii" : ["py.typed" ]},
7- )
6+
7+ def get_name ():
8+ name = ""
9+ with open ("pyproject.toml" ) as f :
10+ name = re .search (r'^name = ["\']([^"\']*)["\']' , f .read (), re .M )
11+ if not name :
12+ raise RuntimeError ("name is not set" )
13+ return name .group (1 )
14+
15+
16+ def get_version ():
17+ version = ""
18+ with open ("pyproject.toml" ) as f :
19+ version = re .search (r'^version = ["\']([^"\']*)["\']' , f .read (), re .M )
20+ if not version :
21+ raise RuntimeError ("version is not set" )
22+ return version .group (1 )
23+
24+
25+ def get_dependencies ():
26+ with open ("pyproject.toml" ) as f :
27+ dependency_match = re .search (r"^dependencies = \[([\s\S]*?)\]" , f .read (), re .M )
28+ if not dependency_match or not dependency_match .group (1 ):
29+ return []
30+ return [
31+ dependency .strip ().strip ("," ).strip ('"' )
32+ for dependency in dependency_match .group (1 ).split ("\n " )
33+ if dependency
34+ ]
35+
36+
37+ try :
38+ # check if pyproject.toml can be used to install dependencies and set the version
39+ setup (
40+ packages = [get_name ()],
41+ package_data = {get_name (): ["py.typed" ]},
42+ )
43+ except Exception :
44+ # fallback for old versions of pip/setuptools
45+ setup (
46+ name = get_name (),
47+ packages = [get_name ()],
48+ package_data = {get_name (): ["py.typed" ]},
49+ version = get_version (),
50+ install_requires = get_dependencies (),
51+ )
You can’t perform that action at this time.
0 commit comments