diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0589c88..330cffb 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -12,7 +12,7 @@ jobs: runs-on: windows-latest strategy: matrix: - python-version: ['3.8', '3.9', '3.10'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] steps: - uses: actions/checkout@master - name: Set up Python ${{ matrix.python-version }} @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8', '3.9', '3.10'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] steps: - uses: actions/checkout@master diff --git a/README.md b/README.md index ccd5482..56d6962 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ a tiny package for fast python c++ binding build. ccimport 0.2.x support python 3.5. -ccimport >= 0.3 support python 3.6-3.10. +ccimport >= 0.3 support python 3.6-3.14. ## Usage diff --git a/ccimport/__init__.py b/ccimport/__init__.py index ef076ae..3ad4a1b 100644 --- a/ccimport/__init__.py +++ b/ccimport/__init__.py @@ -1,2 +1,9 @@ from .core import ccimport -from .buildmeta import BuildMeta \ No newline at end of file +from .buildmeta import BuildMeta + +try: + from .__version__ import __version__ +except ImportError: + __version__ = "unknown" + +__all__ = ["ccimport", "BuildMeta", "__version__"] diff --git a/ccimport/buildtools/writer.py b/ccimport/buildtools/writer.py index 93e9131..6fb6171 100644 --- a/ccimport/buildtools/writer.py +++ b/ccimport/buildtools/writer.py @@ -5,7 +5,7 @@ import subprocess from collections import OrderedDict from pathlib import Path -from typing import Any, Dict, List, Optional, Tuple, Type, Union +from typing import Any, Dict, List, Optional, Union from ninja.ninja_syntax import Writer from ccimport import compat @@ -21,7 +21,11 @@ DEFAULT_MSVC_DEP_PREFIX = LOCALE_TO_MSVC_DEP_PREFIX["en"] -_LOC = locale.getdefaultlocale()[0] +try: + _LOC = locale.getlocale()[0] +except Exception: + _LOC = None + if _LOC is not None: if _LOC in LOCALE_TO_MSVC_DEP_PREFIX: DEFAULT_MSVC_DEP_PREFIX = LOCALE_TO_MSVC_DEP_PREFIX[_LOC] diff --git a/pyproject.toml b/pyproject.toml index 6de3ebe..e1f70f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,52 @@ [build-system] -requires = ["setuptools>=41.0", "wheel"] +requires = ["setuptools>=61.0", "wheel"] build-backend = "setuptools.build_meta" + +[project] +name = "ccimport" +dynamic = ["version"] +description = "a tiny package for fast python c++ binding build." +readme = "README.md" +requires-python = ">=3.6" +license = {text = "MIT"} +authors = [ + {name = "Yan Yan", email = "yanyan.sub@outlook.com"} +] +keywords = ["pybind11", "c++", "bindings", "compilation", "ninja"] +classifiers = [ + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Topic :: Software Development :: Build Tools", + "Topic :: Software Development :: Code Generators", +] +dependencies = [ + "pybind11", + "ninja", + "requests", + "importlib-metadata>=2.0; python_version < '3.8'", + "dataclasses; python_version == '3.6'", +] + +[project.urls] +Homepage = "https://github.com/FindDefinition/ccimport" +Repository = "https://github.com/FindDefinition/ccimport" +Issues = "https://github.com/FindDefinition/ccimport/issues" + +[tool.setuptools] +packages = ["ccimport", "ccimport.buildtools", "ccimport.ccpkg"] +include-package-data = true + +[tool.setuptools.dynamic] +version = {file = "version.txt"} diff --git a/setup.py b/setup.py index 5cb8426..fbedb55 100644 --- a/setup.py +++ b/setup.py @@ -1,63 +1,27 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Note: To use the 'upload' functionality of this file, you must: -# $ pip install twine +""" +Minimal setup.py for custom commands and dynamic version handling. +Most configuration has been moved to pyproject.toml. +""" -import io import os import sys from shutil import rmtree -from setuptools import Command, find_packages, setup +from setuptools import Command, setup # Package meta-data. NAME = 'ccimport' -DESCRIPTION = 'a tiny package for fast python c++ binding build.' -URL = 'https://github.com/FindDefinition/ccimport' -EMAIL = 'yanyan.sub@outlook.com' -AUTHOR = 'Yan Yan' -REQUIRES_PYTHON = '>=3.6' -VERSION = None - -# What packages are required for this module to be executed? -REQUIRED = [ - "pybind11", - "ninja", - "requests", - "importlib-metadata>=2.0; python_version < \"3.8\"", - "dataclasses; python_version == \"3.6\"", -] - -# What packages are optional? -EXTRAS = { - # 'fancy feature': ['django'], -} - -# The rest you shouldn't have to touch too much :) -# ------------------------------------------------ -# Except, perhaps the License and Trove Classifiers! -# If you do change the License, remember to change the Trove Classifier for that! here = os.path.abspath(os.path.dirname(__file__)) - -# Import the README and use it as the long-description. -# Note: this will only work if 'README.md' is present in your MANIFEST.in file! -try: - with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f: - long_description = '\n' + f.read() -except FileNotFoundError: - long_description = DESCRIPTION - -# Load the package's __version__.py module as a dictionary. -about = {} -if not VERSION: - with open('version.txt', 'r') as f: - version = f.read().strip() -else: - version = VERSION cwd = os.path.dirname(os.path.abspath(__file__)) +# Load version from version.txt +with open('version.txt', 'r') as f: + version = f.read().strip() + def _convert_build_number(build_number): parts = build_number.split(".") @@ -69,12 +33,13 @@ def _convert_build_number(build_number): raise NotImplementedError +# Handle dev version suffix from environment variable env_suffix = os.environ.get("CCIMPORT_VERSION_SUFFIX", "") if env_suffix != "": version += ".dev{}".format(_convert_build_number(env_suffix)) -version_path = os.path.join(cwd, NAME, '__version__.py') -about['__version__'] = version +# Write version to __version__.py +version_path = os.path.join(cwd, NAME, '__version__.py') with open(version_path, 'w') as f: f.write("__version__ = '{}'\n".format(version)) @@ -103,51 +68,21 @@ def run(self): except OSError: pass - self.status('Building Source and Wheel (universal) distribution...') - os.system('{0} setup.py sdist bdist_wheel --universal'.format( - sys.executable)) + self.status('Building Source and Wheel distribution...') + os.system('{0} -m build'.format(sys.executable)) self.status('Uploading the package to PyPI via Twine...') os.system('twine upload dist/*') self.status('Pushing git tags...') - os.system('git tag v{0}'.format(about['__version__'])) + os.system('git tag v{0}'.format(version)) os.system('git push --tags') sys.exit() -# Where the magic happens: +# Minimal setup call - most config is in pyproject.toml setup( - name=NAME, - version=about['__version__'], - description=DESCRIPTION, - long_description=long_description, - long_description_content_type='text/markdown', - author=AUTHOR, - author_email=EMAIL, - python_requires=REQUIRES_PYTHON, - url=URL, - packages=find_packages(exclude=('tests', )), - # If your package is a single module, use this instead of 'packages': - # py_modules=['mypackage'], - entry_points={ - 'console_scripts': [], - }, - install_requires=REQUIRED, - extras_require=EXTRAS, - include_package_data=True, - license='MIT', - classifiers=[ - # Trove classifiers - # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy' - ], - # $ setup.py publish support. cmdclass={ 'upload': UploadCommand, }, diff --git a/test/test_source_iter.py b/test/test_source_iter.py index 1ec2707..d773d17 100644 --- a/test/test_source_iter.py +++ b/test/test_source_iter.py @@ -29,7 +29,7 @@ def test_source_iter(): pair = siter.next_curly() assert pair is not None - return siter.identifiers + assert siter.identifiers def test_source_iter2():