diff --git a/Dockerfile b/Dockerfile index 4fc37341..bea64cb1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,7 +48,7 @@ COPY . /buildrunner-source RUN \ cd /buildrunner-source && \ sed -i s/jaraco-classes/jaraco.classes/ requirements.txt && \ - python3 setup.py install && \ + pip install . && \ rm -rf /buildrunner-source # The following will install docker-engine. It's not needed for the container to run, diff --git a/bin/buildrunner b/bin/buildrunner index be909b7c..0f8a6715 100755 --- a/bin/buildrunner +++ b/bin/buildrunner @@ -9,4 +9,4 @@ from buildrunner import cli if __name__ == "__main__": - sys.exit(cli.main(sys.argv)) + sys.exit(cli.main()) diff --git a/bin/buildrunner-cleanup b/bin/buildrunner-cleanup index 22190b41..cc460805 100755 --- a/bin/buildrunner-cleanup +++ b/bin/buildrunner-cleanup @@ -9,4 +9,4 @@ from buildrunner import cli if __name__ == "__main__": - sys.exit(cli.clean_cache(sys.argv)) + sys.exit(cli.clean_cache()) diff --git a/buildrunner/cli.py b/buildrunner/cli.py old mode 100644 new mode 100755 index fc32648b..f5082333 --- a/buildrunner/cli.py +++ b/buildrunner/cli.py @@ -270,9 +270,9 @@ def parse_args(argv): return args -def clean_cache(argv): +def clean_cache(): """Cache cleanup""" - args = parse_args(argv) + args = parse_args(sys.argv) BuildRunnerConfig.initialize_instance( push=False, build_number=1, @@ -409,9 +409,9 @@ def initialize_br(args: argparse.Namespace) -> BuildRunner: ) -def main(argv): +def main(): """Main program execution.""" - args = parse_args(argv) + args = parse_args(sys.argv) # are we just printing the version? if args.print_version: @@ -431,4 +431,4 @@ def main(argv): if __name__ == "__main__": - sys.exit(main(sys.argv)) + sys.exit(main()) diff --git a/buildrunner/docker/runner.py b/buildrunner/docker/runner.py index be4a22c5..6f733574 100644 --- a/buildrunner/docker/runner.py +++ b/buildrunner/docker/runner.py @@ -23,7 +23,6 @@ from docker.utils import compare_version from retry import retry import docker.errors -import six import timeout_decorator from buildrunner import BuildRunnerConfig @@ -217,7 +216,7 @@ def start( _port_list = list(ports.keys()) # check args - if dns_search and isinstance(dns_search, six.string_types): + if dns_search and isinstance(dns_search, str): dns_search = dns_search.split(",") kwargs = { diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..635c323a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,36 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "buildrunner" +version = "3.15" +description = "Docker-based build tool" +readme = "README.rst" +requires-python = ">=3.6" +license = {text = "MIT"} +authors = [ + {name = "Adobe", email = "noreply@adobe.com"} +] +urls = { "Homepage" = "https://github.com/adobe/buildrunner" } + +dynamic = ["dependencies", "optional-dependencies"] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} +optional-dependencies = {test = { file = ["test-requirements.txt"] }} + +[project.scripts] +buildrunner = "buildrunner.cli:main" +buildrunner-cleanup = "buildrunner.cli:clean_cache" + +[tool.setuptools.package-data] +"buildrunner" = ["SourceDockerfile"] +"buildrunner.sshagent" = [ + "SSHAgentProxyImage/Dockerfile", + "SSHAgentProxyImage/run.sh", + "SSHAgentProxyImage/login.sh" +] + +[tool.setuptools.packages.find] +exclude = ["*.tests", "*.tests.*", "tests.*", "tests"] \ No newline at end of file diff --git a/requirements.in b/requirements.in index f5ef65fd..5aabbe04 100644 --- a/requirements.in +++ b/requirements.in @@ -6,12 +6,12 @@ docker>=6.1.2 fabric>=2.5.0 paramiko>=2.10.3 requests>=2.27.0 -twine>=3.2.0 +twine>=6.1.0 vcsinfo>=2.1.105 graphlib-backport>=1.0.3 timeout-decorator>=0.5.0 python-on-whales>=0.70.1 -pydantic>=2.4.2 +pydantic==2.4.2 retry2>=0.9.5 colorlog>=6.8.0 rich>=13 diff --git a/requirements.txt b/requirements.txt index 41155458..72455b66 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,83 +1,94 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.8 # by the following command: # # pip-compile # -annotated-types==0.6.0 + +annotated-types==0.7.0 # via pydantic -bcrypt==4.0.1 +backports-tarfile==1.2.0 + # via jaraco-context +bcrypt==4.3.0 # via # -r requirements.in # paramiko -bleach==6.0.0 - # via readme-renderer -certifi==2023.5.7 +certifi==2025.1.31 # via requests -cffi==1.15.1 +cffi==1.17.1 # via # cryptography # pynacl -charset-normalizer==3.1.0 +charset-normalizer==3.4.1 # via requests -click==8.1.6 - # via typer -colorlog==6.8.0 +colorlog==6.9.0 # via -r requirements.in -cryptography==41.0.1 +cryptography==44.0.2 # via paramiko -decorator==5.1.1 +decorator==5.2.1 # via # -r requirements.in # fabric # retry2 -docker==6.1.3 +deprecated==1.2.18 + # via fabric +docker==7.1.0 # via -r requirements.in docutils==0.20.1 # via readme-renderer -fabric==3.1.0 +fabric==3.2.2 # via -r requirements.in -gitdb==4.0.10 +gitdb==4.0.12 # via # gitpython # vcsinfo -gitpython==3.1.31 +gitpython==3.1.44 # via vcsinfo -graphlib-backport==1.0.3 +graphlib-backport==1.1.0 # via -r requirements.in -idna==3.4 +id==1.5.0 + # via twine +idna==3.10 # via requests -importlib-metadata==6.6.0 +importlib-metadata==8.5.0 # via # keyring # twine -invoke==2.1.2 +importlib-resources==6.4.5 + # via keyring +invoke==2.2.0 # via fabric -jaraco-classes==3.2.3 +jaraco-classes==3.4.0 # via keyring -jinja2==3.1.2 +jaraco-context==6.0.1 + # via keyring +jaraco-functools==4.1.0 + # via keyring +jinja2==3.1.6 # via -r requirements.in -keyring==23.13.1 +keyring==25.5.0 # via twine -markdown-it-py==2.2.0 +markdown-it-py==3.0.0 # via rich -markupsafe==2.1.3 +markupsafe==2.1.5 # via jinja2 mdurl==0.1.2 # via markdown-it-py -more-itertools==9.1.0 - # via jaraco-classes -packaging==23.1 - # via docker -paramiko==3.2.0 +more-itertools==10.5.0 + # via + # jaraco-classes + # jaraco-functools +nh3==0.2.21 + # via readme-renderer +packaging==24.2 + # via twine +paramiko==3.5.1 # via # -r requirements.in # fabric -pkginfo==1.9.6 - # via twine -portalocker==2.10.1 +portalocker==3.0.0 # via -r requirements.in -pycparser==2.21 +pycparser==2.22 # via cffi pydantic==2.4.2 # via @@ -85,23 +96,23 @@ pydantic==2.4.2 # python-on-whales pydantic-core==2.10.1 # via pydantic -pygments==2.15.1 +pygments==2.19.1 # via # readme-renderer # rich pynacl==1.5.0 # via paramiko -python-on-whales==0.70.1 +python-on-whales==0.75.1 # via -r requirements.in -pyyaml==6.0.1 +pyyaml==6.0.2 # via -r requirements.in -readme-renderer==37.3 +readme-renderer==43.0 # via twine -requests==2.31.0 +requests==2.32.3 # via # -r requirements.in # docker - # python-on-whales + # id # requests-toolbelt # twine requests-toolbelt==1.0.0 @@ -110,38 +121,33 @@ retry2==0.9.5 # via -r requirements.in rfc3986==2.0.0 # via twine -rich==13.7.0 +rich==13.9.4 # via # -r requirements.in # twine -six==1.16.0 - # via bleach -smmap==5.0.0 +smmap==5.0.2 # via gitdb timeout-decorator==0.5.0 # via -r requirements.in -tqdm==4.65.0 - # via python-on-whales -twine==4.0.2 +twine==6.1.0 # via -r requirements.in -typer==0.9.0 - # via python-on-whales -typing-extensions==4.7.1 +typing-extensions==4.13.0 # via + # annotated-types # pydantic # pydantic-core # python-on-whales - # typer -urllib3==2.0.3 + # rich +urllib3==2.2.3 # via # docker # requests # twine -vcsinfo==2.1.105 +vcsinfo==2.1.110 # via -r requirements.in -webencodings==0.5.1 - # via bleach -websocket-client==1.5.2 - # via docker -zipp==3.15.0 - # via importlib-metadata +wrapt==1.17.2 + # via deprecated +zipp==3.20.2 + # via + # importlib-metadata + # importlib-resources diff --git a/setup.py b/setup.py deleted file mode 100644 index 8ebba34e..00000000 --- a/setup.py +++ /dev/null @@ -1,156 +0,0 @@ -""" -Copyright (C) 2023 Adobe -""" - -from __future__ import print_function - -import importlib.machinery -import os -import subprocess -import sys -import types - -from setuptools import setup, find_packages - - -BASE_VERSION = "3.15" - -SOURCE_DIR = os.path.dirname(os.path.abspath(__file__)) -BUILDRUNNER_DIR = os.path.join(SOURCE_DIR, "buildrunner") -VERSION_FILE = os.path.join(BUILDRUNNER_DIR, "version.py") - -THIS_DIR = os.path.dirname(__file__) - - -def read_requirements(filename): - """ - :param filename: - """ - requires = [] - dep_links = [] - try: - with open(os.path.join(THIS_DIR, filename)) as robj: - lnr = 0 - for line in robj.readlines(): - lnr += 1 - _line = line.strip() - if not _line: - continue - if _line.startswith("#"): - continue - - if _line.startswith("--extra-index-url"): - args = _line.split(None, 1) - if len(args) != 2: - print( - 'ERROR: option "--extra-index-url" must have a URL argument: {}:{}'.format( - filename, lnr - ), - file=sys.stderr, - ) - continue - dep_links.append(args[1]) - - elif _line[0].isalpha(): - # See note in Dockerfile for why this replacement is done - requires.append(_line.replace("jaraco-classes", "jaraco.classes")) - - else: - print( - 'ERROR: {}:{}:"{}" does not appear to be a requirement'.format( - filename, lnr, _line - ), - file=sys.stderr, - ) - - except IOError as err: - sys.stderr.write('Failure reading "{0}": {1}\n'.format(filename, err)) - sys.exit(err.errno) - - return requires, dep_links - - -REQUIRES, DEP_LINKS = read_requirements("requirements.txt") -requirements, dependency_links = read_requirements("test_requirements.txt") -TEST_REQUIRES = requirements -DEP_LINKS.extend(dependency_links) - - -def get_version(): - """ - Call out to the git command line to get the current commit "number". - """ - if os.path.exists(VERSION_FILE): - # Read version from file - loader = importlib.machinery.SourceFileLoader( - "buildrunner_version", VERSION_FILE - ) - version_mod = types.ModuleType(loader.name) - loader.exec_module(version_mod) - existing_version = version_mod.__version__ # pylint: disable=no-member - return existing_version - - # Generate the version from the base version and the git commit number, then store it in the file - try: - cmd = subprocess.Popen( - args=[ - "git", - "rev-list", - "--count", - "HEAD", - ], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - encoding="utf8", - ) - stdout = cmd.communicate()[0] - output = stdout.strip() - if cmd.returncode == 0: - new_version = "{0}.{1}".format(BASE_VERSION, output) - - # write the version file - if os.path.exists(BUILDRUNNER_DIR): - with open(VERSION_FILE, "w", encoding="utf8") as _fobj: - _fobj.write("__version__ = '%s'\n" % new_version) - return new_version - except Exception as exc: # pylint: disable=broad-except - print(f"Could not generate version from git commits: {exc}") - # If all else fails, use development version - return f"{BASE_VERSION}.DEVELOPMENT" - - -with open(os.path.join(os.path.dirname(__file__), "README.rst")) as fobj: - long_description = fobj.read().strip() - -setup( - name="buildrunner", - version=get_version(), - author="Adobe", - author_email="noreply@adobe.com", - license="MIT", - url="https://github.com/adobe/buildrunner", - description="Docker-based build tool", - long_description=long_description, - long_description_content_type="text/x-rst", - packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), - scripts=[ - "bin/buildrunner", - "bin/buildrunner-cleanup", - ], - package_data={ - "buildrunner": ["SourceDockerfile"], - "buildrunner.sshagent": [ - "SSHAgentProxyImage/Dockerfile", - "SSHAgentProxyImage/run.sh", - "SSHAgentProxyImage/login.sh", - ], - }, - install_requires=REQUIRES, - tests_require=TEST_REQUIRES, - dependency_links=DEP_LINKS, - test_suite="tests", -) - -# Local Variables: -# fill-column: 100 -# End: