From 1562549068b732f8ea08273473f561f268e3fd9e Mon Sep 17 00:00:00 2001 From: Steven Esser Date: Tue, 22 Sep 2020 15:53:53 -0400 Subject: [PATCH 01/53] Initial commit Signed-off-by: Steven Esser --- .gitignore | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..0abbef13 --- /dev/null +++ b/.gitignore @@ -0,0 +1,69 @@ +# Python compiled files +*.py[cod] + +# virtualenv and other misc bits +*.egg-info +/dist +/build +/bin +/lib +/scripts +/Scripts +/Lib +/pip-selfcheck.json +/tmp +.Python +/include +/Include +/local +*/local/* +/local/ +/share/ +/tcl/ +/.eggs/ + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.cache +.coverage +.coverage.* +nosetests.xml +htmlcov + +# Translations +*.mo + +# IDEs +.project +.pydevproject +.idea +org.eclipse.core.resources.prefs +.vscode +.vs + +# Sphinx +docs/_build +docs/bin +docs/build +docs/include +docs/Lib +doc/pyvenv.cfg +pyvenv.cfg + +# Various junk and temp files +.DS_Store +*~ +.*.sw[po] +.build +.ve +*.bak +/.cache/ + +# pyenv +/.python-version +/man/ +/.pytest_cache/ +lib64 +tcl From 85d17806960eed420cf321f1683f8122f27344c2 Mon Sep 17 00:00:00 2001 From: Steven Esser Date: Tue, 22 Sep 2020 15:54:36 -0400 Subject: [PATCH 02/53] Add initial skeleton files This commit adds the inital skeleton files needed for a bare-bones python library. Includes a simple configure script and setup.py file Signed-off-by: Steven Esser --- README.rst | 3 + apache-2.0.LICENSE | 176 +++++++++++++++++++++++++++++++++++++++++ configure | 43 ++++++++++ requirements-tests.txt | 1 + setup.py | 124 +++++++++++++++++++++++++++++ 5 files changed, 347 insertions(+) create mode 100644 README.rst create mode 100644 apache-2.0.LICENSE create mode 100755 configure create mode 100644 requirements-tests.txt create mode 100644 setup.py diff --git a/README.rst b/README.rst new file mode 100644 index 00000000..83376d53 --- /dev/null +++ b/README.rst @@ -0,0 +1,3 @@ +A Simple Python Project Skeleton +================================ +Note: configure script requires src/ directory to run correctly. diff --git a/apache-2.0.LICENSE b/apache-2.0.LICENSE new file mode 100644 index 00000000..d9a10c0d --- /dev/null +++ b/apache-2.0.LICENSE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/configure b/configure new file mode 100755 index 00000000..48c26281 --- /dev/null +++ b/configure @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# +# Copyright (c) nexB Inc. http://www.nexb.com/ - All rights reserved. +# + +set -e +#set -x + +# source this script for a basic setup and configuration for local development + +CONFIGURE_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + + +if [[ "$1" == "--clean" ]]; then + rm -rf "$CONFIGURE_ROOT_DIR/tmp" + exit +fi + + +if [[ "$PYTHON_EXE" == "" ]]; then + PYTHON_EXE=python3 +fi + + +function setup { + # create a virtualenv on Python + mkdir -p $CONFIGURE_ROOT_DIR/tmp + wget -O $CONFIGURE_ROOT_DIR/tmp/virtualenv.pyz https://bootstrap.pypa.io/virtualenv.pyz + $PYTHON_EXE $CONFIGURE_ROOT_DIR/tmp/virtualenv.pyz $CONFIGURE_ROOT_DIR/tmp + source $CONFIGURE_ROOT_DIR/tmp/bin/activate + $CONFIGURE_ROOT_DIR/tmp/bin/pip install --upgrade pip virtualenv setuptools wheel +} + + +setup + +$CONFIGURE_ROOT_DIR/tmp/bin/pip install -r requirements-tests.txt -e . + +if [ -f "$CONFIGURE_ROOT_DIR/tmp/bin/activate" ]; then + source "$CONFIGURE_ROOT_DIR/tmp/bin/activate" +fi + +set +e diff --git a/requirements-tests.txt b/requirements-tests.txt new file mode 100644 index 00000000..e079f8a6 --- /dev/null +++ b/requirements-tests.txt @@ -0,0 +1 @@ +pytest diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..1c920c10 --- /dev/null +++ b/setup.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from __future__ import absolute_import +from __future__ import print_function + +import io +from glob import glob +from os.path import basename +from os.path import dirname +from os.path import join +from os.path import splitext +import re +import sys + +from setuptools import find_packages +from setuptools import setup + +version = '0.0.0' + +#### Small hack to force using a plain version number if the option +#### --plain-version is passed to setup.py + +USE_DEFAULT_VERSION = False +try: + sys.argv.remove('--use-default-version') + USE_DEFAULT_VERSION = True +except ValueError: + pass +#### + + +def get_version(default=version, template='{tag}.{distance}.{commit}{dirty}', + use_default=USE_DEFAULT_VERSION): + """ + Return a version collected from git if possible or fall back to an + hard-coded default version otherwise. If `use_default` is True, + always use the default version. + """ + if use_default: + return default + try: + tag, distance, commit, dirty = get_git_version() + if not distance and not dirty: + # we are from a clean Git tag: use tag + return tag + + distance = 'post{}'.format(distance) + if dirty: + time_stamp = get_time_stamp() + dirty = '.dirty.' + get_time_stamp() + else: + dirty = '' + + return template.format(**locals()) + except: + # no git data: use default version + return default + + +def get_time_stamp(): + """ + Return a numeric UTC time stamp without microseconds. + """ + from datetime import datetime + return (datetime.isoformat(datetime.utcnow()).split('.')[0] + .replace('T', '').replace(':', '').replace('-', '')) + + +def get_git_version(): + """ + Return version parts from Git or raise an exception. + """ + from subprocess import check_output, STDOUT + # this may fail with exceptions + cmd = 'git', 'describe', '--tags', '--long', '--dirty', + version = check_output(cmd, stderr=STDOUT).strip() + dirty = version.endswith('-dirty') + tag, distance, commit = version.split('-')[:3] + # lower tag and strip V prefix in tags + tag = tag.lower().lstrip('v ').strip() + # strip leading g from git describe commit + commit = commit.lstrip('g').strip() + return tag, int(distance), commit, dirty + + +def read(*names, **kwargs): + return io.open( + join(dirname(__file__), *names), + encoding=kwargs.get('encoding', 'utf8') + ).read() + + +setup( + name='', + version=get_version(), + license='Apache-2.0', + description='', + long_description=read('README.rst'), + author='nexB. Inc. and others', + author_email='info@aboutcode.org', + url='', + packages=find_packages('src'), + package_dir={'': 'src'}, + py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')], + include_package_data=True, + zip_safe=False, + classifiers=[ + # complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Topic :: Software Development', + 'Topic :: Utilities', + ], + keywords=[ + ], + install_requires=[ + ] +) From aa71e06afd7f069202590cf532407f92fcafbf66 Mon Sep 17 00:00:00 2001 From: Steven Esser Date: Tue, 22 Sep 2020 16:21:54 -0400 Subject: [PATCH 03/53] Use pytest-xdist by default for threading support Signed-off-by: Steven Esser --- requirements-tests.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index e079f8a6..82d8d43d 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -1 +1 @@ -pytest +pytest-xdist From 774dc7d6709119442e099c7b706ee3a9f89fa219 Mon Sep 17 00:00:00 2001 From: Steven Esser Date: Wed, 23 Sep 2020 19:24:10 -0400 Subject: [PATCH 04/53] Add additional files * Add AUTHORS.rst * Add CHANGELOG.rst * Add setup.cfg Signed-off-by: Steven Esser --- AUTHORS.rst | 3 +++ CHANGELOG.rst | 5 +++++ setup.cfg | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 AUTHORS.rst create mode 100644 CHANGELOG.rst create mode 100644 setup.cfg diff --git a/AUTHORS.rst b/AUTHORS.rst new file mode 100644 index 00000000..51a19cc8 --- /dev/null +++ b/AUTHORS.rst @@ -0,0 +1,3 @@ +The following organizations or individuals have contributed to this repo: + +- diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 00000000..5f8bc8da --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,5 @@ +Release notes +------------- +### Version 0.0.0 + +*xxxx-xx-xx* -- Initial release. diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..24aaefa0 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,50 @@ +[wheel] +universal=1 + +[metadata] +license_files = + README.rst + CHANGELOG.rst + apache-2.0.LICENSE + bsd-new.LICENSE + mit.LICENSE + NOTICE + +[tool:pytest] +norecursedirs = + .git + bin + dist + build + _build + dist + etc + local + ci + docs + man + share + samples + .cache + .settings + Include + include + Lib + lib + lib64 + Lib64 + Scripts + thirdparty + tmp + tests/data + +python_files = *.py + +python_classes=Test +python_functions=test + +addopts = + -rfExXw + --strict + --ignore setup.py + --doctest-modules From 9a56b880389ce929a3c0e0dca8bdda576a3f2945 Mon Sep 17 00:00:00 2001 From: Steven Esser Date: Fri, 25 Sep 2020 13:03:15 -0400 Subject: [PATCH 05/53] Follow modern python packaging and conf practices * Add PEP 517/518 pyproject.toml file * Add setuptools_scm to handle versioning * Add setup.py content to setup.cfg * Update setup.py to act as a shim (so pip install -e works) Addresses: #2 Signed-off-by: Steven Esser --- configure | 2 +- pyproject.toml | 46 +++++++++++++++ requirements-tests.txt | 1 - setup.cfg | 73 ++++++++++-------------- setup.py | 124 +---------------------------------------- 5 files changed, 80 insertions(+), 166 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements-tests.txt diff --git a/configure b/configure index 48c26281..a35c8c90 100755 --- a/configure +++ b/configure @@ -34,7 +34,7 @@ function setup { setup -$CONFIGURE_ROOT_DIR/tmp/bin/pip install -r requirements-tests.txt -e . +$CONFIGURE_ROOT_DIR/tmp/bin/pip install -e .[testing] if [ -f "$CONFIGURE_ROOT_DIR/tmp/bin/activate" ]; then source "$CONFIGURE_ROOT_DIR/tmp/bin/activate" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..e75f1cec --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,46 @@ +[build-system] +requires = ["setuptools >= 50", "wheel", "setuptools_scm[toml] >= 4"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] + +[tool.pytest.ini_options] +norecursedirs = [ + ".git", + "bin", + "dist", + "build", + "_build", + "dist", + "etc", + "local", + "ci", + "docs", + "man", + "share", + "samples", + ".cache", + ".settings", + "Include", + "include", + "Lib", + "lib", + "lib64", + "Lib64", + "Scripts", + "thirdparty", + "tmp", + "tests/data", + ".eggs" +] + +python_files = "*.py" + +python_classes="Test" +python_functions="test" + +addopts = [ + "-rfExXw", + "--strict", + "--doctest-modules" +] \ No newline at end of file diff --git a/requirements-tests.txt b/requirements-tests.txt deleted file mode 100644 index 82d8d43d..00000000 --- a/requirements-tests.txt +++ /dev/null @@ -1 +0,0 @@ -pytest-xdist diff --git a/setup.cfg b/setup.cfg index 24aaefa0..b703e571 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,49 +2,36 @@ universal=1 [metadata] -license_files = - README.rst - CHANGELOG.rst - apache-2.0.LICENSE - bsd-new.LICENSE - mit.LICENSE - NOTICE +license_file = apache-2.0.LICENSE +name = skeleton +author = nexB. Inc. and others +author_email = info@aboutcode.org +description = skeleton +long_description = file:README.rst +url = https://github.com/nexB/skeleton +classifiers = + Development Status :: 5 - Production/Stable + Intended Audience :: Developers + Programming Language :: Python :: 3 + Programming Language :: Python :: 3 :: Only + Topic :: Software Development + Topic :: Utilities +keywords = -[tool:pytest] -norecursedirs = - .git - bin - dist - build - _build - dist - etc - local - ci - docs - man - share - samples - .cache - .settings - Include - include - Lib - lib - lib64 - Lib64 - Scripts - thirdparty - tmp - tests/data +[options] +package_dir= + =src +packages=find: +include_package_data = true +zip_safe = false +install_requires = +setup_requires = setuptools_scm[toml] >= 4 -python_files = *.py +[options.packages.find] +where=src -python_classes=Test -python_functions=test - -addopts = - -rfExXw - --strict - --ignore setup.py - --doctest-modules +[options.extras_require] +testing = + # upstream + pytest >= 6 + pytest-xdist >= 2 \ No newline at end of file diff --git a/setup.py b/setup.py index 1c920c10..45f160da 100644 --- a/setup.py +++ b/setup.py @@ -1,124 +1,6 @@ #!/usr/bin/env python -# -*- encoding: utf-8 -*- -from __future__ import absolute_import -from __future__ import print_function +import setuptools -import io -from glob import glob -from os.path import basename -from os.path import dirname -from os.path import join -from os.path import splitext -import re -import sys - -from setuptools import find_packages -from setuptools import setup - -version = '0.0.0' - -#### Small hack to force using a plain version number if the option -#### --plain-version is passed to setup.py - -USE_DEFAULT_VERSION = False -try: - sys.argv.remove('--use-default-version') - USE_DEFAULT_VERSION = True -except ValueError: - pass -#### - - -def get_version(default=version, template='{tag}.{distance}.{commit}{dirty}', - use_default=USE_DEFAULT_VERSION): - """ - Return a version collected from git if possible or fall back to an - hard-coded default version otherwise. If `use_default` is True, - always use the default version. - """ - if use_default: - return default - try: - tag, distance, commit, dirty = get_git_version() - if not distance and not dirty: - # we are from a clean Git tag: use tag - return tag - - distance = 'post{}'.format(distance) - if dirty: - time_stamp = get_time_stamp() - dirty = '.dirty.' + get_time_stamp() - else: - dirty = '' - - return template.format(**locals()) - except: - # no git data: use default version - return default - - -def get_time_stamp(): - """ - Return a numeric UTC time stamp without microseconds. - """ - from datetime import datetime - return (datetime.isoformat(datetime.utcnow()).split('.')[0] - .replace('T', '').replace(':', '').replace('-', '')) - - -def get_git_version(): - """ - Return version parts from Git or raise an exception. - """ - from subprocess import check_output, STDOUT - # this may fail with exceptions - cmd = 'git', 'describe', '--tags', '--long', '--dirty', - version = check_output(cmd, stderr=STDOUT).strip() - dirty = version.endswith('-dirty') - tag, distance, commit = version.split('-')[:3] - # lower tag and strip V prefix in tags - tag = tag.lower().lstrip('v ').strip() - # strip leading g from git describe commit - commit = commit.lstrip('g').strip() - return tag, int(distance), commit, dirty - - -def read(*names, **kwargs): - return io.open( - join(dirname(__file__), *names), - encoding=kwargs.get('encoding', 'utf8') - ).read() - - -setup( - name='', - version=get_version(), - license='Apache-2.0', - description='', - long_description=read('README.rst'), - author='nexB. Inc. and others', - author_email='info@aboutcode.org', - url='', - packages=find_packages('src'), - package_dir={'': 'src'}, - py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')], - include_package_data=True, - zip_safe=False, - classifiers=[ - # complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Topic :: Software Development', - 'Topic :: Utilities', - ], - keywords=[ - ], - install_requires=[ - ] -) +if __name__ == "__main__": + setuptools.setup() \ No newline at end of file From 565feee243b68db1bc0608058178a8aa9ba485c9 Mon Sep 17 00:00:00 2001 From: Steven Esser Date: Fri, 25 Sep 2020 14:38:11 -0400 Subject: [PATCH 06/53] Add some minimal documentation Signed-off-by: Steven Esser --- README.rst | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 83376d53..049d38eb 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,31 @@ A Simple Python Project Skeleton ================================ -Note: configure script requires src/ directory to run correctly. +This repo attempts to standardize our python repositories using modern python +packaging and configuration techniques. Using this `blog post`_ as inspiration, this +repository will serve as the base for all new python projects and will be adopted to all +our existing ones as well. + +.. _blog post: https://blog.jaraco.com/a-project-skeleton-for-python-projects/ + +Usage +===== +A brand new project +------------------- +.. code-block:: bash + + git init my-new-repo + cd my-new-repo + git pull git@github.com:nexB/skeleton + +From here, you can make the appropriate changes to the files for your specific project. + +Update an existing project +--------------------------- +.. code-block:: bash + + cd my-existing-project + git remote add skeleton git@github.com:nexB/skeleton + git fetch skeleton + git merge skeleton --allow-unrelated-histories + +This is also the workflow to use when updating the skeleton files in any given repository. \ No newline at end of file From 5febefbe4f7b2cceef99a6b4b9c196fe76a266bf Mon Sep 17 00:00:00 2001 From: Steven Esser Date: Tue, 29 Sep 2020 13:32:52 -0400 Subject: [PATCH 07/53] Fix hanging tag chars in setup.cfg Signed-off-by: Steven Esser --- setup.cfg | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/setup.cfg b/setup.cfg index b703e571..a7ab2fe6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,10 +10,10 @@ description = skeleton long_description = file:README.rst url = https://github.com/nexB/skeleton classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only + Development Status :: 5 - Production/Stable + Intended Audience :: Developers + Programming Language :: Python :: 3 + Programming Language :: Python :: 3 :: Only Topic :: Software Development Topic :: Utilities keywords = @@ -32,6 +32,6 @@ where=src [options.extras_require] testing = - # upstream - pytest >= 6 - pytest-xdist >= 2 \ No newline at end of file + # upstream + pytest >= 6 + pytest-xdist >= 2 From 343ff29e14958d31e151310608efac3ce1ad1d9c Mon Sep 17 00:00:00 2001 From: Steven Esser Date: Wed, 30 Sep 2020 13:07:18 -0400 Subject: [PATCH 08/53] Update README instructions with proper git merge conventions Signed-off-by: Steven Esser --- README.rst | 4 ++-- setup.cfg | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 049d38eb..0f1585bc 100644 --- a/README.rst +++ b/README.rst @@ -26,6 +26,6 @@ Update an existing project cd my-existing-project git remote add skeleton git@github.com:nexB/skeleton git fetch skeleton - git merge skeleton --allow-unrelated-histories + git merge skeleton/main --allow-unrelated-histories -This is also the workflow to use when updating the skeleton files in any given repository. \ No newline at end of file +This is also the workflow to use when updating the skeleton files in any given repository. diff --git a/setup.cfg b/setup.cfg index a7ab2fe6..5b665cfa 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,7 +25,7 @@ packages=find: include_package_data = true zip_safe = false install_requires = -setup_requires = setuptools_scm[toml] >= 4 +setup_requires = setuptools_scm >= 4 [options.packages.find] where=src From fa55f68fac8c80413f41bcbc3280d017e6d21198 Mon Sep 17 00:00:00 2001 From: Steven Esser Date: Fri, 16 Oct 2020 11:29:43 -0400 Subject: [PATCH 09/53] Add minimal .travis.yml CI config file Signed-off-by: Steven Esser --- .travis.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..bcc3be8e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +# This is a skeleton Travis CI config file that provides a starting point for adding CI +# to a Python project. Since we primarily develop in python3, this skeleton config file +# will be specific to that language. +# +# See https://config.travis-ci.com/ for a full list of configuration options. + +os: linux + +dist: xenial + +language: python +python: + - "3.6" + - "3.7" + - "3.8" + +# Scripts to run at install stage +install: ./configure + +# Scripts to run at script stage +script: bin/pytest From 3296b9fde77cfbe36824d88e403652bcc72f8316 Mon Sep 17 00:00:00 2001 From: Steven Esser Date: Thu, 22 Oct 2020 14:07:23 -0400 Subject: [PATCH 10/53] Update setuptools_scm declaration Signed-off-by: Steven Esser --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 5b665cfa..a7ab2fe6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,7 +25,7 @@ packages=find: include_package_data = true zip_safe = false install_requires = -setup_requires = setuptools_scm >= 4 +setup_requires = setuptools_scm[toml] >= 4 [options.packages.find] where=src From 083bd0483b5869219db51623eed44a9cd711989b Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Mon, 26 Oct 2020 15:30:56 -0700 Subject: [PATCH 11/53] Add azure pipeline config files and templates * Create configure.bat so we can use our skeleton for Windows projects Signed-off-by: Jono Yang --- .travis.yml | 4 +- azure-pipelines.yml | 45 ++++++++++++ configure.bat | 160 +++++++++++++++++++++++++++++++++++++++++ etc/ci/azure-linux.yml | 37 ++++++++++ etc/ci/azure-mac.yml | 36 ++++++++++ etc/ci/azure-win.yml | 36 ++++++++++ 6 files changed, 316 insertions(+), 2 deletions(-) create mode 100644 azure-pipelines.yml create mode 100644 configure.bat create mode 100644 etc/ci/azure-linux.yml create mode 100644 etc/ci/azure-mac.yml create mode 100644 etc/ci/azure-win.yml diff --git a/.travis.yml b/.travis.yml index bcc3be8e..7a342dff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ # This is a skeleton Travis CI config file that provides a starting point for adding CI # to a Python project. Since we primarily develop in python3, this skeleton config file -# will be specific to that language. +# will be specific to that language. # # See https://config.travis-ci.com/ for a full list of configuration options. @@ -18,4 +18,4 @@ python: install: ./configure # Scripts to run at script stage -script: bin/pytest +script: tmp/bin/pytest diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..904ac906 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,45 @@ + +################################################################################ +# We use Azure to run the full tests suites on Python 3.6 +# on Windows (32 and 64), macOS and Linux (64 various distro) +################################################################################ + +jobs: + +################################################################################ +# These jobs are using VMs and Azure-provided Python 3.6 +################################################################################ + + - template: etc/ci/azure-linux.yml + parameters: + job_name: vm_ubuntu16_py36 + image_name: ubuntu-16.04 + python_versions: ['3.6'] + test_suites: + all: bin/py.test -n 2 -vvs --reruns=3 + + - template: etc/ci/azure-mac.yml + parameters: + job_name: macos1015_py36 + image_name: macos-10.15 + python_versions: ['3.6'] + test_suites: + all: bin/py.test -n 2 -vvs --reruns=3 + + - template: etc/ci/azure-win.yml + parameters: + job_name: Win2016_32_py36 + image_name: vs2017-win2016 + python_versions: ['3.6'] + python_architecture: x86 + test_suites: + all: Scripts\py.test -vvs --reruns=3 + + - template: etc/ci/azure-win.yml + parameters: + job_name: Win2016_64_py36 + image_name: vs2017-win2016 + python_versions: ['3.6'] + python_architecture: x64 + test_suites: + misc: Scripts\py.test -vvs --reruns=3 diff --git a/configure.bat b/configure.bat new file mode 100644 index 00000000..0a2ca00f --- /dev/null +++ b/configure.bat @@ -0,0 +1,160 @@ +@echo OFF +@setlocal +@rem Copyright (c) nexB Inc. http://www.nexb.com/ - All rights reserved. + +@rem ################################ +@rem # A configuration script for Windows +@rem # +@rem # The options and (optional) arguments are: +@rem # --clean : this is exclusive of anything else and cleans the environment +@rem # from built and installed files +@rem # +@rem # --python < path to python.exe> : this must be the first argument and set +@rem # the path to the Python executable to use. If < path to python.exe> is +@rem # set to "path", then the executable will be the python.exe available +@rem # in the PATH. +@rem # +@rem # : this must be the last argument and sets the path to a +@rem # configuration directory to use. +@rem ################################ + +@rem ################################ +@rem # Defaults. Change these variables to customize this script locally +@rem ################################ +@rem # you can define one or more thirdparty dirs, each where the varibale name +@rem # is prefixed with TPP_DIR +set "TPP_DIR=thirdparty" + +@rem # default configurations for dev +set "CONF_DEFAULT=etc/conf/dev" + +@rem # default thirdparty dist for dev +if ""%CONF_DEFAULT%""==""etc/conf/dev"" ( + set "TPP_DIR_DEV=thirdparty/dev" +) + +@rem # default supported version for Python 3 +set SUPPORTED_PYTHON3=3.6 + +@rem ################################# + +@rem python --version +@rem python -c "import sys;print(sys.executable)" + + +@rem Current directory where this .bat files lives +set CFG_ROOT_DIR=%~dp0 + +@rem path where a configured Python should live in the current virtualenv if installed +set CONFIGURED_PYTHON=%CFG_ROOT_DIR%Scripts\python.exe + +set PYTHON_EXECUTABLE= + +@rem parse command line options and arguments +:collectopts +if "%1" EQU "--help" (goto cli_help) +if "%1" EQU "--clean" (call rmdir /s /q "%CFG_ROOT_DIR%tmp") && call exit /b +if "%1" EQU "--python" (set PROVIDED_PYTHON=%~2) && shift && shift && goto collectopts + +@rem We are not cleaning: Either we have a provided configure config path or we use a default. +if ""%1""=="""" ( + set CFG_CMD_LINE_ARGS=%CONF_DEFAULT% +) else ( + set CFG_CMD_LINE_ARGS=%1 +) + +@rem If we have a pre-configured Python in our virtualenv, reuse this as-is and run +if exist ""%CONFIGURED_PYTHON%"" ( + set PYTHON_EXECUTABLE=%CONFIGURED_PYTHON% + goto run +) + +@rem If we have a command arg for Python use this as-is +if ""%PROVIDED_PYTHON%""==""path"" ( + @rem use a bare python available in the PATH + set PYTHON_EXECUTABLE=python + goto run +) +if exist ""%PROVIDED_PYTHON%"" ( + set PYTHON_EXECUTABLE=%PROVIDED_PYTHON% + goto run +) + + +@rem otherwise we search for a suitable Python interpreter +:find_python + +@rem First check the existence of the "py" launcher (available in Python 3) +@rem if we have it, check if we have a py -3 installed with the good version or a py 2.7 +@rem if not, check if we have an old py 2.7 +@rem exist if all fails + +where py >nul 2>nul +if %ERRORLEVEL% == 0 ( + @rem we have a py launcher, check for the availability of our required Python 3 version + py -3.6 --version >nul 2>nul + if %ERRORLEVEL% == 0 ( + set PYTHON_EXECUTABLE=py -3.6 + ) else ( + @rem we have no required python 3, let's try python 2: + py -2 --version >nul 2>nul + if %ERRORLEVEL% == 0 ( + set PYTHON_EXECUTABLE=py -2 + ) else ( + @rem we have py and no python 3 and 2, exit + echo * Unable to find an installation of Python. + exit /b 1 + ) + ) +) else ( + @rem we have no py launcher, check for a default Python 2 installation + if not exist ""%DEFAULT_PYTHON2%"" ( + echo * Unable to find an installation of Python. + exit /b 1 + ) else ( + set PYTHON_EXECUTABLE=%DEFAULT_PYTHON2% + ) +) + +:run + +@rem without this things may not always work on Windows 10, but this makes things slower +set PYTHONDONTWRITEBYTECODE=1 + +call mkdir "%CFG_ROOT_DIR%tmp" +call curl -o "%CFG_ROOT_DIR%tmp\virtualenv.pyz" https://bootstrap.pypa.io/virtualenv.pyz +call %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%tmp\virtualenv.pyz" "%CFG_ROOT_DIR%tmp" +call "%CFG_ROOT_DIR%tmp\Scripts\activate" +call "%CFG_ROOT_DIR%tmp\Scripts\pip" install --upgrade pip virtualenv setuptools wheel + + +@rem Return a proper return code on failure +if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% +) +endlocal +goto activate + + +:cli_help +echo A configuration script for Windows +echo usage: configure [options] [path/to/config/directory] +echo. +echo The options and arguments are: +echo [path/to/config/directory] : this optionally sets the path to a +echo configuration directory to use. Defaults to etc/conf/dev if not set +echo. +echo --clean : this is exclusive of anything else and cleans the environment +echo from built and installed files +echo. +echo --python path/to/python.exe : this is set to the path of an alternative +echo Python executable to use. If path/to/python.exe is set to "path", +echo then the executable will be the python.exe available in the PATH. +echo. + + +:activate +@rem Activate the virtualenv +if exist "%CFG_ROOT_DIR%Scripts\activate" ( + "%CFG_ROOT_DIR%Scripts\activate" +) diff --git a/etc/ci/azure-linux.yml b/etc/ci/azure-linux.yml new file mode 100644 index 00000000..2e12e5b0 --- /dev/null +++ b/etc/ci/azure-linux.yml @@ -0,0 +1,37 @@ +parameters: + job_name: '' + image_name: 'ubuntu-16.04' + python_versions: [] + test_suites: {} + python_architecture: x64 + +jobs: + - job: ${{ parameters.job_name }} + + pool: + vmImage: ${{ parameters.image_name }} + + strategy: + matrix: + ${{ each pyver in parameters.python_versions }}: + ${{ each tsuite in parameters.test_suites }}: + ${{ format('py{0} {1}', pyver, tsuite.key) }}: + python_version: ${{ pyver }} + test_suite_label: ${{ tsuite.key }} + test_suite: ${{ tsuite.value }} + + steps: + - checkout: self + fetchDepth: 10 + + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(python_version)' + architecture: '${{ parameters.python_architecture }}' + displayName: 'Install Python $(python_version)' + + - script: ./configure + displayName: 'Run Configure' + + - script: $(test_suite) + displayName: 'Run $(test_suite_label) tests with py$(python_version) on ${{ parameters.job_name }}' diff --git a/etc/ci/azure-mac.yml b/etc/ci/azure-mac.yml new file mode 100644 index 00000000..752ae2e6 --- /dev/null +++ b/etc/ci/azure-mac.yml @@ -0,0 +1,36 @@ +parameters: + job_name: '' + image_name: '' + python_versions: [] + test_suites: {} + python_architecture: x64 + +jobs: + - job: ${{ parameters.job_name }} + + pool: + vmImage: ${{ parameters.image_name }} + + strategy: + matrix: + ${{ each pyver in parameters.python_versions }}: + ${{ each tsuite in parameters.test_suites }}: + ${{ format('py{0} {1}', pyver, tsuite.key) }}: + python_version: ${{ pyver }} + test_suite_label: ${{ tsuite.key }} + test_suite: ${{ tsuite.value }} + steps: + - checkout: self + fetchDepth: 10 + + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(python_version)' + architecture: '${{ parameters.python_architecture }}' + displayName: 'Install Python $(python_version)' + + - script: ./configure + displayName: 'Run Configure' + + - script: $(test_suite) + displayName: 'Run $(test_suite_label) tests with py$(python_version) on ${{ parameters.job_name }}' diff --git a/etc/ci/azure-win.yml b/etc/ci/azure-win.yml new file mode 100644 index 00000000..62208574 --- /dev/null +++ b/etc/ci/azure-win.yml @@ -0,0 +1,36 @@ +parameters: + job_name: '' + image_name: '' + python_versions: [] + test_suites: {} + python_architecture: x86 + +jobs: + - job: ${{ parameters.job_name }} + + pool: + vmImage: ${{ parameters.image_name }} + + strategy: + matrix: + ${{ each pyver in parameters.python_versions }}: + ${{ each tsuite in parameters.test_suites }}: + ${{ format('py{0} {1}', pyver, tsuite.key) }}: + python_version: ${{ pyver }} + test_suite_label: ${{ tsuite.key }} + test_suite: ${{ tsuite.value }} + steps: + - checkout: self + fetchDepth: 10 + + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(python_version)' + architecture: '${{ parameters.python_architecture }}' + displayName: 'Install Python $(python_version)' + + - script: configure --python path + displayName: 'Run Configure' + + - script: $(test_suite) + displayName: 'Run $(test_suite_label) tests with py$(python_version) on ${{ parameters.job_name }}' From 847564ead159cfcebe0f04066daa6f23e1a5a123 Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Tue, 27 Oct 2020 10:40:38 -0700 Subject: [PATCH 12/53] Fix path to Scripts directory * Remove unused variables and options Signed-off-by: Jono Yang --- configure.bat | 48 ++++-------------------------------------------- 1 file changed, 4 insertions(+), 44 deletions(-) diff --git a/configure.bat b/configure.bat index 0a2ca00f..cbb42446 100644 --- a/configure.bat +++ b/configure.bat @@ -13,41 +13,12 @@ @rem # the path to the Python executable to use. If < path to python.exe> is @rem # set to "path", then the executable will be the python.exe available @rem # in the PATH. -@rem # -@rem # : this must be the last argument and sets the path to a -@rem # configuration directory to use. -@rem ################################ - @rem ################################ -@rem # Defaults. Change these variables to customize this script locally -@rem ################################ -@rem # you can define one or more thirdparty dirs, each where the varibale name -@rem # is prefixed with TPP_DIR -set "TPP_DIR=thirdparty" - -@rem # default configurations for dev -set "CONF_DEFAULT=etc/conf/dev" - -@rem # default thirdparty dist for dev -if ""%CONF_DEFAULT%""==""etc/conf/dev"" ( - set "TPP_DIR_DEV=thirdparty/dev" -) - -@rem # default supported version for Python 3 -set SUPPORTED_PYTHON3=3.6 - -@rem ################################# - -@rem python --version -@rem python -c "import sys;print(sys.executable)" - @rem Current directory where this .bat files lives set CFG_ROOT_DIR=%~dp0 - @rem path where a configured Python should live in the current virtualenv if installed -set CONFIGURED_PYTHON=%CFG_ROOT_DIR%Scripts\python.exe - +set CONFIGURED_PYTHON=%CFG_ROOT_DIR%tmp\Scripts\python.exe set PYTHON_EXECUTABLE= @rem parse command line options and arguments @@ -56,13 +27,6 @@ if "%1" EQU "--help" (goto cli_help) if "%1" EQU "--clean" (call rmdir /s /q "%CFG_ROOT_DIR%tmp") && call exit /b if "%1" EQU "--python" (set PROVIDED_PYTHON=%~2) && shift && shift && goto collectopts -@rem We are not cleaning: Either we have a provided configure config path or we use a default. -if ""%1""=="""" ( - set CFG_CMD_LINE_ARGS=%CONF_DEFAULT% -) else ( - set CFG_CMD_LINE_ARGS=%1 -) - @rem If we have a pre-configured Python in our virtualenv, reuse this as-is and run if exist ""%CONFIGURED_PYTHON%"" ( set PYTHON_EXECUTABLE=%CONFIGURED_PYTHON% @@ -83,7 +47,6 @@ if exist ""%PROVIDED_PYTHON%"" ( @rem otherwise we search for a suitable Python interpreter :find_python - @rem First check the existence of the "py" launcher (available in Python 3) @rem if we have it, check if we have a py -3 installed with the good version or a py 2.7 @rem if not, check if we have an old py 2.7 @@ -116,8 +79,8 @@ if %ERRORLEVEL% == 0 ( ) ) -:run +:run @rem without this things may not always work on Windows 10, but this makes things slower set PYTHONDONTWRITEBYTECODE=1 @@ -141,9 +104,6 @@ echo A configuration script for Windows echo usage: configure [options] [path/to/config/directory] echo. echo The options and arguments are: -echo [path/to/config/directory] : this optionally sets the path to a -echo configuration directory to use. Defaults to etc/conf/dev if not set -echo. echo --clean : this is exclusive of anything else and cleans the environment echo from built and installed files echo. @@ -155,6 +115,6 @@ echo. :activate @rem Activate the virtualenv -if exist "%CFG_ROOT_DIR%Scripts\activate" ( - "%CFG_ROOT_DIR%Scripts\activate" +if exist "%CFG_ROOT_DIR%tmp\Scripts\activate" ( + "%CFG_ROOT_DIR%tmp\Scripts\activate" ) From 0f293cb11374d96df99757ce8dc6bed4730c9751 Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Tue, 27 Oct 2020 10:45:16 -0700 Subject: [PATCH 13/53] Install current project in configure.bat Signed-off-by: Jono Yang --- configure.bat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.bat b/configure.bat index cbb42446..958f5bf8 100644 --- a/configure.bat +++ b/configure.bat @@ -21,6 +21,7 @@ set CFG_ROOT_DIR=%~dp0 set CONFIGURED_PYTHON=%CFG_ROOT_DIR%tmp\Scripts\python.exe set PYTHON_EXECUTABLE= + @rem parse command line options and arguments :collectopts if "%1" EQU "--help" (goto cli_help) @@ -89,7 +90,7 @@ call curl -o "%CFG_ROOT_DIR%tmp\virtualenv.pyz" https://bootstrap.pypa.io/virtua call %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%tmp\virtualenv.pyz" "%CFG_ROOT_DIR%tmp" call "%CFG_ROOT_DIR%tmp\Scripts\activate" call "%CFG_ROOT_DIR%tmp\Scripts\pip" install --upgrade pip virtualenv setuptools wheel - +call "%CFG_ROOT_DIR%tmp\Scripts\pip" install -e .[testing] @rem Return a proper return code on failure if %ERRORLEVEL% neq 0 ( From 63f6946e1b3b070924b156a86b0ed0c3da6b7a48 Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Tue, 27 Oct 2020 11:41:51 -0700 Subject: [PATCH 14/53] Call pytest from proper location * Remove rerun option from azure-pipelines.yml Signed-off-by: Jono Yang --- azure-pipelines.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 904ac906..cf84da29 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -16,7 +16,7 @@ jobs: image_name: ubuntu-16.04 python_versions: ['3.6'] test_suites: - all: bin/py.test -n 2 -vvs --reruns=3 + all: tmp/bin/pytest -n 2 -vvs - template: etc/ci/azure-mac.yml parameters: @@ -24,7 +24,7 @@ jobs: image_name: macos-10.15 python_versions: ['3.6'] test_suites: - all: bin/py.test -n 2 -vvs --reruns=3 + all: tmp/bin/pytest -n 2 -vvs - template: etc/ci/azure-win.yml parameters: @@ -33,7 +33,7 @@ jobs: python_versions: ['3.6'] python_architecture: x86 test_suites: - all: Scripts\py.test -vvs --reruns=3 + all: tmp\Scripts\pytest -vvs - template: etc/ci/azure-win.yml parameters: @@ -42,4 +42,4 @@ jobs: python_versions: ['3.6'] python_architecture: x64 test_suites: - misc: Scripts\py.test -vvs --reruns=3 + misc: tmp\Scripts\pytest -vvs From 7fd250691c0f9db772e289d3cfb2224d70f3dcd0 Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Tue, 27 Oct 2020 12:43:10 -0700 Subject: [PATCH 15/53] Use newer VM images on Azure Signed-off-by: Jono Yang --- azure-pipelines.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cf84da29..fad6928d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,8 +12,8 @@ jobs: - template: etc/ci/azure-linux.yml parameters: - job_name: vm_ubuntu16_py36 - image_name: ubuntu-16.04 + job_name: ubuntu18_py36 + image_name: ubuntu-18.04 python_versions: ['3.6'] test_suites: all: tmp/bin/pytest -n 2 -vvs @@ -28,8 +28,8 @@ jobs: - template: etc/ci/azure-win.yml parameters: - job_name: Win2016_32_py36 - image_name: vs2017-win2016 + job_name: win2019_32_py36 + image_name: windows-2019 python_versions: ['3.6'] python_architecture: x86 test_suites: @@ -37,9 +37,9 @@ jobs: - template: etc/ci/azure-win.yml parameters: - job_name: Win2016_64_py36 - image_name: vs2017-win2016 + job_name: win2019_64_py36 + image_name: windows-2019 python_versions: ['3.6'] python_architecture: x64 test_suites: - misc: tmp\Scripts\pytest -vvs + all: tmp\Scripts\pytest -vvs From bceb8f98633bda15982c667848dc86be19ee6f97 Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Wed, 28 Oct 2020 17:03:27 -0700 Subject: [PATCH 16/53] Add .gitattributes * We have this to ensure the line ending of configure.bat is always CRLF Signed-off-by: Jono Yang --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..2d555b20 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Set configure.bat's line ending to CRLF. Sometimes batch scripts don't work +# properly on Windows if the line ending is LF and not CRLF +configure.bat eol=crlf From e772fe670da017a9ff51e3b7119996f12169e79c Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Tue, 3 Nov 2020 19:32:39 -0800 Subject: [PATCH 17/53] Clean template Signed-off-by: Jono Yang --- etc/ci/azure-linux.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/etc/ci/azure-linux.yml b/etc/ci/azure-linux.yml index 2e12e5b0..752ae2e6 100644 --- a/etc/ci/azure-linux.yml +++ b/etc/ci/azure-linux.yml @@ -1,6 +1,6 @@ parameters: job_name: '' - image_name: 'ubuntu-16.04' + image_name: '' python_versions: [] test_suites: {} python_architecture: x64 @@ -19,7 +19,6 @@ jobs: python_version: ${{ pyver }} test_suite_label: ${{ tsuite.key }} test_suite: ${{ tsuite.value }} - steps: - checkout: self fetchDepth: 10 From 629abedc035290810b4efa30b3e2cc47951f2344 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Thu, 5 Nov 2020 16:36:20 +0530 Subject: [PATCH 18/53] Update .gitignore to ignore Jupyter temp files Signed-off-by: Ayan Sinha Mahapatra --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 0abbef13..68de2d22 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,6 @@ pyvenv.cfg /.pytest_cache/ lib64 tcl + +# Ignore Jupyter Notebook related temp files +.ipynb_checkpoints/ From ef210cd813de2961fe8ca4a5ec7f14532ea6e9f8 Mon Sep 17 00:00:00 2001 From: Steven Esser Date: Mon, 16 Nov 2020 15:29:48 -0500 Subject: [PATCH 19/53] Quick doc update Signed-off-by: Steven Esser --- README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.rst b/README.rst index 0f1585bc..a0e682f3 100644 --- a/README.rst +++ b/README.rst @@ -17,6 +17,9 @@ A brand new project cd my-new-repo git pull git@github.com:nexB/skeleton + # Create the new repo on GitHub, then update your remote + git remote set-url origin git@github.com:nexB/your-new-repo.git + From here, you can make the appropriate changes to the files for your specific project. Update an existing project From 0b6caf92fe394bec7f9f43a338dc0e2d3a32d5df Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Thu, 10 Dec 2020 14:17:12 +0530 Subject: [PATCH 20/53] Add RTD docs configuration file Adds a RTD configuration file (v2) to customize builds. Signed-off-by: Ayan Sinha Mahapatra --- .readthedocs.yml | 18 ++++++++++++++++++ setup.cfg | 4 ++++ 2 files changed, 22 insertions(+) create mode 100644 .readthedocs.yml diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 00000000..1b71cd9e --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,18 @@ +# .readthedocs.yml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Where the Sphinx conf.py file is located +sphinx: + configuration: docs/source/conf.py + +# Setting the python version and doc build requirements +python: + install: + - method: pip + path: . + extra_requirements: + - docs diff --git a/setup.cfg b/setup.cfg index a7ab2fe6..e4274bb0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -35,3 +35,7 @@ testing = # upstream pytest >= 6 pytest-xdist >= 2 +docs= + Sphinx>=3.3.1 + sphinx-rtd-theme>=0.5.0 + doc8>=0.8.1 \ No newline at end of file From f2c1400e39aa99b2a53392910d01509a0a8114f7 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Thu, 10 Dec 2020 14:19:15 +0530 Subject: [PATCH 21/53] Add basic RTD documentaion #4 Signed-off-by: Ayan Sinha Mahapatra --- docs/Makefile | 20 +++++++++++ docs/make.bat | 35 +++++++++++++++++++ docs/source/conf.py | 63 ++++++++++++++++++++++++++++++++++ docs/source/index.rst | 15 ++++++++ docs/source/skeleton/index.rst | 15 ++++++++ 5 files changed, 148 insertions(+) create mode 100644 docs/Makefile create mode 100644 docs/make.bat create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst create mode 100644 docs/source/skeleton/index.rst diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 00000000..d0c3cbf1 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 00000000..6247f7e2 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 00000000..529cae39 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,63 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + + +# -- Project information ----------------------------------------------------- + +project = 'nexb-skeleton' +copyright = 'nexb Inc.' +author = 'nexb Inc.' + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'sphinx_rtd_theme' + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +html_context = { + 'css_files': [ + '_static/theme_overrides.css', # override wide tables in RTD theme + ], + "display_github": True, + "github_user": "nexB", + "github_repo": "nexb-skeleton", + "github_version": "develop", # branch + "conf_py_path": "/docs/source/", # path in the checkout to the docs root + } \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 00000000..67fcf213 --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,15 @@ +Welcome to nexb-skeleton's documentation! +========================================= + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + skeleton/index + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/source/skeleton/index.rst b/docs/source/skeleton/index.rst new file mode 100644 index 00000000..7dfc6cb4 --- /dev/null +++ b/docs/source/skeleton/index.rst @@ -0,0 +1,15 @@ +# Docs Structure Guide +# Rst docs - https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html +# +# 1. Place docs in folders under source for different sections +# 2. Link them by adding individual index files in each section +# to the main index, and then files for each section to their +# respective index files. +# 3. Use `.. include` statements to include other .rst files +# or part of them, or use hyperlinks to a section of the docs, +# to get rid of repetition. +# https://docutils.sourceforge.io/docs/ref/rst/directives.html#including-an-external-document-fragment +# +# Note: Replace these guide/placeholder docs + +.. include:: ../../../README.rst From e7d19903edae48c176baab11a9a5b7393ae74854 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Thu, 10 Dec 2020 14:20:49 +0530 Subject: [PATCH 22/53] Add RTD requirements file and test scripts Signed-off-by: Ayan Sinha Mahapatra --- docs/scripts/doc8_style_check.sh | 5 +++++ docs/scripts/sphinx_build_link_check.sh | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 docs/scripts/doc8_style_check.sh create mode 100644 docs/scripts/sphinx_build_link_check.sh diff --git a/docs/scripts/doc8_style_check.sh b/docs/scripts/doc8_style_check.sh new file mode 100644 index 00000000..94163239 --- /dev/null +++ b/docs/scripts/doc8_style_check.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# halt script on error +set -e +# Check for Style Code Violations +doc8 --max-line-length 100 source --ignore D000 --quiet \ No newline at end of file diff --git a/docs/scripts/sphinx_build_link_check.sh b/docs/scripts/sphinx_build_link_check.sh new file mode 100644 index 00000000..c5426863 --- /dev/null +++ b/docs/scripts/sphinx_build_link_check.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# halt script on error +set -e +# Build locally, and then check links +sphinx-build -E -W -b linkcheck source build \ No newline at end of file From 7d37af0b6636ab23780503a0e8de8287ab282b66 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Wed, 16 Dec 2020 19:45:34 +0530 Subject: [PATCH 23/53] Add `src` folder to pass CI tests and RTD builds Signed-off-by: Ayan Sinha Mahapatra --- src/README.rst | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/README.rst diff --git a/src/README.rst b/src/README.rst new file mode 100644 index 00000000..efb1a14a --- /dev/null +++ b/src/README.rst @@ -0,0 +1,5 @@ +Package Module +-------------- + +Put your python modules in this directory. + From 03ffc8a23606b22ad728bb093e52264bfe1af658 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Wed, 6 Jan 2021 18:54:31 +0100 Subject: [PATCH 24/53] Ensure we use official full text of Apache 2.0 Taken from https://www.apache.org/licenses/LICENSE-2.0.txt Signed-off-by: Philippe Ombredanne --- apache-2.0.LICENSE | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/apache-2.0.LICENSE b/apache-2.0.LICENSE index d9a10c0d..261eeb9e 100644 --- a/apache-2.0.LICENSE +++ b/apache-2.0.LICENSE @@ -174,3 +174,28 @@ of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From 5e386d9ff0bfe77c170e37abde84313aa45b3a3f Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Thu, 14 Jan 2021 17:04:37 +0100 Subject: [PATCH 25/53] Never ever let Git convert line delimiters Signed-off-by: Philippe Ombredanne --- .gitattributes | 5 +- configure.bat | 242 ++++++++++++++++++++++++------------------------- 2 files changed, 123 insertions(+), 124 deletions(-) diff --git a/.gitattributes b/.gitattributes index 2d555b20..c446d380 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,2 @@ -# Set configure.bat's line ending to CRLF. Sometimes batch scripts don't work -# properly on Windows if the line ending is LF and not CRLF -configure.bat eol=crlf +# Ignore all Git auto CR/LF line endings conversions +* binary diff --git a/configure.bat b/configure.bat index 958f5bf8..f03ea07c 100644 --- a/configure.bat +++ b/configure.bat @@ -1,121 +1,121 @@ -@echo OFF -@setlocal -@rem Copyright (c) nexB Inc. http://www.nexb.com/ - All rights reserved. - -@rem ################################ -@rem # A configuration script for Windows -@rem # -@rem # The options and (optional) arguments are: -@rem # --clean : this is exclusive of anything else and cleans the environment -@rem # from built and installed files -@rem # -@rem # --python < path to python.exe> : this must be the first argument and set -@rem # the path to the Python executable to use. If < path to python.exe> is -@rem # set to "path", then the executable will be the python.exe available -@rem # in the PATH. -@rem ################################ - -@rem Current directory where this .bat files lives -set CFG_ROOT_DIR=%~dp0 -@rem path where a configured Python should live in the current virtualenv if installed -set CONFIGURED_PYTHON=%CFG_ROOT_DIR%tmp\Scripts\python.exe -set PYTHON_EXECUTABLE= - - -@rem parse command line options and arguments -:collectopts -if "%1" EQU "--help" (goto cli_help) -if "%1" EQU "--clean" (call rmdir /s /q "%CFG_ROOT_DIR%tmp") && call exit /b -if "%1" EQU "--python" (set PROVIDED_PYTHON=%~2) && shift && shift && goto collectopts - -@rem If we have a pre-configured Python in our virtualenv, reuse this as-is and run -if exist ""%CONFIGURED_PYTHON%"" ( - set PYTHON_EXECUTABLE=%CONFIGURED_PYTHON% - goto run -) - -@rem If we have a command arg for Python use this as-is -if ""%PROVIDED_PYTHON%""==""path"" ( - @rem use a bare python available in the PATH - set PYTHON_EXECUTABLE=python - goto run -) -if exist ""%PROVIDED_PYTHON%"" ( - set PYTHON_EXECUTABLE=%PROVIDED_PYTHON% - goto run -) - - -@rem otherwise we search for a suitable Python interpreter -:find_python -@rem First check the existence of the "py" launcher (available in Python 3) -@rem if we have it, check if we have a py -3 installed with the good version or a py 2.7 -@rem if not, check if we have an old py 2.7 -@rem exist if all fails - -where py >nul 2>nul -if %ERRORLEVEL% == 0 ( - @rem we have a py launcher, check for the availability of our required Python 3 version - py -3.6 --version >nul 2>nul - if %ERRORLEVEL% == 0 ( - set PYTHON_EXECUTABLE=py -3.6 - ) else ( - @rem we have no required python 3, let's try python 2: - py -2 --version >nul 2>nul - if %ERRORLEVEL% == 0 ( - set PYTHON_EXECUTABLE=py -2 - ) else ( - @rem we have py and no python 3 and 2, exit - echo * Unable to find an installation of Python. - exit /b 1 - ) - ) -) else ( - @rem we have no py launcher, check for a default Python 2 installation - if not exist ""%DEFAULT_PYTHON2%"" ( - echo * Unable to find an installation of Python. - exit /b 1 - ) else ( - set PYTHON_EXECUTABLE=%DEFAULT_PYTHON2% - ) -) - - -:run -@rem without this things may not always work on Windows 10, but this makes things slower -set PYTHONDONTWRITEBYTECODE=1 - -call mkdir "%CFG_ROOT_DIR%tmp" -call curl -o "%CFG_ROOT_DIR%tmp\virtualenv.pyz" https://bootstrap.pypa.io/virtualenv.pyz -call %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%tmp\virtualenv.pyz" "%CFG_ROOT_DIR%tmp" -call "%CFG_ROOT_DIR%tmp\Scripts\activate" -call "%CFG_ROOT_DIR%tmp\Scripts\pip" install --upgrade pip virtualenv setuptools wheel -call "%CFG_ROOT_DIR%tmp\Scripts\pip" install -e .[testing] - -@rem Return a proper return code on failure -if %ERRORLEVEL% neq 0 ( - exit /b %ERRORLEVEL% -) -endlocal -goto activate - - -:cli_help -echo A configuration script for Windows -echo usage: configure [options] [path/to/config/directory] -echo. -echo The options and arguments are: -echo --clean : this is exclusive of anything else and cleans the environment -echo from built and installed files -echo. -echo --python path/to/python.exe : this is set to the path of an alternative -echo Python executable to use. If path/to/python.exe is set to "path", -echo then the executable will be the python.exe available in the PATH. -echo. - - -:activate -@rem Activate the virtualenv -if exist "%CFG_ROOT_DIR%tmp\Scripts\activate" ( - "%CFG_ROOT_DIR%tmp\Scripts\activate" -) +@echo OFF +@setlocal +@rem Copyright (c) nexB Inc. http://www.nexb.com/ - All rights reserved. + +@rem ################################ +@rem # A configuration script for Windows +@rem # +@rem # The options and (optional) arguments are: +@rem # --clean : this is exclusive of anything else and cleans the environment +@rem # from built and installed files +@rem # +@rem # --python < path to python.exe> : this must be the first argument and set +@rem # the path to the Python executable to use. If < path to python.exe> is +@rem # set to "path", then the executable will be the python.exe available +@rem # in the PATH. +@rem ################################ + +@rem Current directory where this .bat files lives +set CFG_ROOT_DIR=%~dp0 +@rem path where a configured Python should live in the current virtualenv if installed +set CONFIGURED_PYTHON=%CFG_ROOT_DIR%tmp\Scripts\python.exe +set PYTHON_EXECUTABLE= + + +@rem parse command line options and arguments +:collectopts +if "%1" EQU "--help" (goto cli_help) +if "%1" EQU "--clean" (call rmdir /s /q "%CFG_ROOT_DIR%tmp") && call exit /b +if "%1" EQU "--python" (set PROVIDED_PYTHON=%~2) && shift && shift && goto collectopts + +@rem If we have a pre-configured Python in our virtualenv, reuse this as-is and run +if exist ""%CONFIGURED_PYTHON%"" ( + set PYTHON_EXECUTABLE=%CONFIGURED_PYTHON% + goto run +) + +@rem If we have a command arg for Python use this as-is +if ""%PROVIDED_PYTHON%""==""path"" ( + @rem use a bare python available in the PATH + set PYTHON_EXECUTABLE=python + goto run +) +if exist ""%PROVIDED_PYTHON%"" ( + set PYTHON_EXECUTABLE=%PROVIDED_PYTHON% + goto run +) + + +@rem otherwise we search for a suitable Python interpreter +:find_python +@rem First check the existence of the "py" launcher (available in Python 3) +@rem if we have it, check if we have a py -3 installed with the good version or a py 2.7 +@rem if not, check if we have an old py 2.7 +@rem exist if all fails + +where py >nul 2>nul +if %ERRORLEVEL% == 0 ( + @rem we have a py launcher, check for the availability of our required Python 3 version + py -3.6 --version >nul 2>nul + if %ERRORLEVEL% == 0 ( + set PYTHON_EXECUTABLE=py -3.6 + ) else ( + @rem we have no required python 3, let's try python 2: + py -2 --version >nul 2>nul + if %ERRORLEVEL% == 0 ( + set PYTHON_EXECUTABLE=py -2 + ) else ( + @rem we have py and no python 3 and 2, exit + echo * Unable to find an installation of Python. + exit /b 1 + ) + ) +) else ( + @rem we have no py launcher, check for a default Python 2 installation + if not exist ""%DEFAULT_PYTHON2%"" ( + echo * Unable to find an installation of Python. + exit /b 1 + ) else ( + set PYTHON_EXECUTABLE=%DEFAULT_PYTHON2% + ) +) + + +:run +@rem without this things may not always work on Windows 10, but this makes things slower +set PYTHONDONTWRITEBYTECODE=1 + +call mkdir "%CFG_ROOT_DIR%tmp" +call curl -o "%CFG_ROOT_DIR%tmp\virtualenv.pyz" https://bootstrap.pypa.io/virtualenv.pyz +call %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%tmp\virtualenv.pyz" "%CFG_ROOT_DIR%tmp" +call "%CFG_ROOT_DIR%tmp\Scripts\activate" +call "%CFG_ROOT_DIR%tmp\Scripts\pip" install --upgrade pip virtualenv setuptools wheel +call "%CFG_ROOT_DIR%tmp\Scripts\pip" install -e .[testing] + +@rem Return a proper return code on failure +if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% +) +endlocal +goto activate + + +:cli_help +echo A configuration script for Windows +echo usage: configure [options] [path/to/config/directory] +echo. +echo The options and arguments are: +echo --clean : this is exclusive of anything else and cleans the environment +echo from built and installed files +echo. +echo --python path/to/python.exe : this is set to the path of an alternative +echo Python executable to use. If path/to/python.exe is set to "path", +echo then the executable will be the python.exe available in the PATH. +echo. + + +:activate +@rem Activate the virtualenv +if exist "%CFG_ROOT_DIR%tmp\Scripts\activate" ( + "%CFG_ROOT_DIR%tmp\Scripts\activate" +) From 2e48dca222b6f5889a3874ed5cda5476a7e9ff9b Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Thu, 14 Jan 2021 17:05:30 +0100 Subject: [PATCH 26/53] Run tests on more OSes and Python versions Signed-off-by: Philippe Ombredanne --- azure-pipelines.yml | 55 ++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fad6928d..9a4c950c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,45 +1,64 @@ ################################################################################ -# We use Azure to run the full tests suites on Python 3.6 -# on Windows (32 and 64), macOS and Linux (64 various distro) +# We use Azure to run the full tests suites on multiple Python 3.x +# on multiple Windows, macOS and Linux versions all on 64 bits +# These jobs are using VMs with Azure-provided Python builds ################################################################################ jobs: -################################################################################ -# These jobs are using VMs and Azure-provided Python 3.6 -################################################################################ + - template: etc/ci/azure-linux.yml + parameters: + job_name: ubuntu16_cpython + image_name: ubuntu-16.04 + python_versions: ['3.6', '3.7', '3.8', '3.9'] + test_suites: + all: tmp/bin/pytest -vvs - template: etc/ci/azure-linux.yml parameters: - job_name: ubuntu18_py36 + job_name: ubuntu18_cpython image_name: ubuntu-18.04 - python_versions: ['3.6'] + python_versions: ['3.6', '3.7', '3.8', '3.9'] + test_suites: + all: tmp/bin/pytest -n 2 -vvs + + - template: etc/ci/azure-linux.yml + parameters: + job_name: ubuntu20_cpython + image_name: ubuntu-20.04 + python_versions: ['3.6', '3.7', '3.8', '3.9'] + test_suites: + all: tmp/bin/pytest -n 2 -vvs + + - template: etc/ci/azure-mac.yml + parameters: + job_name: macos1014_cpython + image_name: macos-10.14 + python_versions: ['3.6', '3.7', '3.8', '3.9'] test_suites: all: tmp/bin/pytest -n 2 -vvs - template: etc/ci/azure-mac.yml parameters: - job_name: macos1015_py36 + job_name: macos1015_cpython image_name: macos-10.15 - python_versions: ['3.6'] + python_versions: ['3.6', '3.7', '3.8', '3.9'] test_suites: all: tmp/bin/pytest -n 2 -vvs - template: etc/ci/azure-win.yml parameters: - job_name: win2019_32_py36 - image_name: windows-2019 - python_versions: ['3.6'] - python_architecture: x86 + job_name: win2016_cpython + image_name: vs2017-win2016 + python_versions: ['3.6', '3.7', '3.8', '3.9'] test_suites: - all: tmp\Scripts\pytest -vvs + all: tmp\Scripts\pytest -n 2 -vvs - template: etc/ci/azure-win.yml parameters: - job_name: win2019_64_py36 + job_name: win2019_cpython image_name: windows-2019 - python_versions: ['3.6'] - python_architecture: x64 + python_versions: ['3.6', '3.7', '3.8', '3.9'] test_suites: - all: tmp\Scripts\pytest -vvs + all: tmp\Scripts\pytest -n 2 -vvs From b959539450069bb573653a3d1265a95cb6c6f563 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Thu, 14 Jan 2021 17:11:01 +0100 Subject: [PATCH 27/53] Do not make wheel universal Also include more license files Signed-off-by: Philippe Ombredanne --- setup.cfg | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index e4274bb0..f7910848 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,11 +1,15 @@ -[wheel] -universal=1 - [metadata] -license_file = apache-2.0.LICENSE +license_files = + apache-2.0.LICENSE + NOTICE + AUTHORS.rst + CHANGELOG.rst name = skeleton author = nexB. Inc. and others author_email = info@aboutcode.org +license = Apache-2.0 + +# description must be on ONE line https://github.com/pypa/setuptools/issues/1390 description = skeleton long_description = file:README.rst url = https://github.com/nexB/skeleton @@ -17,6 +21,7 @@ classifiers = Topic :: Software Development Topic :: Utilities keywords = + utilities [options] package_dir= From 98641a067009e2b1c08682e99cbae84d30f59d15 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Thu, 14 Jan 2021 17:12:00 +0100 Subject: [PATCH 28/53] Format and add license Signed-off-by: Philippe Ombredanne --- configure | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure b/configure index a35c8c90..8f3a68e3 100755 --- a/configure +++ b/configure @@ -1,6 +1,7 @@ #!/usr/bin/env bash # -# Copyright (c) nexB Inc. http://www.nexb.com/ - All rights reserved. +# Copyright (c) nexB Inc. and others. +# SPDX-License-Identifier: Apache-2.0 # set -e From 9fa3f315b7cc1495889b95d50a15cc738d48887f Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Thu, 14 Jan 2021 17:12:13 +0100 Subject: [PATCH 29/53] Format Signed-off-by: Philippe Ombredanne --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 45f160da..bac24a43 100644 --- a/setup.py +++ b/setup.py @@ -3,4 +3,4 @@ import setuptools if __name__ == "__main__": - setuptools.setup() \ No newline at end of file + setuptools.setup() From 0b8cd65580db4ad56b31fc67dd438a006cc66a6b Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Thu, 14 Jan 2021 17:12:27 +0100 Subject: [PATCH 30/53] Improve documentation Signed-off-by: Philippe Ombredanne --- src/README.rst | 5 +---- tests/README.rst | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) create mode 100644 tests/README.rst diff --git a/src/README.rst b/src/README.rst index efb1a14a..ec651fcf 100644 --- a/src/README.rst +++ b/src/README.rst @@ -1,5 +1,2 @@ -Package Module --------------- - -Put your python modules in this directory. +Put your Python source code (and installable data) in this directory. diff --git a/tests/README.rst b/tests/README.rst new file mode 100644 index 00000000..d94783e6 --- /dev/null +++ b/tests/README.rst @@ -0,0 +1,2 @@ +Put your Python test modules in this directory. + From 300769149b530e283a4e4a6aa7f338ca72e5df5e Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Thu, 14 Jan 2021 17:12:48 +0100 Subject: [PATCH 31/53] Format for spaces Signed-off-by: Philippe Ombredanne --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e75f1cec..55fb92c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,11 +36,11 @@ norecursedirs = [ python_files = "*.py" -python_classes="Test" -python_functions="test" +python_classes = "Test" +python_functions = "test" addopts = [ "-rfExXw", "--strict", "--doctest-modules" -] \ No newline at end of file +] From b49895c69abd9713461de61032645cc2c492e73e Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Thu, 14 Jan 2021 17:14:47 +0100 Subject: [PATCH 32/53] Add manifest for source distributions Signed-off-by: Philippe Ombredanne --- MANIFEST.in | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..ef3721e8 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,15 @@ +graft src + +include *.LICENSE +include NOTICE +include *.ABOUT +include *.toml +include *.yml +include *.rst +include setup.* +include configure* +include requirements* +include .git* + +global-exclude *.py[co] __pycache__ *.*~ + From d3e2d28d9f6cde0ded3d8450107d14fb4da05c4e Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Thu, 14 Jan 2021 17:15:06 +0100 Subject: [PATCH 33/53] Add Apache license NOTICE Signed-off-by: Philippe Ombredanne --- NOTICE | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 NOTICE diff --git a/NOTICE b/NOTICE new file mode 100644 index 00000000..65936b2b --- /dev/null +++ b/NOTICE @@ -0,0 +1,19 @@ +# +# Copyright (c) nexB Inc. and others. +# SPDX-License-Identifier: Apache-2.0 +# +# Visit https://aboutcode.org and https://github.com/nexB/ for support and download. +# ScanCode is a trademark of nexB Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# From f46bc48f7b056670f87cbc25e51a0979c7fff8db Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Sun, 24 Jan 2021 12:32:27 +0100 Subject: [PATCH 34/53] Default to 64 bits windows on CI Signed-off-by: Philippe Ombredanne --- etc/ci/azure-win.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/ci/azure-win.yml b/etc/ci/azure-win.yml index 62208574..afe1686f 100644 --- a/etc/ci/azure-win.yml +++ b/etc/ci/azure-win.yml @@ -3,7 +3,7 @@ parameters: image_name: '' python_versions: [] test_suites: {} - python_architecture: x86 + python_architecture: x64 jobs: - job: ${{ parameters.job_name }} From 182532f69052c75d3621ff214ede196cbeed16e7 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Mon, 25 Jan 2021 12:54:13 +0100 Subject: [PATCH 35/53] Use wheels embedded in virtualenv.pyz Signed-off-by: Philippe Ombredanne --- configure | 2 +- configure.bat | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 8f3a68e3..d41bf8e5 100755 --- a/configure +++ b/configure @@ -27,7 +27,7 @@ function setup { # create a virtualenv on Python mkdir -p $CONFIGURE_ROOT_DIR/tmp wget -O $CONFIGURE_ROOT_DIR/tmp/virtualenv.pyz https://bootstrap.pypa.io/virtualenv.pyz - $PYTHON_EXE $CONFIGURE_ROOT_DIR/tmp/virtualenv.pyz $CONFIGURE_ROOT_DIR/tmp + $PYTHON_EXE $CONFIGURE_ROOT_DIR/tmp/virtualenv.pyz --wheel embed --pip embed --setuptools embed --seeder pip $CONFIGURE_ROOT_DIR/tmp source $CONFIGURE_ROOT_DIR/tmp/bin/activate $CONFIGURE_ROOT_DIR/tmp/bin/pip install --upgrade pip virtualenv setuptools wheel } diff --git a/configure.bat b/configure.bat index f03ea07c..ee68f9e6 100644 --- a/configure.bat +++ b/configure.bat @@ -87,7 +87,7 @@ set PYTHONDONTWRITEBYTECODE=1 call mkdir "%CFG_ROOT_DIR%tmp" call curl -o "%CFG_ROOT_DIR%tmp\virtualenv.pyz" https://bootstrap.pypa.io/virtualenv.pyz -call %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%tmp\virtualenv.pyz" "%CFG_ROOT_DIR%tmp" +call %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%tmp\virtualenv.pyz" --wheel embed --pip embed --setuptools embed --seeder pip "%CFG_ROOT_DIR%tmp" call "%CFG_ROOT_DIR%tmp\Scripts\activate" call "%CFG_ROOT_DIR%tmp\Scripts\pip" install --upgrade pip virtualenv setuptools wheel call "%CFG_ROOT_DIR%tmp\Scripts\pip" install -e .[testing] From cd4e87beb91ea5e9380dfeb19c3530c0a92ff192 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Mon, 25 Jan 2021 12:56:18 +0100 Subject: [PATCH 36/53] Do not force an upgrade on virtualenv.pyz embeds Signed-off-by: Philippe Ombredanne --- configure | 1 - configure.bat | 1 - 2 files changed, 2 deletions(-) diff --git a/configure b/configure index d41bf8e5..78e74983 100755 --- a/configure +++ b/configure @@ -29,7 +29,6 @@ function setup { wget -O $CONFIGURE_ROOT_DIR/tmp/virtualenv.pyz https://bootstrap.pypa.io/virtualenv.pyz $PYTHON_EXE $CONFIGURE_ROOT_DIR/tmp/virtualenv.pyz --wheel embed --pip embed --setuptools embed --seeder pip $CONFIGURE_ROOT_DIR/tmp source $CONFIGURE_ROOT_DIR/tmp/bin/activate - $CONFIGURE_ROOT_DIR/tmp/bin/pip install --upgrade pip virtualenv setuptools wheel } diff --git a/configure.bat b/configure.bat index ee68f9e6..00cb1011 100644 --- a/configure.bat +++ b/configure.bat @@ -89,7 +89,6 @@ call mkdir "%CFG_ROOT_DIR%tmp" call curl -o "%CFG_ROOT_DIR%tmp\virtualenv.pyz" https://bootstrap.pypa.io/virtualenv.pyz call %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%tmp\virtualenv.pyz" --wheel embed --pip embed --setuptools embed --seeder pip "%CFG_ROOT_DIR%tmp" call "%CFG_ROOT_DIR%tmp\Scripts\activate" -call "%CFG_ROOT_DIR%tmp\Scripts\pip" install --upgrade pip virtualenv setuptools wheel call "%CFG_ROOT_DIR%tmp\Scripts\pip" install -e .[testing] @rem Return a proper return code on failure From 51510cbdb2f2d066d6652695aed40175a37d88a4 Mon Sep 17 00:00:00 2001 From: Steven Esser Date: Thu, 11 Feb 2021 15:56:55 -0500 Subject: [PATCH 37/53] Fix .gitattributes Signed-off-by: Steven Esser --- .gitattributes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index c446d380..b79df5cd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,2 @@ # Ignore all Git auto CR/LF line endings conversions -* binary +* -text From d6fe59fd2e832075905ecb27235640a2776dad7a Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Fri, 7 May 2021 14:56:42 +0200 Subject: [PATCH 38/53] Update markers syntax for pytest Signed-off-by: Philippe Ombredanne --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 55fb92c3..a3bda449 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,6 @@ python_functions = "test" addopts = [ "-rfExXw", - "--strict", + "--strict-markers", "--doctest-modules" ] From ca6ab2189a6ff6fd093dc9424aa17183a05e6988 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Fri, 7 May 2021 14:59:17 +0200 Subject: [PATCH 39/53] Add fallback version for setuptools_scm This will work even from a git archive or when git is not installed. Signed-off-by: Philippe Ombredanne --- .gitattributes | 1 + pyproject.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitattributes b/.gitattributes index b79df5cd..96c89ceb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ # Ignore all Git auto CR/LF line endings conversions * -text +pyproject.toml export-subst diff --git a/pyproject.toml b/pyproject.toml index a3bda449..52caac46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,6 +3,7 @@ requires = ["setuptools >= 50", "wheel", "setuptools_scm[toml] >= 4"] build-backend = "setuptools.build_meta" [tool.setuptools_scm] +fallback_version = "v9999.$Format:%h-%cs$" [tool.pytest.ini_options] norecursedirs = [ From 1364bbbb9c399bd535686ea4ec6bfc241eb0e689 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Tue, 11 May 2021 10:57:19 +0200 Subject: [PATCH 40/53] Add note for setuptools_scam fallback version Signed-off-by: Philippe Ombredanne --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 52caac46..8eebe91a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,6 +3,8 @@ requires = ["setuptools >= 50", "wheel", "setuptools_scm[toml] >= 4"] build-backend = "setuptools.build_meta" [tool.setuptools_scm] +# this is used populated when creating a git archive +# and when there is .git dir and/or there is no git installed fallback_version = "v9999.$Format:%h-%cs$" [tool.pytest.ini_options] From be851b017a6e5c98ad85a84cda8b3f070e7acf34 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Tue, 11 May 2021 11:00:26 +0200 Subject: [PATCH 41/53] Use azure-posix.yml for linux and macOS Signed-off-by: Philippe Ombredanne --- azure-pipelines.yml | 10 +++--- etc/ci/azure-mac.yml | 36 --------------------- etc/ci/{azure-linux.yml => azure-posix.yml} | 0 3 files changed, 5 insertions(+), 41 deletions(-) delete mode 100644 etc/ci/azure-mac.yml rename etc/ci/{azure-linux.yml => azure-posix.yml} (100%) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9a4c950c..31ef36f0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,7 +7,7 @@ jobs: - - template: etc/ci/azure-linux.yml + - template: etc/ci/azure-posix.yml parameters: job_name: ubuntu16_cpython image_name: ubuntu-16.04 @@ -15,7 +15,7 @@ jobs: test_suites: all: tmp/bin/pytest -vvs - - template: etc/ci/azure-linux.yml + - template: etc/ci/azure-posix.yml parameters: job_name: ubuntu18_cpython image_name: ubuntu-18.04 @@ -23,7 +23,7 @@ jobs: test_suites: all: tmp/bin/pytest -n 2 -vvs - - template: etc/ci/azure-linux.yml + - template: etc/ci/azure-posix.yml parameters: job_name: ubuntu20_cpython image_name: ubuntu-20.04 @@ -31,7 +31,7 @@ jobs: test_suites: all: tmp/bin/pytest -n 2 -vvs - - template: etc/ci/azure-mac.yml + - template: etc/ci/azure-posix.yml parameters: job_name: macos1014_cpython image_name: macos-10.14 @@ -39,7 +39,7 @@ jobs: test_suites: all: tmp/bin/pytest -n 2 -vvs - - template: etc/ci/azure-mac.yml + - template: etc/ci/azure-posix.yml parameters: job_name: macos1015_cpython image_name: macos-10.15 diff --git a/etc/ci/azure-mac.yml b/etc/ci/azure-mac.yml deleted file mode 100644 index 752ae2e6..00000000 --- a/etc/ci/azure-mac.yml +++ /dev/null @@ -1,36 +0,0 @@ -parameters: - job_name: '' - image_name: '' - python_versions: [] - test_suites: {} - python_architecture: x64 - -jobs: - - job: ${{ parameters.job_name }} - - pool: - vmImage: ${{ parameters.image_name }} - - strategy: - matrix: - ${{ each pyver in parameters.python_versions }}: - ${{ each tsuite in parameters.test_suites }}: - ${{ format('py{0} {1}', pyver, tsuite.key) }}: - python_version: ${{ pyver }} - test_suite_label: ${{ tsuite.key }} - test_suite: ${{ tsuite.value }} - steps: - - checkout: self - fetchDepth: 10 - - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(python_version)' - architecture: '${{ parameters.python_architecture }}' - displayName: 'Install Python $(python_version)' - - - script: ./configure - displayName: 'Run Configure' - - - script: $(test_suite) - displayName: 'Run $(test_suite_label) tests with py$(python_version) on ${{ parameters.job_name }}' diff --git a/etc/ci/azure-linux.yml b/etc/ci/azure-posix.yml similarity index 100% rename from etc/ci/azure-linux.yml rename to etc/ci/azure-posix.yml From 4f0aecf4f2a01c71b8d0f54987cd68de5f7922c2 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Tue, 11 May 2021 11:14:23 +0200 Subject: [PATCH 42/53] Adopt new configure script derived from ScanCode Signed-off-by: Philippe Ombredanne --- configure | 164 ++++++++++++++++++++++++---- configure.bat | 238 ++++++++++++++++++++++++++--------------- etc/ci/azure-posix.yml | 7 +- etc/ci/azure-win.yml | 5 +- 4 files changed, 304 insertions(+), 110 deletions(-) diff --git a/configure b/configure index 78e74983..25ab0ce9 100755 --- a/configure +++ b/configure @@ -1,43 +1,169 @@ #!/usr/bin/env bash # -# Copyright (c) nexB Inc. and others. +# Copyright (c) nexB Inc. and others. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +# See https://github.com/nexB/ for support or download. +# See https://aboutcode.org for more information about nexB OSS projects. # set -e #set -x -# source this script for a basic setup and configuration for local development +################################ +# A configuration script to set things up: +# create a virtualenv and install or update thirdparty packages. +# Source this script for initial configuration +# Use configure --help for details +# +# This script will search for a virtualenv.pyz app in etc/thirdparty/virtualenv.pyz +# Otherwise it will download the latest from the VIRTUALENV_PYZ_URL default +################################ +CLI_ARGS=$1 -CONFIGURE_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +################################ +# Defaults. Change these variables to customize this script +################################ +# Requirement arguments passed to pip and used by default or with --dev. +REQUIREMENTS="--editable ." +DEV_REQUIREMENTS="--editable .[testing]" -if [[ "$1" == "--clean" ]]; then - rm -rf "$CONFIGURE_ROOT_DIR/tmp" - exit +# where we create a virtualenv +VIRTUALENV_DIR=tmp + +# Cleanable files and directories with the --clean option +CLEANABLE=" + build + tmp" + +# extra arguments passed to pip +PIP_EXTRA_ARGS=" " + +# the URL to download virtualenv.pyz if needed +VIRTUALENV_PYZ_URL=https://bootstrap.pypa.io/virtualenv.pyz +################################ + + +################################ +# Current directory where this script lives +CFG_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CFG_BIN_DIR=$CFG_ROOT_DIR/$VIRTUALENV_DIR/bin + + +################################ +# Set the quiet flag to empty if not defined +if [[ "$CFG_QUIET" == "" ]]; then + CFG_QUIET=" " fi -if [[ "$PYTHON_EXE" == "" ]]; then - PYTHON_EXE=python3 +################################ +# find a proper Python to run +# Use environment variables or a file if available. +# Otherwise the latest Python by default. +if [[ "$PYTHON_EXECUTABLE" == "" ]]; then + # check for a file named PYTHON_EXECUTABLE + if [ -f "$CFG_ROOT_DIR/PYTHON_EXECUTABLE" ]; then + PYTHON_EXECUTABLE=$(cat "$CFG_ROOT_DIR/PYTHON_EXECUTABLE") + else + PYTHON_EXECUTABLE=python3 + fi fi -function setup { - # create a virtualenv on Python - mkdir -p $CONFIGURE_ROOT_DIR/tmp - wget -O $CONFIGURE_ROOT_DIR/tmp/virtualenv.pyz https://bootstrap.pypa.io/virtualenv.pyz - $PYTHON_EXE $CONFIGURE_ROOT_DIR/tmp/virtualenv.pyz --wheel embed --pip embed --setuptools embed --seeder pip $CONFIGURE_ROOT_DIR/tmp - source $CONFIGURE_ROOT_DIR/tmp/bin/activate +################################ +cli_help() { + echo An initial configuration script + echo " usage: ./configure [options]" + echo + echo The default is to configure for regular use. Use --dev for development. + echo + echo The options are: + echo " --clean: clean built and installed files and exit." + echo " --dev: configure the environment for development." + echo " --help: display this help message and exit." + echo + echo By default, the python interpreter version found in the path is used. + echo Alternatively, the PYTHON_EXECUTABLE environment variable can be set to + echo configure another Python executable interpreter to use. If this is not + echo set, a file named PYTHON_EXECUTABLE containing a single line with the + echo path of the Python executable to use will be checked last. + set +e + exit } -setup +clean() { + # Remove cleanable file and directories and files from the root dir. + echo "* Cleaning ..." + for cln in $CLEANABLE; + do rm -rf "${CFG_ROOT_DIR:?}/${cln:?}"; + done + set +e + exit +} -$CONFIGURE_ROOT_DIR/tmp/bin/pip install -e .[testing] -if [ -f "$CONFIGURE_ROOT_DIR/tmp/bin/activate" ]; then - source "$CONFIGURE_ROOT_DIR/tmp/bin/activate" -fi +create_virtualenv() { + # create a virtualenv for Python + # Note: we do not use the bundled Python 3 "venv" because its behavior and + # presence is not consistent across Linux distro and sometimes pip is not + # included either by default. The virtualenv.pyz app cures all these issues. + + VENV_DIR="$1" + if [ ! -f "$CFG_BIN_DIR/python" ]; then + + mkdir -p "$CFG_ROOT_DIR/$VENV_DIR" + + if [ -f "$CFG_ROOT_DIR/etc/thirdparty/virtualenv.pyz" ]; then + VIRTUALENV_PYZ="$CFG_ROOT_DIR/etc/thirdparty/virtualenv.pyz" + else + VIRTUALENV_PYZ="$CFG_ROOT_DIR/$VENV_DIR/virtualenv.pyz" + wget -O "$VIRTUALENV_PYZ" "$VIRTUALENV_PYZ_URL" + fi + + $PYTHON_EXECUTABLE "$VIRTUALENV_PYZ" \ + --wheel embed --pip embed --setuptools embed \ + --seeder pip \ + --never-download \ + --no-periodic-update \ + --no-vcs-ignore \ + $CFG_QUIET \ + "$CFG_ROOT_DIR/$VENV_DIR" + fi +} + + +install_packages() { + # install requirements in virtualenv + # note: --no-build-isolation means that pip/wheel/setuptools will not + # be reinstalled a second time and reused from the virtualenv and this + # speeds up the installation. + # We always have the PEP517 build dependencies installed already. + + "$CFG_BIN_DIR/pip" install \ + --upgrade \ + --no-build-isolation \ + $CFG_QUIET \ + $PIP_EXTRA_ARGS \ + $1 +} + + +################################ +# Main command line entry point +CFG_DEV_MODE=0 +CFG_REQUIREMENTS=$REQUIREMENTS + +case "$CLI_ARGS" in + --help) cli_help;; + --clean) clean;; + --dev) CFG_REQUIREMENTS="$DEV_REQUIREMENTS" && CFG_DEV_MODE=1;; +esac + +create_virtualenv "$VIRTUALENV_DIR" +install_packages "$CFG_REQUIREMENTS" +. "$CFG_BIN_DIR/activate" set +e diff --git a/configure.bat b/configure.bat index 00cb1011..8c497ba0 100644 --- a/configure.bat +++ b/configure.bat @@ -1,120 +1,180 @@ @echo OFF @setlocal -@rem Copyright (c) nexB Inc. http://www.nexb.com/ - All rights reserved. + +@rem Copyright (c) nexB Inc. and others. All rights reserved. +@rem SPDX-License-Identifier: Apache-2.0 +@rem See http://www.apache.org/licenses/LICENSE-2.0 for the license text. +@rem See https://github.com/nexB/ for support or download. +@rem See https://aboutcode.org for more information about nexB OSS projects. + @rem ################################ -@rem # A configuration script for Windows -@rem # -@rem # The options and (optional) arguments are: -@rem # --clean : this is exclusive of anything else and cleans the environment -@rem # from built and installed files -@rem # -@rem # --python < path to python.exe> : this must be the first argument and set -@rem # the path to the Python executable to use. If < path to python.exe> is -@rem # set to "path", then the executable will be the python.exe available -@rem # in the PATH. +@rem # A configuration script to set things up: +@rem # create a virtualenv and install or update thirdparty packages. +@rem # Source this script for initial configuration +@rem # Use configure --help for details + +@rem # This script will search for a virtualenv.pyz app in etc\thirdparty\virtualenv.pyz +@rem # Otherwise it will download the latest from the VIRTUALENV_PYZ_URL default @rem ################################ -@rem Current directory where this .bat files lives -set CFG_ROOT_DIR=%~dp0 -@rem path where a configured Python should live in the current virtualenv if installed -set CONFIGURED_PYTHON=%CFG_ROOT_DIR%tmp\Scripts\python.exe -set PYTHON_EXECUTABLE= +@rem ################################ +@rem # Defaults. Change these variables to customize this script +@rem ################################ + +@rem # Requirement arguments passed to pip and used by default or with --dev. +set "REQUIREMENTS=--editable ." +set "DEV_REQUIREMENTS=--editable .[testing]" + +@rem # where we create a virtualenv +set "VIRTUALENV_DIR=tmp" + +@rem # Cleanable files and directories to delete with the --clean option +set "CLEANABLE=build tmp" -@rem parse command line options and arguments -:collectopts -if "%1" EQU "--help" (goto cli_help) -if "%1" EQU "--clean" (call rmdir /s /q "%CFG_ROOT_DIR%tmp") && call exit /b -if "%1" EQU "--python" (set PROVIDED_PYTHON=%~2) && shift && shift && goto collectopts +@rem # extra arguments passed to pip +set "PIP_EXTRA_ARGS= " -@rem If we have a pre-configured Python in our virtualenv, reuse this as-is and run -if exist ""%CONFIGURED_PYTHON%"" ( - set PYTHON_EXECUTABLE=%CONFIGURED_PYTHON% - goto run +@rem # the URL to download virtualenv.pyz if needed +set VIRTUALENV_PYZ_URL=https://bootstrap.pypa.io/virtualenv.pyz +@rem ################################ + + +@rem ################################ +@rem # Current directory where this script lives +set CFG_ROOT_DIR=%~dp0 +set "CFG_BIN_DIR=%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\Scripts" + + +@rem ################################ +@rem # Set the quiet flag to empty if not defined +if not defined CFG_QUIET ( + set "CFG_QUIET= " ) -@rem If we have a command arg for Python use this as-is -if ""%PROVIDED_PYTHON%""==""path"" ( - @rem use a bare python available in the PATH - set PYTHON_EXECUTABLE=python - goto run + +@rem ################################ +@rem # Main command line entry point +set CFG_DEV_MODE=0 +set "CFG_REQUIREMENTS=%REQUIREMENTS%" + +if "%1" EQU "--help" (goto cli_help) +if "%1" EQU "--clean" (goto clean) +if "%1" EQU "--dev" ( + set "CFG_REQUIREMENTS=%DEV_REQUIREMENTS%" + set CFG_DEV_MODE=1 ) -if exist ""%PROVIDED_PYTHON%"" ( - set PYTHON_EXECUTABLE=%PROVIDED_PYTHON% - goto run +if "%1" EQU "--python" ( + echo "The --python is now DEPRECATED. Use the PYTHON_EXECUTABLE environment + echo "variable instead. Run configure --help for details." + exit /b 0 ) +@rem ################################ +@rem # find a proper Python to run +@rem # Use environment variables or a file if available. +@rem # Otherwise the latest Python by default. +if not defined PYTHON_EXECUTABLE ( + @rem # check for a file named PYTHON_EXECUTABLE + if exist ""%CFG_ROOT_DIR%\PYTHON_EXECUTABLE"" ( + set /p PYTHON_EXECUTABLE=<""%CFG_ROOT_DIR%\PYTHON_EXECUTABLE"" + ) else ( + set "PYTHON_EXECUTABLE=py" + ) +) -@rem otherwise we search for a suitable Python interpreter -:find_python -@rem First check the existence of the "py" launcher (available in Python 3) -@rem if we have it, check if we have a py -3 installed with the good version or a py 2.7 -@rem if not, check if we have an old py 2.7 -@rem exist if all fails +:create_virtualenv +@rem # create a virtualenv for Python +@rem # Note: we do not use the bundled Python 3 "venv" because its behavior and +@rem # presence is not consistent across Linux distro and sometimes pip is not +@rem # included either by default. The virtualenv.pyz app cures all these issues. -where py >nul 2>nul -if %ERRORLEVEL% == 0 ( - @rem we have a py launcher, check for the availability of our required Python 3 version - py -3.6 --version >nul 2>nul - if %ERRORLEVEL% == 0 ( - set PYTHON_EXECUTABLE=py -3.6 - ) else ( - @rem we have no required python 3, let's try python 2: - py -2 --version >nul 2>nul - if %ERRORLEVEL% == 0 ( - set PYTHON_EXECUTABLE=py -2 - ) else ( - @rem we have py and no python 3 and 2, exit - echo * Unable to find an installation of Python. - exit /b 1 - ) +if not exist ""%CFG_BIN_DIR%\python.exe"" ( + if not exist "%CFG_BIN_DIR%" ( + mkdir %CFG_BIN_DIR% ) -) else ( - @rem we have no py launcher, check for a default Python 2 installation - if not exist ""%DEFAULT_PYTHON2%"" ( - echo * Unable to find an installation of Python. - exit /b 1 + + if exist ""%CFG_ROOT_DIR%\etc\thirdparty\virtualenv.pyz"" ( + %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%\etc\thirdparty\virtualenv.pyz" ^ + --wheel embed --pip embed --setuptools embed ^ + --seeder pip ^ + --never-download ^ + --no-periodic-update ^ + --no-vcs-ignore ^ + %CFG_QUIET% ^ + %CFG_ROOT_DIR%\%VIRTUALENV_DIR% ) else ( - set PYTHON_EXECUTABLE=%DEFAULT_PYTHON2% + if not exist ""%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\virtualenv.pyz"" ( + curl -o "%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\virtualenv.pyz" %VIRTUALENV_PYZ_URL% + + if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% + ) + ) + %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\virtualenv.pyz" ^ + --wheel embed --pip embed --setuptools embed ^ + --seeder pip ^ + --never-download ^ + --no-periodic-update ^ + --no-vcs-ignore ^ + %CFG_QUIET% ^ + %CFG_ROOT_DIR%\%VIRTUALENV_DIR% ) ) +if %ERRORLEVEL% neq 0 ( + exit /b %ERRORLEVEL% +) + -:run -@rem without this things may not always work on Windows 10, but this makes things slower -set PYTHONDONTWRITEBYTECODE=1 +:install_packages +@rem # install requirements in virtualenv +@rem # note: --no-build-isolation means that pip/wheel/setuptools will not +@rem # be reinstalled a second time and reused from the virtualenv and this +@rem # speeds up the installation. +@rem # We always have the PEP517 build dependencies installed already. -call mkdir "%CFG_ROOT_DIR%tmp" -call curl -o "%CFG_ROOT_DIR%tmp\virtualenv.pyz" https://bootstrap.pypa.io/virtualenv.pyz -call %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%tmp\virtualenv.pyz" --wheel embed --pip embed --setuptools embed --seeder pip "%CFG_ROOT_DIR%tmp" -call "%CFG_ROOT_DIR%tmp\Scripts\activate" -call "%CFG_ROOT_DIR%tmp\Scripts\pip" install -e .[testing] +%CFG_BIN_DIR%\pip install ^ + --upgrade ^ + --no-build-isolation ^ + %CFG_QUIET% ^ + %PIP_EXTRA_ARGS% ^ + %CFG_REQUIREMENTS% -@rem Return a proper return code on failure if %ERRORLEVEL% neq 0 ( exit /b %ERRORLEVEL% ) -endlocal -goto activate +exit /b 0 + + +@rem ################################ :cli_help -echo A configuration script for Windows -echo usage: configure [options] [path/to/config/directory] -echo. -echo The options and arguments are: -echo --clean : this is exclusive of anything else and cleans the environment -echo from built and installed files -echo. -echo --python path/to/python.exe : this is set to the path of an alternative -echo Python executable to use. If path/to/python.exe is set to "path", -echo then the executable will be the python.exe available in the PATH. -echo. - - -:activate -@rem Activate the virtualenv -if exist "%CFG_ROOT_DIR%tmp\Scripts\activate" ( - "%CFG_ROOT_DIR%tmp\Scripts\activate" + echo An initial configuration script + echo " usage: configure [options]" + echo " " + echo The default is to configure for regular use. Use --dev for development. + echo " " + echo The options are: + echo " --clean: clean built and installed files and exit." + echo " --dev: configure the environment for development." + echo " --help: display this help message and exit." + echo " " + echo By default, the python interpreter version found in the path is used. + echo Alternatively, the PYTHON_EXECUTABLE environment variable can be set to + echo configure another Python executable interpreter to use. If this is not + echo set, a file named PYTHON_EXECUTABLE containing a single line with the + echo path of the Python executable to use will be checked last. + exit /b 0 + + +:clean +@rem # Remove cleanable file and directories and files from the root dir. +echo "* Cleaning ..." +for %%F in (%CLEANABLE%) do ( + rmdir /s /q "%CFG_ROOT_DIR%\%%F" >nul 2>&1 + del /f /q "%CFG_ROOT_DIR%\%%F" >nul 2>&1 ) +exit /b 0 diff --git a/etc/ci/azure-posix.yml b/etc/ci/azure-posix.yml index 752ae2e6..0921d9b3 100644 --- a/etc/ci/azure-posix.yml +++ b/etc/ci/azure-posix.yml @@ -19,6 +19,7 @@ jobs: python_version: ${{ pyver }} test_suite_label: ${{ tsuite.key }} test_suite: ${{ tsuite.value }} + steps: - checkout: self fetchDepth: 10 @@ -29,7 +30,11 @@ jobs: architecture: '${{ parameters.python_architecture }}' displayName: 'Install Python $(python_version)' - - script: ./configure + - script: | + python3 --version + python$(python_version) --version + echo "python$(python_version)" > PYTHON_EXECUTABLE + ./configure --dev displayName: 'Run Configure' - script: $(test_suite) diff --git a/etc/ci/azure-win.yml b/etc/ci/azure-win.yml index afe1686f..03d89274 100644 --- a/etc/ci/azure-win.yml +++ b/etc/ci/azure-win.yml @@ -29,7 +29,10 @@ jobs: architecture: '${{ parameters.python_architecture }}' displayName: 'Install Python $(python_version)' - - script: configure --python path + - script: | + python --version + echo | set /p=python> PYTHON_EXECUTABLE + configure --dev displayName: 'Run Configure' - script: $(test_suite) From aa04429ae6e5d05ef8ee2a0fbad9872014463a25 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Tue, 11 May 2021 11:17:09 +0200 Subject: [PATCH 43/53] Add notes on customization Signed-off-by: Philippe Ombredanne --- README.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.rst b/README.rst index a0e682f3..a2911736 100644 --- a/README.rst +++ b/README.rst @@ -32,3 +32,12 @@ Update an existing project git merge skeleton/main --allow-unrelated-histories This is also the workflow to use when updating the skeleton files in any given repository. + + +Customizing +----------- + +You typically want to perform these customizations: + +- remove or update the src/README.rst and tests/README.rst files +- check the configure and configure.bat defaults From 56ada8fffacac14140bf016fd3f6bee4f4615fcc Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Tue, 11 May 2021 11:19:12 +0200 Subject: [PATCH 44/53] Adopt new configure --dev convention Signed-off-by: Philippe Ombredanne --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7a342dff..1b52eb20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ python: - "3.8" # Scripts to run at install stage -install: ./configure +install: ./configure --dev # Scripts to run at script stage script: tmp/bin/pytest From 0dbcdc9f6c929b3d030910a69e5566c149e15d7a Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Tue, 11 May 2021 11:21:48 +0200 Subject: [PATCH 45/53] Clarify CHANGELOG to be Rst Signed-off-by: Philippe Ombredanne --- CHANGELOG.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5f8bc8da..fc2b6e32 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,8 @@ -Release notes -------------- -### Version 0.0.0 +Changelog +========= + + +v0.0.0 +------ *xxxx-xx-xx* -- Initial release. From d21aef35a61675289bbebf963030b539c10a7b28 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Tue, 11 May 2021 11:22:22 +0200 Subject: [PATCH 46/53] Add skeleton release notes to README.rst This was they do not end up in the template CHANGELOG.rst Signed-off-by: Philippe Ombredanne --- README.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.rst b/README.rst index a2911736..b84a0491 100644 --- a/README.rst +++ b/README.rst @@ -41,3 +41,10 @@ You typically want to perform these customizations: - remove or update the src/README.rst and tests/README.rst files - check the configure and configure.bat defaults + + +Release Notes +------------- + +- 2021-05-11: adopt new configure scripts from ScanCode TK that allows correct + configuration of which Python version is used. From 3aeb2ec68d313b75430539d9e4d2e57c53ef6998 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Mon, 31 May 2021 11:24:39 +0200 Subject: [PATCH 47/53] Update format Signed-off-by: Philippe Ombredanne --- setup.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index f7910848..f192f220 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,7 +20,7 @@ classifiers = Programming Language :: Python :: 3 :: Only Topic :: Software Development Topic :: Utilities -keywords = +keywords = utilities [options] @@ -43,4 +43,4 @@ testing = docs= Sphinx>=3.3.1 sphinx-rtd-theme>=0.5.0 - doc8>=0.8.1 \ No newline at end of file + doc8>=0.8.1 From 2c412e8222d4d615384a24e2ddc472b0c9703916 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Mon, 31 May 2021 11:24:57 +0200 Subject: [PATCH 48/53] Add Python 3.9 to Travis Signed-off-by: Philippe Ombredanne --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 1b52eb20..1a90a385 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ python: - "3.6" - "3.7" - "3.8" + - "3.9" # Scripts to run at install stage install: ./configure --dev From 69eec23792d59dbdc3a3acb1711884560cf27073 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Mon, 31 May 2021 11:27:35 +0200 Subject: [PATCH 49/53] Format and remove spurious spaces From https://github.com/nexB/typecode/pull/20 Reported-by: Pierre Tardy Signed-off-by: Philippe Ombredanne --- configure.bat | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configure.bat b/configure.bat index 8c497ba0..80d0a43b 100644 --- a/configure.bat +++ b/configure.bat @@ -9,7 +9,7 @@ @rem ################################ -@rem # A configuration script to set things up: +@rem # A configuration script to set things up: @rem # create a virtualenv and install or update thirdparty packages. @rem # Source this script for initial configuration @rem # Use configure --help for details @@ -48,7 +48,7 @@ set "CFG_BIN_DIR=%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\Scripts" @rem ################################ -@rem # Set the quiet flag to empty if not defined +@rem # Set the quiet flag to empty if not defined if not defined CFG_QUIET ( set "CFG_QUIET= " ) @@ -65,8 +65,8 @@ if "%1" EQU "--dev" ( set "CFG_REQUIREMENTS=%DEV_REQUIREMENTS%" set CFG_DEV_MODE=1 ) -if "%1" EQU "--python" ( - echo "The --python is now DEPRECATED. Use the PYTHON_EXECUTABLE environment +if "%1" EQU "--python"( + echo "The --python option is now DEPRECATED. Use the PYTHON_EXECUTABLE environment" echo "variable instead. Run configure --help for details." exit /b 0 ) @@ -76,7 +76,7 @@ if "%1" EQU "--python" ( @rem # Use environment variables or a file if available. @rem # Otherwise the latest Python by default. if not defined PYTHON_EXECUTABLE ( - @rem # check for a file named PYTHON_EXECUTABLE + @rem # check for a file named PYTHON_EXECUTABLE if exist ""%CFG_ROOT_DIR%\PYTHON_EXECUTABLE"" ( set /p PYTHON_EXECUTABLE=<""%CFG_ROOT_DIR%\PYTHON_EXECUTABLE"" ) else ( From 0e09ad9eb77ca0b580d71baa428955a0a56d19f1 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Mon, 31 May 2021 19:17:43 +0200 Subject: [PATCH 50/53] Bump to more modern version of setuptools_scm And remove v prefix from fallback version Signed-off-by: Philippe Ombredanne --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8eebe91a..852f0fce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,11 @@ [build-system] -requires = ["setuptools >= 50", "wheel", "setuptools_scm[toml] >= 4"] +requires = ["setuptools >= 50", "wheel", "setuptools_scm[toml] >= 6"] build-backend = "setuptools.build_meta" [tool.setuptools_scm] # this is used populated when creating a git archive # and when there is .git dir and/or there is no git installed -fallback_version = "v9999.$Format:%h-%cs$" +fallback_version = "9999.$Format:%h-%cs$" [tool.pytest.ini_options] norecursedirs = [ From e339a70e1a46b613fa73b9d0a9273fe7640acb8d Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Mon, 31 May 2021 19:18:09 +0200 Subject: [PATCH 51/53] Add space for correct syntax Signed-off-by: Philippe Ombredanne --- configure.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.bat b/configure.bat index 80d0a43b..c12f937f 100644 --- a/configure.bat +++ b/configure.bat @@ -65,7 +65,7 @@ if "%1" EQU "--dev" ( set "CFG_REQUIREMENTS=%DEV_REQUIREMENTS%" set CFG_DEV_MODE=1 ) -if "%1" EQU "--python"( +if "%1" EQU "--python" ( echo "The --python option is now DEPRECATED. Use the PYTHON_EXECUTABLE environment" echo "variable instead. Run configure --help for details." exit /b 0 From 9dff54a1f827ee2d40761fae72cd0c1b69489818 Mon Sep 17 00:00:00 2001 From: Chin Yeung Li Date: Thu, 17 Jun 2021 17:59:32 +0800 Subject: [PATCH 52/53] Create junction from Scripts to bin * This is handy for windows to have the same path as linux Signed-off-by: Chin Yeung Li --- configure.bat | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.bat b/configure.bat index c12f937f..bafa126e 100644 --- a/configure.bat +++ b/configure.bat @@ -142,6 +142,9 @@ if %ERRORLEVEL% neq 0 ( %PIP_EXTRA_ARGS% ^ %CFG_REQUIREMENTS% +@rem # Create junction to bin to have the same directory between linux and windows +mklink /J %CFG_ROOT_DIR%\%VIRTUALENV_DIR%\bin %CFG_ROOT_DIR%\%VIRTUALENV_DIR%\Scripts + if %ERRORLEVEL% neq 0 ( exit /b %ERRORLEVEL% ) From 7f0b49c2e92af6a49f2cbdd232fec76eaec38d57 Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Mon, 2 Aug 2021 10:10:24 -0700 Subject: [PATCH 53/53] Removed unused skeleton files * Do not run tests on vendored pip code Signed-off-by: Jono Yang --- .gitignore | 1 + .travis.yml | 18 ------------------ pyproject.toml | 3 ++- setup.cfg | 4 +--- src/README.rst | 2 -- tests/README.rst | 2 -- 6 files changed, 4 insertions(+), 26 deletions(-) delete mode 100644 .travis.yml delete mode 100644 src/README.rst delete mode 100644 tests/README.rst diff --git a/.gitignore b/.gitignore index 762cc89f..83e00b21 100644 --- a/.gitignore +++ b/.gitignore @@ -112,6 +112,7 @@ venv/ ENV/ env.bak/ venv.bak/ +tmp # Spyder project settings .spyderproject diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 430f9d0c..00000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -# See https://config.travis-ci.com/ for a full list of configuration options. - -os: linux - -dist: xenial - -language: python -python: - - "3.6" - - "3.7" - - "3.8" - - "3.9" - -# Scripts to run at install stage -install: ./configure --dev - -# Scripts to run at script stage -script: tmp/bin/pytest diff --git a/pyproject.toml b/pyproject.toml index dbb33ac2..a32bcb21 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,7 +34,8 @@ norecursedirs = [ "thirdparty", "tmp", "tests/data", - ".eggs" + ".eggs", + "src/fetchcode/vcs/pip", ] python_files = "*.py" diff --git a/setup.cfg b/setup.cfg index 1fec5f17..333451c6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,9 +39,7 @@ testing = # upstream pytest pytest-xdist -full = - fetchcode -docs= +docs = Sphinx>=3.3.1 sphinx-rtd-theme>=0.5.0 doc8>=0.8.1 diff --git a/src/README.rst b/src/README.rst deleted file mode 100644 index ec651fcf..00000000 --- a/src/README.rst +++ /dev/null @@ -1,2 +0,0 @@ -Put your Python source code (and installable data) in this directory. - diff --git a/tests/README.rst b/tests/README.rst deleted file mode 100644 index d94783e6..00000000 --- a/tests/README.rst +++ /dev/null @@ -1,2 +0,0 @@ -Put your Python test modules in this directory. -