Skip to content

Commit

Permalink
Get version from __init__ file directly
Browse files Browse the repository at this point in the history
+ Functionize the `readme_description` code snippet
  • Loading branch information
Mamdasn committed Feb 17, 2024
1 parent 8d542cd commit b48e8b2
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions setup.py
@@ -1,24 +1,33 @@
from setuptools import setup, find_packages
import codecs
import os


parent_dir = os.path.abspath(os.path.dirname(__file__))

with codecs.open(os.path.join(parent_dir, "README.md"), encoding="utf-8") as readme:
readme_description = "\n" + readme.read()
def get_version():
with open(os.path.join(parent_dir, "src", "__init__.py")) as f:
for line in f:
if line.startswith("__version__"):
return line.strip().split("=")[1].strip(" '\"")

def get_readme():
with open(os.path.join(parent_dir, "README.md"), encoding="utf-8") as readme:
readme_description = "\n" + readme.read()
return readme_description


setup(
name="im2dhist",
version="1.0.0",
author="mamdasn s",
author_email="<mamdassn@gmail.com>",
version=get_version(),
author="Mamdasan Sabrian",
author_email="<reach.s.farhad@gmail.com>",
url="https://github.com/Mamdasn/im2dhist",
description="Calculates two dimensional histogram of a given image.",
long_description=readme_description,
long_description=get_readme(),
long_description_content_type="text/markdown",
include_package_data=True,
package_dir={"": "src"},
packages=find_packages(where='src'),
py_modules=["im2dhist"],
install_requires=[
"numpy",
Expand Down

0 comments on commit b48e8b2

Please sign in to comment.