Issue
I need to get version value from setup.py or from PKG-INFO using bash and extract environment variable with the version value for later use. (Actually I need version value for GitHub Action)
from setuptools import setup, find_packages
with open("README.md", "r") as fh:
long_description = fh.read()
setup(
name="helloworld",
version="0.0.3",
author="John",
author_email="[email protected]",
url="https://github.com/google/helloworld",
description="Hello World!",
long_description=long_description,
long_description_content_type="text/markdown",
packages=find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
install_requires=["click"],
python_requires='>=3.6',
py_modules=["helloworld"],
entry_points={"console_scripts": ["helloworld = src.main:main"]},
)
PKG-INFO:
Metadata-Version: 2.1
Name: helloworld
Version: 0.0.3
Summary: Hello World!
Home-page: https://github.com/google/helloworld
Author: John
Author-email: [email protected]
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
# helloworld
Hello World Python
...
Solution
It was easier than I though:
VERSION=$(python setup.py --version)
echo $VERSION
In the same manner you can also get the module name:
MODULE_NAME=$(python setup.py --name)
echo $MODULE_NAME
Answered By - ybonda Answer Checked By - Clifford M. (WPSolving Volunteer)