From b6dcce607c96ce751fc3bb9aef45848c94e0e71e Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 12 Dec 2021 14:46:00 +0100 Subject: Updated setup.py to use pyTooling.Packaging. --- setup.py | 117 ++++++++------------------------------------------------------- 1 file changed, 14 insertions(+), 103 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index f61a0f2a4..e1789c3db 100644 --- a/setup.py +++ b/setup.py @@ -32,121 +32,32 @@ # # SPDX-License-Identifier: GPL-2.0-or-later # ============================================================================ +# +from pathlib import Path +from pyTooling.Packaging import DescribePythonPackageHostedOnGitHub -from pathlib import Path -from re import compile as re_compile -from typing import List - -from setuptools import ( - setup as setuptools_setup, - find_packages as setuptools_find_packages, -) - -gitHubNamespace = "ghdl" -projectName = "ghdl" -packageName = "pyGHDL" -packagePath = Path(packageName) - -readmeFile = packagePath / "README.md" -requirementsFile = packagePath / "requirements.txt" - - -# Read (local) README for upload to PyPI -def get_description(file: Path) -> str: - with file.open("r") as fh: - description = fh.read() - return description - - -# Read requirements file and add them to package dependency list -def get_requirements(file: Path) -> List[str]: - requirements = [] - with file.open("r") as fh: - for line in fh.read().splitlines(): - if line.startswith("#") or line == "": - continue - elif line.startswith("-r"): - # Remove the first word/argument (-r) - filename = " ".join(line.split(" ")[1:]) - requirements += get_requirements(file.parent / filename) - elif line.startswith("https"): - # Convert 'URL#NAME' to 'NAME @ URL' - splitItems = line.split("#") - requirements.append("{} @ {}".format(splitItems[1], splitItems[0])) - else: - requirements.append(line) - return requirements - - -def get_version(): - # Try from version.py. Reads it to avoid loading the shared library. - pattern = re_compile('^__version__ = "(.*)"\n') - try: - line = open("pyGHDL/libghdl/version.py").read() - match = pattern.match(line) - if match: - return match.group(1) - except Exception: - pass - - raise Exception("Cannot find version") - - -# Derive URLs -sourceCodeURL = "https://github.com/{namespace}/{projectName}".format( - namespace=gitHubNamespace, projectName=projectName -) -documentationURL = ( - "https://{namespace}.github.io/{projectName}/using/py/index.html".format( - namespace=gitHubNamespace, projectName=projectName - ) -) -requirements = list(set(get_requirements(requirementsFile))) - +gitHubNamespace = "ghdl" +packageName = "pyGHDL" +packageDirectory = packageName +packageInformationFile = Path(f"{packageDirectory}/__init__.py") -# Assemble all package information -setuptools_setup( - name=packageName, - version=get_version(), - author="Tristan Gingold", - author_email="tgingold@free.fr", - license="GPL-2.0-or-later", +DescribePythonPackageHostedOnGitHub( + packageName=packageName, description="Python binding for GHDL and high-level APIs (incl. LSP).", - long_description=get_description(readmeFile), - long_description_content_type="text/markdown", - url=sourceCodeURL, - project_urls={ - "Documentation": documentationURL, - "Source Code": sourceCodeURL, - "Issue Tracker": sourceCodeURL + "/issues", - }, - python_requires=">=3.6", - install_requires=requirements, - packages=setuptools_find_packages(exclude=("tests",)), - entry_points={ - "console_scripts": [ - "ghdl-ls = pyGHDL.cli.lsp:main", - "ghdl-dom = pyGHDL.cli.dom:main", - ] - }, + license="GPL-2.0-or-later", + gitHubNamespace=gitHubNamespace, keywords="Python3 VHDL Parser Compiler Simulator GHDL", + sourceFileWithVersion=packageInformationFile, + developmentStatus="beta", classifiers=[ - "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", "Operating System :: MacOS", "Operating System :: Microsoft :: Windows :: Windows 10", "Operating System :: POSIX :: Linux", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Development Status :: 4 - Beta", - # "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)", "Topic :: Software Development :: Code Generators", "Topic :: Software Development :: Compilers", "Topic :: Software Development :: Testing", "Topic :: Utilities", - ], + ] ) -- cgit v1.2.3 From e88ad9e4a10a60679b10a285029e05b0184eeef0 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Sun, 12 Dec 2021 14:56:55 +0100 Subject: Adjusted configure script. --- setup.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index e1789c3db..8e4b687a1 100644 --- a/setup.py +++ b/setup.py @@ -36,10 +36,11 @@ from pathlib import Path from pyTooling.Packaging import DescribePythonPackageHostedOnGitHub -gitHubNamespace = "ghdl" -packageName = "pyGHDL" -packageDirectory = packageName +gitHubNamespace = "ghdl" +packageName = "pyGHDL" +packageDirectory = packageName packageInformationFile = Path(f"{packageDirectory}/__init__.py") +requirementsFile = Path(f"{packageDirectory}/requirements.txt") DescribePythonPackageHostedOnGitHub( packageName=packageName, @@ -48,6 +49,7 @@ DescribePythonPackageHostedOnGitHub( gitHubNamespace=gitHubNamespace, keywords="Python3 VHDL Parser Compiler Simulator GHDL", sourceFileWithVersion=packageInformationFile, + requirementsFile=requirementsFile, developmentStatus="beta", classifiers=[ "Operating System :: MacOS", -- cgit v1.2.3 From 7c35000d5d3704d939133964a92fc7e4b2d361d0 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Mon, 13 Dec 2021 21:01:21 +0100 Subject: Fixed license in `setup.py`. --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 8e4b687a1..b834152ad 100644 --- a/setup.py +++ b/setup.py @@ -34,6 +34,7 @@ # ============================================================================ # from pathlib import Path +from pyTooling.Licensing import GPL_2_0_or_later from pyTooling.Packaging import DescribePythonPackageHostedOnGitHub gitHubNamespace = "ghdl" @@ -45,9 +46,8 @@ requirementsFile = Path(f"{packageDirectory}/requirements.txt") DescribePythonPackageHostedOnGitHub( packageName=packageName, description="Python binding for GHDL and high-level APIs (incl. LSP).", - license="GPL-2.0-or-later", + license=GPL_2_0_or_later, gitHubNamespace=gitHubNamespace, - keywords="Python3 VHDL Parser Compiler Simulator GHDL", sourceFileWithVersion=packageInformationFile, requirementsFile=requirementsFile, developmentStatus="beta", -- cgit v1.2.3 From 8a48be3f32e08eadc25b08d0929a9e117d8a94aa Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Tue, 14 Dec 2021 08:34:50 +0100 Subject: Added entry points. --- setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index b834152ad..085d7f8e4 100644 --- a/setup.py +++ b/setup.py @@ -61,5 +61,9 @@ DescribePythonPackageHostedOnGitHub( "Topic :: Software Development :: Compilers", "Topic :: Software Development :: Testing", "Topic :: Utilities", - ] + ], + consoleScripts={ + "ghdl-ls": "pyGHDL.cli.lsp:main", + "ghdl-dom": "pyGHDL.cli.dom:main" + } ) -- cgit v1.2.3