From 513ee743a2f633ed01486621b4684c0608d34219 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Wed, 23 Jun 2021 00:38:41 +0200 Subject: pyGHDL: handle requirements files with comments and/or git URLs (cherry picked from commit 8bb020fb4481e1d21ccf64470ddf1838024732cb) --- setup.py | 159 ++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 91 insertions(+), 68 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 75e04bb3a..26bd54181 100644 --- a/setup.py +++ b/setup.py @@ -33,89 +33,112 @@ # SPDX-License-Identifier: GPL-2.0-or-later # ============================================================================ -from pathlib import Path -from re import compile as re_compile -from setuptools import setup as setuptools_setup, find_packages as setuptools_find_packages +from pathlib import Path +from re import compile as re_compile +from setuptools import ( + setup as setuptools_setup, + find_packages as setuptools_find_packages, +) gitHubNamespace = "ghdl" projectName = "ghdl" packageName = "pyGHDL" packagePath = Path(packageName) -# Read (local) README for upload to PyPI readmeFile = packagePath / "README.md" -with readmeFile.open("r") as file: - long_description = file.read() +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 -requirementsFile = packagePath / "requirements.txt" -with requirementsFile.open("r") as file: - requirements = [line for line in file.readlines()] +def get_requirements(file: Path) -> List[str]: + requirements = [] + with file.open("r") as fh: + for line in fh.readlines(): + if line.startswith("#"): + continue + elif line.startswith("git+"): + _splitItems = line.split("#") + requirements.append( + "{} @ {}".format(_splitItems[1].strip(), _splitItems[0]) + ) + else: + requirements.append(line.strip()) + 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: - pass + # 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: + pass + + raise Exception("Cannot find version") - 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) +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 + ) +) # 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", - description="Python binding for GHDL and high-level APIs (incl. LSP).", - long_description=long_description, - 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" - ] - }, - - keywords="Python3 VHDL Parser Compiler Simulator GHDL", - 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", - ] + name=packageName, + version=get_version(), + author="Tristan Gingold", + author_email="tgingold@free.fr", + license="GPL-2.0-or-later", + 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=get_requirements(requirementsFile), + packages=setuptools_find_packages(exclude=("tests",)), + entry_points={ + "console_scripts": [ + "ghdl-ls = pyGHDL.cli.lsp:main", + "ghdl-dom = pyGHDL.cli.DOM:main", + ] + }, + keywords="Python3 VHDL Parser Compiler Simulator GHDL", + 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 66425e5257c9cec2bdc428b761d59d887564daf6 Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Wed, 23 Jun 2021 01:18:13 +0200 Subject: Better type handling. --- setup.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 26bd54181..32acf3456 100644 --- a/setup.py +++ b/setup.py @@ -35,6 +35,8 @@ 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, -- cgit v1.2.3 From d97e2079a633736d0323e915cabff5f91cfd4ebe Mon Sep 17 00:00:00 2001 From: umarcor Date: Wed, 23 Jun 2021 02:54:57 +0200 Subject: setup.py: get a zipfile instead of using git (cherry picked from commit 541815223c0df0fb2cdd227d3ca9e5a82135dc28) --- setup.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 32acf3456..330247011 100644 --- a/setup.py +++ b/setup.py @@ -64,11 +64,9 @@ def get_requirements(file: Path) -> List[str]: for line in fh.readlines(): if line.startswith("#"): continue - elif line.startswith("git+"): - _splitItems = line.split("#") - requirements.append( - "{} @ {}".format(_splitItems[1].strip(), _splitItems[0]) - ) + elif line.startswith("https"): + _splitItems = line.strip().split("#") + requirements.append("{} @ {}".format(_splitItems[1], _splitItems[0])) else: requirements.append(line.strip()) return requirements @@ -135,7 +133,7 @@ setuptools_setup( "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Development Status :: 4 - Beta", - # "Development Status :: 5 - Production/Stable", + # "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)", "Topic :: Software Development :: Code Generators", -- cgit v1.2.3