From d8c69901d3ccbaa504da450f0e65db515681c300 Mon Sep 17 00:00:00 2001 From: KmolYuan Date: Fri, 12 Feb 2021 14:21:07 +0800 Subject: [PATCH] Apply PEP 517. --- cython/MANIFEST.in | 2 +- cython/README.md | 5 ++- cython/platform/set_pycompiler.bat | 5 ++- cython/pyproject.toml | 3 ++ cython/requirements.txt | 1 - cython/setup.cfg | 46 +++++++++++++++++++++ cython/setup.py | 66 ++++++------------------------ 7 files changed, 69 insertions(+), 59 deletions(-) create mode 100644 cython/pyproject.toml delete mode 100644 cython/requirements.txt create mode 100644 cython/setup.cfg diff --git a/cython/MANIFEST.in b/cython/MANIFEST.in index 048558b4..400ce882 100644 --- a/cython/MANIFEST.in +++ b/cython/MANIFEST.in @@ -1,3 +1,3 @@ -include requirements.txt +include pyproject.toml setup.cfg include README.md recursive-include . *.h *.c diff --git a/cython/README.md b/cython/README.md index e511a5bb..1c0454ec 100644 --- a/cython/README.md +++ b/cython/README.md @@ -21,7 +21,10 @@ pip install python-solvespace Build and install the module: ```bash -python setup.py install +pip install python-solvespace +# From repository +git submodule update --init +pip install -e . ``` Run unit tests: diff --git a/cython/platform/set_pycompiler.bat b/cython/platform/set_pycompiler.bat index 3e42cf8a..8b8513ef 100644 --- a/cython/platform/set_pycompiler.bat +++ b/cython/platform/set_pycompiler.bat @@ -16,8 +16,9 @@ echo compiler=%COMPILER%>> "%DISTUTILS%" echo patched file "%DISTUTILS%" REM Apply the patch of "cygwinccompiler.py". REM Unix "patch" command of Msys. -patch -N "%PYTHON_DIR%\lib\distutils\cygwinccompiler.py" "%HERE%\cygwinccompiler.diff" -patch -N "%PYTHON_DIR%\include\pyconfig.h" "%HERE%\pyconfig.diff" +set patch="C:\Program Files\Git\usr\bin\patch.exe" +%patch% -N "%PYTHON_DIR%\lib\distutils\cygwinccompiler.py" "%HERE%\cygwinccompiler.diff" +%patch% -N "%PYTHON_DIR%\include\pyconfig.h" "%HERE%\pyconfig.diff" REM Copy "vcruntime140.dll" to "libs". copy "%PYTHON_DIR%\vcruntime140.dll" "%PYTHON_DIR%\libs" diff --git a/cython/pyproject.toml b/cython/pyproject.toml new file mode 100644 index 00000000..10376dcb --- /dev/null +++ b/cython/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["wheel", "setuptools"] +build-backend = "setuptools.build_meta" diff --git a/cython/requirements.txt b/cython/requirements.txt deleted file mode 100644 index f6629e02..00000000 --- a/cython/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -cython diff --git a/cython/setup.cfg b/cython/setup.cfg new file mode 100644 index 00000000..06d6d07f --- /dev/null +++ b/cython/setup.cfg @@ -0,0 +1,46 @@ +[metadata] +name = python_solvespace +version = attr: python_solvespace.__version__ +description = Python library of Solvespace. +long_description = file: README.md +long_description_content_type = text/markdown +keywords = cad,mechanical-engineering,2d,3d +license = GPLv3+ +author = Yuan Chang +author_email = pyslvs@gmail.com +url = https://github.com/KmolYuan/solvespace +classifiers = + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Cython + Topic :: Scientific/Engineering + License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) + Operating System :: OS Independent + Typing :: Typed + +[options] +zip_safe = False +packages = find: +python_requires = >=3.6 +setup_requires = + cython + +[options.package_data] +* = *.pyi, *.pxd, *.pyx +python_solvespace = py.typed + +[options.packages.find] +exclude = + test + +[mypy] +pretty = True +show_error_codes = True +show_column_numbers = True +ignore_missing_imports = True +allow_redefinition = True +warn_redundant_casts = True +warn_unreachable = True +strict_equality = True diff --git a/cython/setup.py b/cython/setup.py index 4627a8df..9cddb0b6 100644 --- a/cython/setup.py +++ b/cython/setup.py @@ -10,9 +10,7 @@ __email__ = "pyslvs@gmail.com" import sys from os import walk from os.path import dirname, isdir, join -import re -import codecs -from setuptools import setup, Extension, find_packages +from setuptools import setup, Extension from setuptools.command.build_ext import build_ext from setuptools.command.sdist import sdist from distutils import file_util, dir_util @@ -27,25 +25,6 @@ mimalloc_path = join(extlib_path, 'mimalloc') mimalloc_include_path = join(mimalloc_path, 'include') mimalloc_src_path = join(mimalloc_path, 'src') build_dir = 'build' - - -def write(doc, *parts): - with codecs.open(join(*parts), 'w') as f: - f.write(doc) - - -def read(*parts): - with codecs.open(join(*parts), 'r') as f: - return f.read() - - -def find_version(*file_paths): - m = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", read(*file_paths), re.M) - if m: - return m.group(1) - raise RuntimeError("Unable to find version string.") - - macros = [ ('M_PI', 'PI'), ('_USE_MATH_DEFINES', None), @@ -90,8 +69,9 @@ mimalloc_sources = [ join(mimalloc_src_path, 'stats.c'), join(mimalloc_src_path, 'random.c'), join(mimalloc_src_path, 'os.c'), + join(mimalloc_src_path, 'bitmap.c'), join(mimalloc_src_path, 'arena.c'), - join(mimalloc_src_path, 'region.c'), + join(mimalloc_src_path, 'segment-cache.c'), join(mimalloc_src_path, 'segment.c'), join(mimalloc_src_path, 'page.c'), join(mimalloc_src_path, 'alloc.c'), @@ -139,6 +119,7 @@ def copy_source(dry_run): class Build(build_ext): + def build_extensions(self): compiler = self.compiler.compiler_type for e in self.extensions: @@ -178,6 +159,7 @@ class Build(build_ext): class PackSource(sdist): + def run(self): copy_source(self.dry_run) super(PackSource, self).run() @@ -187,34 +169,10 @@ class PackSource(sdist): dir_util.remove_tree(extlib_path, dry_run=self.dry_run) -setup( - name="python_solvespace", - version=find_version(m_path, '__init__.py'), - author=__author__, - author_email=__email__, - description="Python library of Solvespace.", - long_description=read("README.md"), - long_description_content_type='text/markdown', - url="https://github.com/KmolYuan/solvespace", - packages=find_packages(exclude=('test',)), - package_data={'': ["*.pyi", "*.pxd"], 'python_solvespace': ['py.typed']}, - ext_modules=[Extension( - "python_solvespace.slvs", - sources, - language="c++", - include_dirs=[include_path, src_path, mimalloc_include_path, mimalloc_src_path] - )], - cmdclass={'build_ext': Build, 'sdist': PackSource}, - zip_safe=False, - python_requires=">=3.6", - install_requires=read('requirements.txt').splitlines(), - test_suite='test', - classifiers=[ - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Cython", - "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", - "Operating System :: OS Independent", - ] -) +setup(ext_modules=[Extension( + "python_solvespace.slvs", + sources, + language="c++", + include_dirs=[include_path, src_path, mimalloc_include_path, + mimalloc_src_path] +)], cmdclass={'build_ext': Build, 'sdist': PackSource})