Add package version option to mkpkg command (#661)

This commit is contained in:
Frithjof 2020-05-19 22:38:41 +01:00 committed by GitHub
parent 9f9a6c3965
commit 163ab43b64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -36,10 +36,11 @@ def get_sdist_url_entry(json_content):
)) ))
def make_package(package): def make_package(package, version=None):
import yaml import yaml
url = f'https://pypi.org/pypi/{package}/json' version = ('/' + version) if version is not None else ''
url = f"https://pypi.org/pypi/{package}{version}/json"
with urllib.request.urlopen(url) as fd: with urllib.request.urlopen(url) as fd:
json_content = json.load(fd) json_content = json.load(fd)
@ -79,12 +80,16 @@ complex things.'''.strip()
parser.add_argument( parser.add_argument(
'package', type=str, nargs=1, 'package', type=str, nargs=1,
help="The package name on PyPI") help="The package name on PyPI")
parser.add_argument(
'--version', type=str, default=None,
help="Package version string, "
"e.g. v1.2.1 (defaults to latest stable release)")
return parser return parser
def main(args): def main(args):
package = args.package[0] package = args.package[0]
make_package(package) make_package(package, args.version)
if __name__ == '__main__': if __name__ == '__main__':