Skip to content

Python 2.7 support #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: test
run-name: Run tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
pre-commit:
name: Check pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.0

pytest-fabric2:
name: Test for Fabric 2.0 compatibility
runs-on: ubuntu-latest
needs: [ pre-commit ]
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
fabric-version: [ "==2.2","<3.0" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Fabric ${{ matrix.fabric-version }} and patchwork
run: pip install "fabric${{ matrix.fabric-version }}" .[test]
- name: Test with pytest
run: pytest

pytest:
name: Run pytests
runs-on: ubuntu-latest
needs: [ pre-commit ]
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup patchwork
run: pip install -e .[test]
- name: Test with pytest
run: pytest
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
docs/_build
.cache
.coverage
/venv
/build
/.idea
*.egg-info
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.21.0
hooks:
- id: check-github-workflows
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

15 changes: 0 additions & 15 deletions dev-requirements.txt

This file was deleted.

63 changes: 63 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "patchwork"
version = "2.0.0"
description = "Deployment/sysadmin operations, powered by Fabric"
authors = [{ name = "Jeff Forcier", email = "jeff@bitprophet.org" }]
maintainers = [{ name = "Jeff Forcier", email = "jeff@bitprophet.org" }]
requires-python = ">=3.7"
readme = "README.rst"
license = { file = "LICENSE" }
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: BSD License",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Topic :: Software Development",
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Software Distribution",
"Topic :: System :: Systems Administration",
]

dependencies = [
"fabric>=2.2",
]

[project.optional-dependencies]
docs = [
"releases",
"alabaster",
"sphinx",
]
test = [
"invocations",
"pytest",
"mock",
"pytest-relaxed",
]
test-cov = [
"pytest-cov",
]
dev = [
"patchwork[test]",
"pre-commit",
]

[project.urls]
homepage = "https://www.fabfile.org/"

[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = "*"
14 changes: 0 additions & 14 deletions setup.cfg

This file was deleted.

157 changes: 109 additions & 48 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,109 @@
#!/usr/bin/env python

# Support setuptools only, distutils has a divergent and more annoying API and
# few folks will lack setuptools.
from setuptools import setup, find_packages

# Version info -- read without importing
_locals = {}
with open("patchwork/_version.py") as fp:
exec(fp.read(), None, _locals)
version = _locals["__version__"]

setup(
name="patchwork",
version=version,
description="Deployment/sysadmin operations, powered by Fabric",
license="BSD",
long_description=open("README.rst").read(),
author="Jeff Forcier",
author_email="jeff@bitprophet.org",
url="https://fabric-patchwork.readthedocs.io",
install_requires=["fabric>=2.0,<3.0"],
packages=find_packages(),
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: BSD License",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Topic :: Software Development",
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Software Distribution",
"Topic :: System :: Systems Administration",
],
)
# -*- coding: utf-8 -*-

"""
setup.py implementation, interesting because it parsed the first __init__.py and
extracts the `__author__` and `__version__`
"""

import sys
from ast import parse
from os import path

from setuptools import setup

if sys.version_info[:2] > (3, 7):
from ast import Constant
else:
if sys.version_info[0] == 2:
from itertools import imap as map

from ast import expr

# Constant. Will never be used in Python =< 3.8
Constant = type("Constant", (expr,), {})


package_name = "patchwork"

with open(
path.join(path.dirname(__file__), "README{extsep}rst".format(extsep=path.extsep)),
"rt",
) as fh:
long_description = fh.read()


def main():
"""Main function for setup.py; this actually does the installation"""
with open(
path.join(
path.abspath(path.dirname(__file__)),
"src",
"patchwork",
"_version{extsep}py".format(extsep=path.extsep),
)
) as f:
parsed_init = parse(f.read())

__version__ = ".".join(
map(
lambda node: str(node.value if isinstance(node, Constant) else node.n),
parsed_init.body[0].value.elts,
)
)

setup(
name=package_name,
author="Jeff Forcier",
author_email="jeff@bitprophet.org",
version=__version__,
url="https://www.fabfile.org",
description=long_description[: long_description.find("\n")],
long_description=long_description,
long_description_content_type="text/x-rst",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: BSD License",
"Operating System :: POSIX",
"Operating System :: POSIX :: Linux",
"Operating System :: Unix",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"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",
"Topic :: Software Development",
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Software Distribution",
"Topic :: System :: Systems Administration",
],
license="BSD-2-Clause",
license_files=["LICENSE"],
install_requires=["fabric>=2.2"],
test_suite="tests",
packages=[package_name],
package_dir={package_name: path.join("src", package_name)},
)


def setup_py_main():
"""Calls main if `__name__ == '__main__'`"""
if __name__ == "__main__":
main()


setup_py_main()
File renamed without changes.
2 changes: 1 addition & 1 deletion patchwork/_version.py → src/patchwork/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version_info__ = (1, 0, 1)
__version_info__ = (2, 0, 0)
__version__ = ".".join(map(str, __version_info__))
2 changes: 1 addition & 1 deletion patchwork/environment.py → src/patchwork/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ def have_program(c, name):
"""
Returns whether connected user has program ``name`` in their ``$PATH``.
"""
return c.run("which {}".format(name), hide=True, warn=True)
return c.run("which {name}".format(name=name), hide=True, warn=True)
Loading