-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,6 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
.idea/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""A script for parsing out ranges from python package metadata files.""" | ||
|
||
import os | ||
import re | ||
|
||
semver_range = "" | ||
if os.path.isfile("pyproject.toml"): | ||
# ex: requires-python = ">=3.8, <3.13" | ||
pat = re.compile(r"requires-python = \"(?P<semver_range>[^\"]+)\"$") | ||
with open("pyproject.toml") as f: | ||
for line in f: | ||
if m := pat.match(line): | ||
semver_range = m.group("semver_range") | ||
if not semver_range: | ||
raise Exception("could not find `requires-python` entry in pyproject.toml") | ||
elif os.path.isfile("setup.cfg"): | ||
# ex: python_requires = >=3.8, <3.13 | ||
pat = re.compile(r"python_requires = (?P<semver_range>.+)$") | ||
with open("setup.cfg") as f: | ||
for line in f: | ||
if m := pat.match(line): | ||
semver_range = m.group("semver_range") | ||
if not semver_range: | ||
raise Exception("could not find `python_requires` entry in setup.cfg") | ||
else: | ||
raise Exception("could not find pyproject.toml nor setup.cfg") | ||
|
||
print(semver_range) |