Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Improve packagecode and other release prep #2992

Merged
merged 85 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
e38ed76
init
orsinium Nov 11, 2019
c777451
+examples
orsinium Nov 11, 2019
c0b12b2
+poeytry's static
orsinium Nov 11, 2019
2a21119
+cfg reader
orsinium Nov 11, 2019
5902aa1
refactor static parser
orsinium Nov 11, 2019
14c4479
test on a few more examples
orsinium Nov 11, 2019
98f6798
+base reader
orsinium Nov 12, 2019
3fc49ed
+subprocess based readers skeleton
orsinium Nov 12, 2019
a6e8652
make cmd reader work
orsinium Nov 12, 2019
8a83f96
simplify type convertion for static parser
orsinium Nov 12, 2019
0540a6b
put all keyword args into static result
orsinium Nov 12, 2019
77bfea9
make static parser really short and smart
orsinium Nov 12, 2019
9e162a1
use setuptools for cfg reader
orsinium Nov 12, 2019
9722d6d
reuse fields
orsinium Nov 12, 2019
80f7dbd
+cli
orsinium Nov 12, 2019
4e5fa9e
do normalization
orsinium Nov 13, 2019
e9b6bef
provide interface
orsinium Nov 13, 2019
e686539
add metainfo and ci
orsinium Nov 13, 2019
1b61d12
release
orsinium Nov 13, 2019
2a5c88a
build ci only once
orsinium Nov 13, 2019
23a662d
sort imports
orsinium Nov 13, 2019
5da30a7
fix flake8
orsinium Nov 13, 2019
2ef82d9
check more pythons
orsinium Nov 13, 2019
0477166
trigger ci
orsinium Nov 13, 2019
f94b2e2
py 3.5 compat
orsinium Nov 13, 2019
104ad4a
Merge pull request #1 from dephell/ci
orsinium Nov 13, 2019
9ff032b
release
orsinium Nov 13, 2019
de4257a
check type annotations
orsinium Nov 14, 2019
97e3aef
Merge pull request #2 from dephell/typing
orsinium Nov 14, 2019
b5762b1
fix a few details and release
orsinium Nov 14, 2019
7d21e4f
_pkginfo: Improve error handling
jayvdb Dec 14, 2019
762b283
Merge pull request #6 from jayvdb/fix-pkginfo
orsinium Dec 18, 2019
d9946bd
bump version to 0.2.2
orsinium Dec 18, 2019
4b1e995
Fix 'CommandReader' on Windows
espdev Dec 27, 2019
8b3bae0
Merge pull request #7 from espdev/win
orsinium Dec 27, 2019
1054bcc
bump version to 0.2.3
orsinium Dec 30, 2019
02c1939
Better reporting of command failures
jhermann Feb 3, 2020
13ae64c
fix CI
orsinium May 28, 2020
2031e40
Merge pull request #9 from dephell/fix-ci
orsinium May 28, 2020
97c4b2b
Merge remote-tracking branch 'origin/master' into patch-1
orsinium May 28, 2020
ea9c7e3
format
orsinium May 28, 2020
444487e
Merge pull request #8 from jhermann/patch-1
orsinium May 28, 2020
b43cc29
set tag format and change email
orsinium May 28, 2020
1586bc4
bump version to 0.2.4
orsinium May 28, 2020
c273002
Improve Gradle script handling
pombredanne May 24, 2022
eb93183
Improve searching for a thirdparty dir with wheels
pombredanne May 25, 2022
e8e4322
Format code
pombredanne May 29, 2022
22ffa1e
Format code
pombredanne May 29, 2022
ba481ba
Fetch sources from native first
pombredanne Jun 4, 2022
242d0c3
Yield a package Resource earlier
pombredanne Jun 4, 2022
26be981
Use SCANCODE_DEBUG_PACKAGE_API for tracing
pombredanne Jun 4, 2022
76b4915
Add missing ABOUT file
pombredanne Jun 4, 2022
25e9a07
Use SCANCODE_DEBUG_PACKAGE_API for tracing
pombredanne Jun 4, 2022
e4621f8
Improve handling of NO_INDEX
pombredanne Jun 4, 2022
0cdd4f6
Load optionally nested requirement files
pombredanne Jun 4, 2022
4665969
Reorg setup.py test files
pombredanne Jun 5, 2022
5d0e249
Test files do not need to be executable
pombredanne Jun 5, 2022
b66be3b
Remove unused code
pombredanne Jun 6, 2022
9c30d8a
Remove unused code
pombredanne Jun 6, 2022
06b47ee
Improve PyPI packages handling
pombredanne Jun 7, 2022
8ed97a6
Add more Python tests
pombredanne Jun 8, 2022
426a039
Also consider non-string in setup.py
pombredanne Jun 8, 2022
d24acbc
Move modules to match ScanCode locations
pombredanne Jun 8, 2022
49f069f
Remove unused code
pombredanne Jun 8, 2022
39f975b
Use only subset of code to parser setup.*
pombredanne Jun 8, 2022
5edb581
Improve handling of setup.py
pombredanne Jun 8, 2022
5578104
Improve detecetion of setup()* and other minor improvements
pombredanne Jun 8, 2022
7b1de9c
Imporva validation of license keys
pombredanne Jun 10, 2022
ac0d145
Correct expected results for Composer JSON
pombredanne Jun 10, 2022
1182264
Remove unused test file
pombredanne Jun 10, 2022
465f4e7
Force x86-64 mode on macOS M1/ARM
pombredanne Jun 12, 2022
d84b106
Improve ABOUT files
pombredanne Jun 12, 2022
fcc26fc
Only parse setup.py files
pombredanne Jun 12, 2022
34b4b9b
Merge remote-tracking branch 'dephell/master' into improve-gradle
pombredanne Jun 12, 2022
d8aadb5
Use new parser for setup.py
pombredanne Jun 12, 2022
05f93c4
Add more setup.py tests
pombredanne Jun 12, 2022
9dbbccd
Merge latest develop
pombredanne Jun 12, 2022
aa5c662
Adapt PyPI tests with correct requirements
pombredanne Jun 12, 2022
40d6e1d
Correct test expectations
pombredanne Jun 13, 2022
6687b6f
Add more PyPI tests
pombredanne Jun 13, 2022
dc82d18
Correctly compute path depth in PyPI
pombredanne Jun 13, 2022
5c653ad
Support conversion from YAML to JSON to CSV
pombredanne Jun 13, 2022
4b827d1
Fix typo in comment
pombredanne Jun 13, 2022
49f434a
Remove unused imports
pombredanne Jun 13, 2022
03193c0
Add docstring to pypi.is_setup_call()
pombredanne Jun 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/scancode-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,16 @@ jobs:
rm -rf thirdparty build dist
rm -rf .eggs src/scancode_toolkit.egg-info src/scancode_toolkit_mini.egg-info
mkdir -p thirdparty
venv/bin/python etc/scripts/fetch_thirdparty.py \
--requirements=requirements-native.txt \
--dest=thirdparty \
--sdists
venv/bin/python etc/scripts/fetch_thirdparty.py \
--requirements=requirements.txt \
--dest=thirdparty \
--python-version=$python_version \
--operating-system=$operating_system \
--wheels
venv/bin/python etc/scripts/fetch_thirdparty.py \
--requirements=requirements-native.txt \
--dest=thirdparty \
--sdists
venv/bin/python setup.py --quiet sdist --formats=$formats
venv/bin/python etc/release/scancode_rename_archives.py dist/ _py$python_version-$operating_system

