diff --git a/.black.toml b/.black.toml index 9414fb7..bedc251 100644 --- a/.black.toml +++ b/.black.toml @@ -1,6 +1,6 @@ [tool.black] line-length = 120 -target-version = ['py36', 'py37', 'py38'] +target-version = ['py37', 'py38', 'py39', 'py310', 'py311'] exclude = ''' /( \.eggs diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 9f0cd6e..f7d8c27 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -23,15 +23,8 @@ jobs: - name: Install Dependencies run: | python -m pip install --upgrade pip - pip install poetry --upgrade - poetry config virtualenvs.create false --local + pip install setuptools wheel twine --upgrade - - name: Poetry Install - run: poetry install --with dev - continue-on-error: true - - - name: Poetry Install 2 - run: poetry install --with dev - name: Build and Publish env: @@ -39,38 +32,56 @@ jobs: TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - poetry build + python setup.py sdist bdist_wheel twine upload dist/* deploy-cython: strategy: matrix: - os: [ ubuntu-latest, macos-12, windows-latest ] + os: [macos-11, windows-latest] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.11 - uses: actions/setup-python@v4 - with: - python-version: "3.11" - - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - python -m pip install cibuildwheel twine --upgrade - - - name: Build Wheels - env: - CIBW_SKIP: "cp36-* pp* *i686" - CIBW_BUILD_VERBOSITY: 1 - CIBW_TEST_REQUIRES: "pytest msgpack ruamel.yaml tomli tomli-w" - CIBW_TEST_COMMAND: "pytest {package}/test" - run: python -m cibuildwheel --output-dir wheels - - - name: Publish Wheels - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - twine upload wheels/* + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine Cython --upgrade + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py bdist_wheel + twine upload dist/* + + deploy-cython-manylinux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - uses: RalfG/python-wheels-manylinux-build@v0.7.1-manylinux2010_x86_64 + with: + python-versions: 'cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310' + build-requirements: 'cython' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install twine --upgrade + + - name: Publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + twine upload dist/*-manylinux*.whl diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d40f647..35eff83 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,117 +10,122 @@ on: branches: [ master, development, develop, test, tests ] jobs: - build-checks: + package-checks: strategy: matrix: - os: [ubuntu-latest, macos-12, windows-latest] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "pypy-3.8"] + os: [ubuntu-latest, macos-11, windows-latest] runs-on: ${{ matrix.os }} - steps: - uses: actions/checkout@v3 - - - name: Set up Python 3.11 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: - python-version: "3.11" - - - name: Build Wheels - env: - CIBW_SKIP: "cp36-* pp* *i686" - CIBW_BUILD_VERBOSITY: 1 - CIBW_TEST_REQUIRES: "pytest msgpack ruamel.yaml tomli tomli-w" - CIBW_TEST_COMMAND: "pytest {package}/test" + python-version: ${{ matrix.python-version }} + - uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: package-check-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-test.txt') }} + - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install cibuildwheel --upgrade - python -m cibuildwheel --output-dir wheels - + pip install -r requirements.txt + pip install -r requirements-test.txt + pip install coveralls flake8 flake8-print mypy setuptools wheel twine Cython + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors, undefined names or print statements + flake8 box --count --select=E9,F63,F7,F82,T001,T002,T003,T004 --show-source --statistics + # exit-zero treats all errors as warnings. + flake8 . --count --exit-zero --max-complexity=20 --max-line-length=120 --statistics --extend-ignore E203 + - name: Run mypy + run: mypy box + - name: Build Wheel and check distribution log description + run: | + python setup.py sdist bdist_wheel + twine check dist/* + - name: Test packaged wheel on *nix + if: matrix.os != 'windows-latest' + run: | + pip install dist/*.whl + rm -rf box + python -m pytest + - name: Test packaged wheel on Windows + if: matrix.os == 'windows-latest' + run: | + $wheel = (Get-ChildItem dist\*.whl | Sort lastWriteTime | Select-Object -last 1).Name + pip install dist\${wheel} + Remove-item box -recurse -force + python -m pytest - name: Upload wheel artifact uses: actions/upload-artifact@v2 with: name: python_box - path: wheels/*.whl + path: dist/*.whl - lint-and-mypy: + package-manylinux-checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - - name: Set up Python 3.11 - uses: actions/setup-python@v4 - with: - python-version: "3.11" - - - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: lint-and-mypy-${{ hashFiles('pyproject.toml') }} - - - name: Install Dependencies - run: | - python -m pip install poetry --upgrade - poetry config virtualenvs.create false --local + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" - - name: Poetry Install - run: poetry install --with dev - continue-on-error: true + - uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: package-manylinux-check-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-test.txt') }} - - name: Poetry Install 2 - run: poetry install --with dev + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -r requirements-test.txt + pip install coveralls flake8 flake8-print mypy setuptools wheel twine Cython - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors, undefined names or print statements - python -m flake8 box --count --select=E9,F63,F7,F82,T001,T002,T003,T004 --show-source --statistics - # exit-zero treats all errors as warnings. - python -m flake8 . --count --exit-zero --max-complexity=20 --max-line-length=120 --statistics --extend-ignore E203 + - uses: RalfG/python-wheels-manylinux-build@v0.7.1-manylinux2010_x86_64 + with: + python-versions: 'cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310' + build-requirements: 'cython' - - name: Run mypy - run: python -m mypy box + - name: Test packaged wheel on linux + run: | + pip install dist/*cp310-manylinux*.whl + rm -rf box + python -m pytest - - name: Build Wheel and Check Distribution Log Description - run: | - poetry build - python -m twine check dist/* + - name: Upload wheel artifact + uses: actions/upload-artifact@v2 + with: + name: python_box + path: dist/*-manylinux*.whl - test-non-cython: + test: strategy: matrix: python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-11, windows-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - - uses: actions/cache@v2 + - uses: actions/cache@v3 with: path: ~/.cache/pip - key: test-${{ hashFiles('pyproject.toml') }} - - - name: Install Dependencies + key: test-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-test.txt') }} + - name: Install dependencies run: | python -m pip install --upgrade pip - pip install poetry --upgrade - poetry config virtualenvs.create false --local - - - name: Poetry Install - run: poetry install --with dev --with test - continue-on-error: true - - - name: Poetry Install 2 - run: poetry install --with dev --with test - - - name: Poetry Build - run: poetry build - continue-on-error: true - + pip install -r requirements.txt + pip install -r requirements-test.txt + pip install setuptools wheel Cython + python setup.py build_ext --inplace - name: Test with pytest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - python -m pytest --cov=box test/ + pytest --cov=box test/ diff --git a/.gitignore b/.gitignore index e75de53..a9543e8 100644 --- a/.gitignore +++ b/.gitignore @@ -97,3 +97,7 @@ coverage/ # don't upload cython files box/*.c .pytest_cache/ + +box/*.rst +box/LICENSE +box/*png diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a9ab210..2fc0ba4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: exclude: ^test/data/.+ - repo: https://github.com/ambv/black - rev: 22.12.0 + rev: 23.1.0 hooks: - id: black args: [--config=.black.toml] @@ -38,7 +38,7 @@ repos: hooks: - id: cythonize-check name: Cythonize - entry: python -m poetry build + entry: pip install -e . language: system types: [python] pass_filenames: false @@ -51,7 +51,7 @@ repos: always_run: true - repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v0.991' + rev: 'v1.0.1' hooks: - id: mypy types: [python] diff --git a/CHANGES.rst b/CHANGES.rst index 681554b..eb7921b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,11 @@ Changelog ========= +Version 7.0.1 +------------- + +* Switching off of poetry due to multiple build issues + Version 7.0.0 ------------- diff --git a/box/__init__.py b/box/__init__.py index a1795a1..b2225bb 100644 --- a/box/__init__.py +++ b/box/__init__.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- __author__ = "Chris Griffith" -__version__ = "7.0.0" +__version__ = "7.0.1" from box.box import Box from box.box_list import BoxList diff --git a/build.py b/build.py deleted file mode 100644 index 1ca7ea0..0000000 --- a/build.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import os -from distutils.command.build_ext import build_ext - -from pathlib import Path - -root = os.path.abspath(os.path.dirname(__file__)) - -try: - from Cython.Build import cythonize -except ImportError: - # Got to provide this function. Otherwise, poetry will fail - def build(setup_kwargs): - pass - - -# Cython is installed. Compile -else: - # This function will be executed in setup.py: - def build(setup_kwargs): - # Build - setup_kwargs.update( - { - "ext_modules": cythonize( - [ - str(file.relative_to(root)) - for file in Path(root, "box").glob("*.py") - if file.name != "__init__.py" - ], - compiler_directives={"language_level": 3}, - ), - } - ) diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index dd9cda5..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,97 +0,0 @@ -[tool.black] -line-length = 120 -target-version = ['py37', 'py38', 'py39', 'py310', 'py311'] -exclude = ''' -/( - \.eggs - | \.git - | \.idea - | \.pytest_cache - | _build - | build - | dist - | venv -)/ -''' - -[tool.poetry] -name = "python-box" -version = "7.0.0" -description = "Advanced Python dictionaries with dot notation access" -license = "MIT" -authors = ["Chris Griffith ", ] -include = ["box_logo.png", "AUTHORS.rst", "CHANGES.rst", "LICENSE"] -readme = "README.rst" -repository = "https://github.com/cdgriffith/Box" -build = "build.py" -packages = [ { include = "box" }] -classifiers = [ - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "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 :: Implementation :: CPython", - "Development Status :: 5 - Production/Stable", - "Natural Language :: English", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - "Topic :: Utilities", - "Topic :: Software Development", - "Topic :: Software Development :: Libraries :: Python Modules" -] - -[tool.poetry.dependencies] -python = ">=3.7" -msgpack = {version = ">=1.0.0", optional = true} -"ruamel.yaml" = {version = ">=0.17", optional = true} -tomli = {version = ">=1.2.3", python = '<3.11', optional = true} -tomli-w = {version = ">=1.0.0", optional = true} -PyYAML = {version = ">=6.0", optional = true} -toml = {version = ">=0.10.2", optional = true} - -[tool.poetry.group.dev] -optional = true - -[tool.poetry.group.dev.dependencies] -black = ">=22.10.0" -Cython = ">=0.29" -pre-commit = ">=2.20" -coveralls = ">=3.3.1" -flake8 = ">=5.0.4" -flake8-print = ">=5.0.0" -mypy = ">=0.991" -setuptools = ">=67.0.0" -wheel = ">=0.38.4" -twine = ">=4.0.2" - -[tool.poetry.group.test] -optional = true - -[tool.poetry.group.test.dependencies] -coverage = ">=5.0.4" -pytest = ">=7.1.3" -pytest-cov = ">=2.8.1" -msgpack = ">=1.0.0" -"ruamel.yaml" =">=0.17" -tomli = {version = ">=1.2.3", python = '<3.11'} -tomli-w = ">=1.0.0" -types-PyYAML = ">=6.0.3" -wheel = ">=0.34.2" - - -[tool.poetry.extras] -all = ["ruamel.yaml", "tomli", "tomli-w", "msgpack"] -yaml = ["ruamel.yaml"] -"ruamel.yaml" = ["ruamel.yaml"] -PyYAML = ["PyYAML"] -tomli = ["tomli", "tomli-w"] -toml = ["toml"] -msgpack= ["msgpack"] - -[build-system] -requires = ["poetry>=0.12", "Cython", "setuptools", "wheel"] -build-backend = "poetry.masonry.api" diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..cb6ad4c --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,5 @@ +# Files needed for pre-commit hooks +black>=23.1.0 +Cython>=0.29 +mypy>=1.0.1 +pre-commit>=2.21.0 diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 0000000..1296ffa --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,9 @@ +coverage>=5.0.4 +msgpack>=1.0 +pytest>=7.1.3 +pytest-cov>=2.8.1 +ruamel.yaml>=0.17 +tomli>=1.2.3; python_version < '3.11' +tomli-w>=1.0.0 +types-PyYAML>=6.0.3 +wheel>=0.34.2 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..57e2f36 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +msgpack>=1.0.0 +ruamel.yaml>=0.17 +tomli>=1.2.3; python_version < '3.11' +tomli-w diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..0f0519e --- /dev/null +++ b/setup.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Must import multiprocessing as a fix for issues with testing, experienced on win10 +import multiprocessing # noqa: F401 +import os +import re +from pathlib import Path +import sys +import shutil + +from setuptools import setup + +root = os.path.abspath(os.path.dirname(__file__)) + +try: + from Cython.Build import cythonize +except ImportError: + extra = None +else: + extra = cythonize( + [str(file.relative_to(root)) for file in Path(root, "box").glob("*.py") if file.name != "__init__.py"], + compiler_directives={"language_level": 3}, + ) + +with open(os.path.join(root, "box", "__init__.py"), "r") as init_file: + init_content = init_file.read() + +attrs = dict(re.findall(r"__([a-z]+)__ *= *['\"](.+)['\"]", init_content)) + +with open("README.rst", "r") as readme_file: + long_description = readme_file.read() + +setup( + name="python-box", + version=attrs["version"], + url="https://github.com/cdgriffith/Box", + license="MIT", + author=attrs["author"], + install_requires=[], + author_email="chris@cdgriffith.com", + description="Advanced Python dictionaries with dot notation access", + long_description=long_description, + long_description_content_type="text/x-rst", + py_modules=["box"], + packages=["box"], + ext_modules=extra, + python_requires=">=3.7", + include_package_data=True, + platforms="any", + 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 :: Implementation :: CPython", + "Development Status :: 5 - Production/Stable", + "Natural Language :: English", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Topic :: Utilities", + "Topic :: Software Development", + "Topic :: Software Development :: Libraries :: Python Modules", + ], + extras_require={ + "all": ["ruamel.yaml>=0.17", "toml", "msgpack"], + "yaml": ["ruamel.yaml>=0.17"], + "ruamel.yaml": ["ruamel.yaml>=0.17"], + "PyYAML": ["PyYAML"], + "tomli": ["tomli; python_version < '3.11'", "tomli-w"], + "toml": ["toml"], + "msgpack": ["msgpack"], + }, +) + +if not extra: + print("WARNING: Cython not installed, could not optimize box.", file=sys.stderr)