diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 6995ca92..c73530cf 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -1,33 +1,36 @@ name: Python package on: [push, pull_request] jobs: build: runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: [3.6, 3.7, 3.8, pypy3] fail-fast: false steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -U pip coverage codecov flake8 fastimport + pip install -U pip coverage codecov flake8 fastimport mypy - name: Style checks run: | python -m flake8 + - name: Typing checks + run: | + python -m mypy dulwich - name: Build run: | python setup.py build_ext -i - name: Coverage test suite run run: | python -m coverage run -p -m unittest dulwich.tests.test_suite diff --git a/.travis.yml b/.travis.yml index 8e7713ef..5861374d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,68 +1,67 @@ language: python sudo: false cache: pip python: - - 3.5 - 3.6 - 3.7 - 3.8 - - pypy3.5 + - pypy3.6 env: - PYTHONHASHSEED=random TEST_REQUIRE="gevent greenlet geventhttpclient fastimport" PURE=false matrix: include: - python: pypy env: TEST_REQUIRE=fastimport - python: 3.7 env: TEST_REQUIRE=fastimport dist: xenial sudo: true - python: 3.8 env: TEST_REQUIRE=fastimport dist: xenial sudo: true - python: 3.8 env: TEST_REQUIRE=fastimport dist: xenial sudo: true - python: 3.6 env: PURE=true install: - - travis_retry pip install -U pip coverage codecov flake8 $TEST_REQUIRE + - travis_retry pip install -U pip coverage codecov flake8 mypy $TEST_REQUIRE script: - if [ $PURE = false ]; then python setup.py build_ext -i; fi - python -m coverage run -p -m unittest dulwich.tests.test_suite # Style - make style - make typing - if [ $PURE = true ]; then SETUP_ARGS=--pure; fi - python setup.py $SETUP_ARGS bdist_wheel after_success: - python -m coverage combine - codecov deploy: provider: pypi user: dulwich-bot password: secure: Q8DDDojBugQWzXvmmEQiU90UkVPk+OYoFZwv1H9LYpQ4u5CfwQNWpf8qXYhlGMdr/gzWaSWsqLvgWLpzfkvqS4Vyk2bO9mr+dSskfD8uwc82LiiL9CNd/NY03CjH9RaFgVMD/+exMjY/yCtlyH1jL4kjgOyNnC+x4B37CliZHcE= skip_cleanup: true skip_existing: true file_glob: true file: - dist/dulwich*.whl - dist/dulwich*.tar.gz on: tags: true repo: dulwich/dulwich diff --git a/appveyor.yml b/appveyor.yml index 3b8a4799..58d8bb52 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,80 +1,80 @@ environment: TWINE_USERNAME: "dulwich-bot" TWINE_PASSWORD: # See https://www.appveyor.com/docs/build-configuration/#secure-variables secure: e7DTu4CwOCARfN/mwA8lXQ== matrix: - - PYTHON: "C:\\Python35" - PYTHON_VERSION: "3.5.x" - PYTHON_ARCH: "32" - - - PYTHON: "C:\\Python35-x64" - PYTHON_VERSION: "3.5.x" - PYTHON_ARCH: "64" - - PYTHON: "C:\\Python36" PYTHON_VERSION: "3.6.x" PYTHON_ARCH: "32" - PYTHON: "C:\\Python36-x64" PYTHON_VERSION: "3.6.x" PYTHON_ARCH: "64" + - PYTHON: "C:\\Python37" + PYTHON_VERSION: "3.7.x" + PYTHON_ARCH: "32" + + - PYTHON: "C:\\Python37-x64" + PYTHON_VERSION: "3.7.x" + PYTHON_ARCH: "64" + install: # If there is a newer build queued for the same PR, cancel this one. # The AppVeyor 'rollout builds' option is supposed to serve the same # purpose but it is problematic because it tends to cancel builds pushed # directly to master instead of just PR builds (or the converse). # credits: JuliaLang developers. - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod ` https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | ` Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` throw "There are newer queued builds for this pull request, failing early." } - ECHO "Filesystem root:" - ps: "ls \"C:/\"" - ECHO "Installed SDKs:" - ps: "ls \"C:/Program Files/Microsoft SDKs/Windows\"" # Install Python (from the official .msi of http://python.org) and pip when # not already installed. - ps: if (-not(Test-Path($env:PYTHON))) { & appveyor\install.ps1 } # Prepend newly installed Python to the PATH of this build (this cannot be # done from inside the powershell script as it would require to restart # the parent CMD process). - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" # Check that we have the expected version and architecture for Python - "build.cmd %PYTHON%\\python.exe --version" - "build.cmd %PYTHON%\\python.exe -c \"import struct; print(struct.calcsize('P') * 8)\"" # Install setuptools/wheel so that we can e.g. use bdist_wheel - "pip install setuptools wheel" - "build.cmd %PYTHON%\\python.exe setup.py develop" build_script: # Build the compiled extension - "build.cmd %PYTHON%\\python.exe setup.py build" test_script: - "build.cmd %PYTHON%\\python.exe setup.py test" - "build.cmd %PYTHON%\\pythonw.exe setup.py test" after_test: - "build.cmd %PYTHON%\\python.exe setup.py bdist_wheel" # http://stackoverflow.com/questions/43255455/unicode-character-causing-error-with-bdist-wininst-on-python-3-but-not-python-2 # - "python setup.py bdist_wininst" - "build.cmd %PYTHON%\\python.exe setup.py bdist_msi" - ps: "ls dist" deploy_script: - if "%APPVEYOR_REPO_TAG%"=="true" pip install twine - if "%APPVEYOR_REPO_TAG%"=="true" twine upload dist\dulwich-*.whl artifacts: - path: dist\* diff --git a/setup.py b/setup.py index f9cade2a..3caa4a17 100755 --- a/setup.py +++ b/setup.py @@ -1,116 +1,117 @@ #!/usr/bin/python # encoding: utf-8 # Setup file for dulwich # Copyright (C) 2008-2016 Jelmer Vernooij try: from setuptools import setup, Extension except ImportError: from distutils.core import setup, Extension has_setuptools = False else: has_setuptools = True from distutils.core import Distribution import io import os import sys dulwich_version_string = '0.20.0' class DulwichDistribution(Distribution): def is_pure(self): if self.pure: return True def has_ext_modules(self): return not self.pure global_options = Distribution.global_options + [ ('pure', None, "use pure Python code instead of C " "extensions (slower on CPython)")] pure = False if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'): # XCode 4.0 dropped support for ppc architecture, which is hardcoded in # distutils.sysconfig import subprocess p = subprocess.Popen( ['/usr/bin/xcodebuild', '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env={}) out, err = p.communicate() for line in out.splitlines(): line = line.decode("utf8") # Also parse only first digit, because 3.2.1 can't be parsed nicely if (line.startswith('Xcode') and int(line.split()[1].split('.')[0]) >= 4): os.environ['ARCHFLAGS'] = '' tests_require = ['fastimport'] if '__pypy__' not in sys.modules and not sys.platform == 'win32': tests_require.extend([ 'gevent', 'geventhttpclient', 'mock', 'setuptools>=17.1']) ext_modules = [ Extension('dulwich._objects', ['dulwich/_objects.c']), Extension('dulwich._pack', ['dulwich/_pack.c']), Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c']), ] setup_kwargs = {} if has_setuptools: setup_kwargs['extras_require'] = { 'fastimport': ['fastimport'], 'https': ['urllib3[secure]>=1.24.1'], 'pgp': ['gpg'], } setup_kwargs['install_requires'] = ['urllib3>=1.24.1', 'certifi'] setup_kwargs['include_package_data'] = True setup_kwargs['test_suite'] = 'dulwich.tests.test_suite' setup_kwargs['tests_require'] = tests_require with io.open(os.path.join(os.path.dirname(__file__), "README.rst"), encoding="utf-8") as f: description = f.read() setup(name='dulwich', author="Jelmer Vernooij", author_email="jelmer@jelmer.uk", url="https://www.dulwich.io/", long_description=description, description="Python Git Library", version=dulwich_version_string, license='Apachev2 or later or GPLv2', project_urls={ "Bug Tracker": "https://github.com/dulwich/dulwich/issues", "Repository": "https://www.dulwich.io/code/", "GitHub": "https://github.com/dulwich/dulwich", }, keywords="git vcs", packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat', 'dulwich.contrib'], package_data={'': ['../docs/tutorial/*.txt']}, scripts=['bin/dulwich', 'bin/dul-receive-pack', 'bin/dul-upload-pack'], ext_modules=ext_modules, distclass=DulwichDistribution, classifiers=[ 'Development Status :: 4 - Beta', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Operating System :: POSIX', 'Operating System :: Microsoft :: Windows', 'Topic :: Software Development :: Version Control', ], **setup_kwargs )