Expand Down Expand Up @@ -208,16 +208,16 @@ jobs:
rm -rf thirdparty build dist
rm -rf .eggs src/scancode_toolkit.egg-info src/scancode_toolkit_mini.egg-info
mkdir -p thirdparty
venv/bin/python etc/scripts/fetch_thirdparty.py \
--requirements=requirements-native.txt \
--dest=thirdparty \
--sdists
venv/bin/python etc/scripts/fetch_thirdparty.py \
--requirements=requirements.txt \
--dest=thirdparty \
--python-version=$python_version \
--operating-system=$operating_system \
--wheels
venv/bin/python etc/scripts/fetch_thirdparty.py \
--requirements=requirements-native.txt \
--dest=thirdparty \
--sdists
venv/bin/python setup.py --quiet sdist --formats=$formats
venv/bin/python etc/release/scancode_rename_archives.py dist/ _py$python_version-$operating_system

Expand Down Expand Up @@ -262,16 +262,16 @@ jobs:
rm -rf thirdparty build dist
rm -rf .eggs src/scancode_toolkit.egg-info src/scancode_toolkit_mini.egg-info
mkdir -p thirdparty
venv/bin/python etc/scripts/fetch_thirdparty.py \
--requirements=requirements-native.txt \
--dest=thirdparty \
--sdists
venv/bin/python etc/scripts/fetch_thirdparty.py \
--requirements=requirements.txt \
--dest=thirdparty \
--python-version=$python_version \
--operating-system=$operating_system \
--wheels
venv/bin/python etc/scripts/fetch_thirdparty.py \
--requirements=requirements-native.txt \
--dest=thirdparty \
--sdists
venv/bin/python setup.py --quiet sdist --formats=$formats
venv/bin/python etc/release/scancode_rename_archives.py dist/ _py$python_version-$operating_system

