diff --git a/.github/workflows/docs-ci.yml b/.github/workflows/docs-ci.yml index fd407fd..200c230 100644 --- a/.github/workflows/docs-ci.yml +++ b/.github/workflows/docs-ci.yml @@ -23,7 +23,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install Dependencies - run: ./configure --dev + run: make dev - name: Check documentation and HTML for errors and dead links run: make docs-check diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 0f19707..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,25 +0,0 @@ -graft src -graft docs -graft etc - -include *.LICENSE -include NOTICE -include *.ABOUT -include *.toml -include *.yml -include *.rst -include *.png -include setup.* -include configure* -include requirements* -include .dockerignore -include .gitignore -include .readthedocs.yml -include manage.py -include Dockerfile* -include Makefile -include MANIFEST.in - -include .VERSION - -global-exclude *.py[co] __pycache__ *.*~ diff --git a/Makefile b/Makefile index 3041547..3ac7383 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,34 @@ -# SPDX-License-Identifier: Apache-2.0 # -# Copyright (c) nexB Inc. and others. All rights reserved. -# ScanCode is a trademark of nexB Inc. # SPDX-License-Identifier: Apache-2.0 -# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. -# See https://github.com/aboutcode-org/skeleton for support or download. -# See https://aboutcode.org for more information about nexB OSS projects. -# +# Copyright (c) nexB Inc. and contributors +# See https://github.com/aboutcode-org/aboutcode.federated/ for support and sources # Python version can be specified with `$ PYTHON_EXE=python3.x make conf` PYTHON_EXE?=python3 VENV=venv ACTIVATE?=. ${VENV}/bin/activate; +virtualenv: + @echo "-> Bootstrap the virtualenv with PYTHON_EXE=${PYTHON_EXE}" + @${PYTHON_EXE} -m venv ${VENV} + @${ACTIVATE} pip install --upgrade pip -conf: +conf: virtualenv @echo "-> Install dependencies" - ./configure + @${ACTIVATE} pip install --editable . -dev: +dev: virtualenv @echo "-> Configure and install development dependencies" - ./configure --dev + @${ACTIVATE} pip install --editable .[dev] + +build: test + @echo "-> Building sdist and wheel" + rm -rf build/ dist/ + ${VENV}/bin/flot --pyproject pyproject.toml --sdist --wheel + +publish: build + @echo "-> Publish built sdist and wheel to PyPi" + ${VENV}/bin/twine upload dist/* doc8: @echo "-> Run doc8 validation" @@ -38,16 +46,19 @@ check: @echo "-> Run Ruff format validation" @${ACTIVATE} ruff format --check @$(MAKE) doc8 - @echo "-> Run ABOUT files validation" - @${ACTIVATE} about check etc/ clean: @echo "-> Clean the Python env" - ./configure --clean + rm -rf ${VENV} build/ dist/ docs/_build/ pip-selfcheck.json .tox .pytest_cache/ .coverage + find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete -test: +test: check @echo "-> Run the test suite" - ${VENV}/bin/pytest -vvs + ${ACTIVATE} ${PYTHON_EXE} -m pytest -vvs + +bump: + @echo "-> Bump the version" + venv/bin/bump-my-version bump patch docs: rm -rf docs/_build/ @@ -57,4 +68,4 @@ docs-check: @${ACTIVATE} sphinx-build -E -W -b html docs/source docs/_build/ @${ACTIVATE} sphinx-build -E -W -b linkcheck docs/source docs/_build/ -.PHONY: conf dev check valid clean test docs docs-check +.PHONY: virtualenv conf dev build publish doc8 valid check clean test bump docs docs-check diff --git a/src/aboutcode/federated/__init__.py b/aboutcode/federated/__init__.py similarity index 100% rename from src/aboutcode/federated/__init__.py rename to aboutcode/federated/__init__.py diff --git a/configure b/configure deleted file mode 100755 index 6d317d4..0000000 --- a/configure +++ /dev/null @@ -1,201 +0,0 @@ -#!/usr/bin/env bash -# -# 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/aboutcode-org/ for support or download. -# See https://aboutcode.org for more information about nexB OSS projects. -# - -set -e -#set -x - -################################ -# 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 -# -# NOTE: please keep in sync with Windows script configure.bat -# -# 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 - -################################ -# Defaults. Change these variables to customize this script -################################ - -# Requirement arguments passed to pip and used by default or with --dev. -REQUIREMENTS="--editable . --constraint requirements.txt" -DEV_REQUIREMENTS="--editable .[dev] --constraint requirements.txt --constraint requirements-dev.txt" - -# where we create a virtualenv -VIRTUALENV_DIR=venv - -# Cleanable files and directories to delete with the --clean option -CLEANABLE="build dist venv .cache .eggs *.egg-info docs/_build/ pip-selfcheck.json" - -# 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 - - -################################ -# Install with or without and index. With "--no-index" this is using only local wheels -# This is an offline mode with no index and no network operations -# NO_INDEX="--no-index " -NO_INDEX="" - - -################################ -# Thirdparty package locations and index handling -# Find packages from the local thirdparty directory if present -THIRDPARDIR=$CFG_ROOT_DIR/thirdparty -if [[ "$(echo $THIRDPARDIR/*.whl)x" != "$THIRDPARDIR/*.whlx" ]]; then - PIP_EXTRA_ARGS="$NO_INDEX --find-links $THIRDPARDIR" -fi - - -################################ -# Set the quiet flag to empty if not defined -if [[ "$CFG_QUIET" == "" ]]; then - CFG_QUIET=" " -fi - - -################################ -# Find a proper Python to run -# Use environment variables or a file if available. -# Otherwise the latest Python by default. -find_python() { - 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 -} - - -################################ -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" 2>/dev/null || curl -o "$VIRTUALENV_PYZ" "$VIRTUALENV_PYZ_URL" - fi - - $PYTHON_EXECUTABLE "$VIRTUALENV_PYZ" \ - --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 -} - - -################################ -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 -} - - -################################ -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 - find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete - set +e - exit -} - - -################################ -# Main command line entry point -CFG_REQUIREMENTS=$REQUIREMENTS - -# We are using getopts to parse option arguments that start with "-" -while getopts :-: optchar; do - case "${optchar}" in - -) - case "${OPTARG}" in - help ) cli_help;; - clean ) find_python && clean;; - dev ) CFG_REQUIREMENTS="$DEV_REQUIREMENTS";; - esac;; - esac -done - - -PIP_EXTRA_ARGS="$PIP_EXTRA_ARGS" - -find_python -create_virtualenv "$VIRTUALENV_DIR" -install_packages "$CFG_REQUIREMENTS" -. "$CFG_BIN_DIR/activate" - - -set +e diff --git a/configure.bat b/configure.bat deleted file mode 100644 index 15ab701..0000000 --- a/configure.bat +++ /dev/null @@ -1,203 +0,0 @@ -@echo OFF -@setlocal - -@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/aboutcode-org/ for support or download. -@rem See https://aboutcode.org for more information about nexB OSS projects. - - -@rem ################################ -@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 # NOTE: please keep in sync with POSIX script configure - -@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 ################################ -@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 . --constraint requirements.txt" -set "DEV_REQUIREMENTS=--editable .[dev] --constraint requirements.txt --constraint requirements-dev.txt" - -@rem # where we create a virtualenv -set "VIRTUALENV_DIR=venv" - -@rem # Cleanable files and directories to delete with the --clean option -set "CLEANABLE=build dist venv .cache .eggs" - -@rem # extra arguments passed to pip -set "PIP_EXTRA_ARGS= " - -@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 # Thirdparty package locations and index handling -@rem # Find packages from the local thirdparty directory -if exist "%CFG_ROOT_DIR%\thirdparty" ( - set PIP_EXTRA_ARGS=--find-links "%CFG_ROOT_DIR%\thirdparty" -) - - -@rem ################################ -@rem # Set the quiet flag to empty if not defined -if not defined CFG_QUIET ( - set "CFG_QUIET= " -) - - -@rem ################################ -@rem # Main command line entry point -set "CFG_REQUIREMENTS=%REQUIREMENTS%" - -:again -if not "%1" == "" ( - if "%1" EQU "--help" (goto cli_help) - if "%1" EQU "--clean" (goto clean) - if "%1" EQU "--dev" ( - set "CFG_REQUIREMENTS=%DEV_REQUIREMENTS%" - ) - shift - goto again -) - -set "PIP_EXTRA_ARGS=%PIP_EXTRA_ARGS%" - - -@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 ################################ -: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. - -if not exist "%CFG_BIN_DIR%\python.exe" ( - if not exist "%CFG_BIN_DIR%" ( - mkdir "%CFG_BIN_DIR%" - ) - - if exist "%CFG_ROOT_DIR%\etc\thirdparty\virtualenv.pyz" ( - %PYTHON_EXECUTABLE% "%CFG_ROOT_DIR%\etc\thirdparty\virtualenv.pyz" ^ - --pip embed --setuptools embed ^ - --seeder pip ^ - --never-download ^ - --no-periodic-update ^ - --no-vcs-ignore ^ - %CFG_QUIET% ^ - "%CFG_ROOT_DIR%\%VIRTUALENV_DIR%" - ) else ( - 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" ^ - --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% -) - - -@rem ################################ -: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. - -"%CFG_BIN_DIR%\pip" install ^ - --upgrade ^ - --no-build-isolation ^ - %CFG_QUIET% ^ - %PIP_EXTRA_ARGS% ^ - %CFG_REQUIREMENTS% - - -@rem ################################ -:create_bin_junction -@rem # Create junction to bin to have the same directory between linux and windows -if exist "%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\bin" ( - rmdir /s /q "%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\bin" -) -mklink /J "%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\bin" "%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\Scripts" - -if %ERRORLEVEL% neq 0 ( - exit /b %ERRORLEVEL% -) - -exit /b 0 - - -@rem ################################ -: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. - exit /b 0 - - -@rem ################################ -: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/pyproject.toml b/pyproject.toml index f106e69..892fb7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,106 @@ [build-system] -requires = ["setuptools >= 50", "wheel"] -build-backend = "setuptools.build_meta" +requires = [ "flot>=0.7.3" ] +build-backend = "flot.buildapi" + +[project] +name = "aboutcode.federated" +version = "1.0.2" +description = "A library for AboutCode PURL-based federated identifiers" +readme = "README.rst" +license = { text = "Apache-2.0" } +requires-python = ">=3.10" + +authors = [ + { name = "AboutCode and others", email = "info@aboutcode.org" }, +] + +keywords = [ + "purl", + "Package-URL", + "open source", + "package", + "sca", + "scan", + "hash", +] + +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Software Development", + "Topic :: Utilities", +] + +dependencies = [ + "packageurl_python == 0.17.6", + "saneyaml == 0.6.1", + "requests == 2.33.1", + "uritemplate == 4.2.0", +] + +urls = { Homepage = "https://github.com/aboutcode-org/aboutcode.federated" } + + +[project.optional-dependencies] +dev = [ + "pytest >= 7.0.1", + "pytest-xdist >= 2", + "aboutcode-toolkit >= 7.0.2", + "twine", + "ruff", + "Sphinx>=5.0.2", + "sphinx-rtd-theme>=1.0.0", + "sphinx-reredirects >= 0.1.2", + "doc8>=0.11.2", + "sphinx-autobuild", + "sphinx-rtd-dark-mode>=1.3.0", + "sphinx-copybutton", + "flot", +] + + +[tool.bumpversion] +current_version = "1.0.2" +allow_dirty = true + +files = [ + { filename = "pyproject.toml" }, +] + +[tool.flot] +includes = [ + "aboutcode/**/*", +] + +excludes = [ + # Python compiled files + "**/*.py[cod]", + "**/*.egg-info", + # Various junk and temp files + "**/.DS_Store", + "**/*~", + "**/.*.sw[po]", + "**/.ve", + "**/*.bak", + "**/.ipynb_checkpoints", +] + +metadata_files = ["apache-2.0.LICENSE", "NOTICE"] + +editable_paths = ["."] + +sdist_extra_includes = [ + "tests/**/*", + "docs/**/*", + "README.rst", + ".gitignore", +] +sdist_extra_excludes = [ + "docs/_build/**/*", +] -[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 = "9999.$Format:%h-%cs$" [tool.pytest.ini_options] norecursedirs = [ @@ -68,7 +163,7 @@ include = [ "." ] -# ignore test data and testfiles: they should never be linted nor formatted +# ignore test data and testfiles: they should never be linted nor formatted exclude = [ # main style "**/tests/data/**/*", diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7637bf8..0000000 --- a/setup.cfg +++ /dev/null @@ -1,73 +0,0 @@ -[metadata] -name = aboutcode.federated -version = 1.0.2 -license = Apache-2.0 - -# description must be on ONE line https://github.com/pypa/setuptools/issues/1390 -description = "A library for AboutCode PURL-based federated identifiers" -long_description = file:README.rst -long_description_content_type = text/x-rst -url = https://github.com/aboutcode-org/aboutcode.federated - -author = nexB. Inc. and others -author_email = info@aboutcode.org - -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Topic :: Software Development - Topic :: Utilities - -keywords = - purl - Package-URL - open source - package - sca - scan - hash - -license_files = - apache-2.0.LICENSE - NOTICE - AUTHORS.rst - CHANGELOG.rst - CODE_OF_CONDUCT.rst - README.rst - -[options] -python_requires = >=3.10 - -package_dir = - =src -packages = find: -include_package_data = true -zip_safe = false - -install_requires = - packageurl_python == 0.17.6 - saneyaml == 0.6.1 - requests == 2.33.1 - uritemplate == 4.2.0 - - -[options.packages.find] -where = src - - -[options.extras_require] -dev = - pytest >= 7.0.1 - pytest-xdist >= 2 - aboutcode-toolkit >= 7.0.2 - twine - ruff - Sphinx>=5.0.2 - sphinx-rtd-theme>=1.0.0 - sphinx-reredirects >= 0.1.2 - doc8>=0.11.2 - sphinx-autobuild - sphinx-rtd-dark-mode>=1.3.0 - sphinx-copybutton diff --git a/setup.py b/setup.py deleted file mode 100644 index bac24a4..0000000 --- a/setup.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env python - -import setuptools - -if __name__ == "__main__": - setuptools.setup()