Expand Down
157 changes: 133 additions & 24 deletions configure
Original file line number Diff line number Diff line change
@@ -1,15 +1,129 @@
#!/usr/bin/env bash
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Apache-2.0 AND MIT
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# ScanCode is a trademark of nexB Inc.
# See https://github.com/nexB/ for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#

set -e
#set -x

###################################################################################
###################################################################################
# from https://raw.githubusercontent.com/mkropat/sh-realpath/58c03982cfd8accbcf0c4426a4adf0f120a8b2bb/realpath.sh
# realpath emulation for portability on *nix
# this allow running scancode from arbitrary locations and from symlinks
#
# Copyright (c) 2014 Michael Kropat
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.


realpath() {
canonicalize_path "$(resolve_symlinks "$1")"
}

resolve_symlinks() {
_resolve_symlinks "$1"
}

_resolve_symlinks() {
_assert_no_path_cycles "$@" || return

local dir_context path
path=$(readlink -- "$1")
if [ $? -eq 0 ]; then
dir_context=$(dirname -- "$1")
_resolve_symlinks "$(_prepend_dir_context_if_necessary "$dir_context" "$path")" "$@"
else
printf '%s\n' "$1"
fi
}

_prepend_dir_context_if_necessary() {
if [ "$1" = . ]; then
printf '%s\n' "$2"
else
_prepend_path_if_relative "$1" "$2"
fi
}

_prepend_path_if_relative() {
case "$2" in
/* ) printf '%s\n' "$2" ;;
* ) printf '%s\n' "$1/$2" ;;
esac
}

_assert_no_path_cycles() {
local target path

target=$1
shift

for path in "$@"; do
if [ "$path" = "$target" ]; then
return 1
fi
done
}

canonicalize_path() {
if [ -d "$1" ]; then
_canonicalize_dir_path "$1"
else
_canonicalize_file_path "$1"
fi
}

_canonicalize_dir_path() {
(cd "$1" 2>/dev/null && pwd -P)
}

_canonicalize_file_path() {
local dir file
dir=$(dirname -- "$1")
file=$(basename -- "$1")
(cd "$dir" 2>/dev/null && printf '%s/%s\n' "$(pwd -P)" "$file")
}

###################################################################################
###################################################################################

# Now run configure proper

################################
# Setup current directory where this script lives
CFG_BIN="$( realpath "${BASH_SOURCE[0]}" )"
CFG_ROOT_DIR="$( cd "$( dirname "${CFG_BIN}" )" && pwd )"

CFG_BIN_DIR=$CFG_ROOT_DIR/$VIRTUALENV_DIR/bin

# force relaunching under X86-64 architecture on macOS M1/ARM
if [[ $OSTYPE == 'darwin'* && $(uname -m) == 'arm64' ]]; then
arch -x86_64 /bin/bash -c "$CFG_ROOT_DIR/configure $@"
exit $?
fi

################################
# A configuration script to set things up:
# create a virtualenv and install or update thirdparty packages.
Expand Down Expand Up @@ -52,14 +166,21 @@ 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 "


################################
# Thirdparty package locations and index handling
# Find packages from the local thirdparty directory or from thirdparty.aboutcode.org
# offline mode for scancode installation with no index at all
if [ -d "$CFG_ROOT_DIR/thirdparty" ]; then
PIP_EXTRA_ARGS="--no-index --find-links $CFG_ROOT_DIR/thirdparty"
# Find packages from the local thirdparty directory if present
thirddir=$CFG_ROOT_DIR/thirdparty
if [[ "$(echo $thirddir/*.whl)x" != "$thirddir/*.whlx" ]]; then
PIP_EXTRA_ARGS="$NO_INDEX --find-links $CFG_ROOT_DIR/thirdparty"
fi


################################
# Set the quiet flag to empty if not defined
if [[ "$CFG_QUIET" == "" ]]; then
Expand Down Expand Up @@ -102,25 +223,13 @@ create_virtualenv() {
wget -O "$VIRTUALENV_PYZ" "$VIRTUALENV_PYZ_URL" 2>/dev/null || curl -o "$VIRTUALENV_PYZ" "$VIRTUALENV_PYZ_URL"
fi

if [[ $OSTYPE == 'darwin'* && $(uname -m) == 'arm64' ]]; then
arch -x86_64 /bin/bash -c "$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\" "
else
$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
$PYTHON_EXECUTABLE "$VIRTUALENV_PYZ" \
--wheel embed --pip embed --setuptools embed \
--never-download \
--no-periodic-update \
--no-vcs-ignore \
$CFG_QUIET \
"$CFG_ROOT_DIR/$VENV_DIR"
fi
}

Expand Down
1 change: 0 additions & 1 deletion etc/scripts/fetch_thirdparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
is_flag=True,
help="Use on disk cached PyPI indexes list of packages and versions and do not refetch if present.",
)

@click.help_option("-h", "--help")
def fetch_thirdparty(
requirements_files,
Expand Down
2 changes: 1 addition & 1 deletion etc/scripts/misc/openhub_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def fetch_and_save_license(url, force=False, directory="openhub_licenses"):

os.makedirs(directory, exist_ok=True)
print(f" Fetching: {url}")
time.sleep(.1)
time.sleep(0.1)
content = urlopen(url).read()
with open(lic_file, "wb") as of:
of.write(content)
Expand Down
24 changes: 13 additions & 11 deletions etc/scripts/misc/test_openhub_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,26 @@


def test_scraping_unicode_and_ascii():
test_file = os.path.join(
os.path.dirname(__file__), "testdata/openhub_html.html"
)
test_file = os.path.join(os.path.dirname(__file__), "testdata/openhub_html.html")
with open(test_file, "r") as f:
test_content = f.read()

licenses = list(openhub_scraper.list_licenses_on_page(test_content))

result = [i for i in licenses if i["name"] == "Sleepycat License"]
expected = [{
"url": "https://www.openhub.net/licenses/sleepycat",
"name": "Sleepycat License",
}]
expected = [
{
"url": "https://www.openhub.net/licenses/sleepycat",
"name": "Sleepycat License",
}
]
assert result == expected

result = [i for i in licenses if i["name"] == "Sun Public License v1.0"]
expected = [{
"url": "https://www.openhub.net/licenses/sun_public",
"name": "Sun Public License v1.0",
}]
expected = [
{
"url": "https://www.openhub.net/licenses/sun_public",
"name": "Sun Public License v1.0",
}
]
assert result == expected
Loading