Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
756611c
Add python3.6 to .travis.yml
Aug 15, 2017
6ff9250
Add a custom-modified version of Transcrypt to dev dependencies
Jul 13, 2017
50e0582
Hack to get Transcrypt installed
pombredanne Jul 13, 2017
a2cfefc
Add dependencies for Transcrypt on Python 3.6
pombredanne Jul 13, 2017
1fc0929
Add PyYAML as dependency for transpile step
Jul 17, 2017
97fba7e
Add script that calls transcrypt on license_expression
Jul 17, 2017
3b3190f
Capture Transcrypt output to decide if transpile was ok
Jul 17, 2017
a5b7780
Add hand-coded Keyword instead of collections.namedtuple
Jul 18, 2017
a125148
Add hand-coded Deque instead of collections.deque
Jul 18, 2017
d34727d
Use manual .setdefault checks instead of collections.defaultdict
Jul 18, 2017
c0c9dd8
Patch transcrypt to respect utils.commandArgs.source
Jul 18, 2017
c713d9c
Drop copy.deepcopy because it is never used
Jul 19, 2017
609e5c6
Swap copy.copy for a hand-written copy function
Jul 19, 2017
b36df12
Drop functools.total_ordering, two reasons:
Jul 19, 2017
19db8c7
Drop import string, two reasons:
Jul 19, 2017
1e917d4
Move class Deque to my_collections, reuse it in Aho-Corasik
Jul 19, 2017
420902c
Drop OrderedDict, use built-in dict
Jul 19, 2017
3f2f37e
Drop all arguments out of super() calls
Jul 20, 2017
4305b03
Drop unicode, assume python3 is used
Jul 20, 2017
caea371
Drop object() and use a custom dummy class instead
Jul 20, 2017
58bfe30
Add a simple index.html to test __javascript__/__init__.js
Jul 20, 2017
6a9ac18
Rewrite __nonzero__ and __bool__ with explicit def *(self):
Jul 20, 2017
7711b8d
Remove isinstance(stmt, bytes) because Transcrypt does not have bytes
Jul 21, 2017
59a7c3a
Avoid calling list() and use a list comprehension instead
Jul 25, 2017
f35e5f5
Rename Result.sort to Result.reorder to avoid wrong function call
Jul 25, 2017
dbcc566
Drop Result.reorder and use result.reorder (i.e. use an instance)
Jul 25, 2017
3c69292
Change Scan.iter to Scan.iterate because Transcrypt mangles it
Jul 26, 2017
e34c268
Drop an explicit try - catch because of TypeError in Trie.add
Jul 26, 2017
5b9490a
Drop custom transcrypt_true() function, use -t switch instead
Jul 27, 2017
437bd08
Rewrite splitter without regular expressions and generators
Jul 28, 2017
e19118e
Drop isinstance(key, bytes) check from LicenseSymbol
Jul 28, 2017
3652569
Drop *args and **kwargs from LicenseSymbol- and Like
Jul 28, 2017
4f1c387
Drop key=sym_or_tok in favour of just sym_or_tok in LicenseSymbol
Jul 28, 2017
6d39db2
Rewrite strip_and_skip_spaces without a generator
Jul 28, 2017
35b439a
Rewrite group_results_for_with_subexpression without generators
Jul 28, 2017
456f1ce
Avoid named arguments when initializing Keyword
Aug 1, 2017
5888c86
Move src/license_expression/__javascript__ into its own directory
Aug 3, 2017
22fd4bc
Remove transpilation results, add __javascript__ to .gitignore
Aug 3, 2017
6b0da96
Improve logging output
Aug 3, 2017
03d0b25
Fix boolean.py -> license_expression in comments
Aug 3, 2017
353471d
Initialize js project: package.json and test.js directory
Aug 4, 2017
80c6e92
Separate switches and their arguments in subprocess.run
Aug 4, 2017
03eae1a
Remove 'import logging' from _pyahocorasick.py
Aug 7, 2017
404a495
Use -p switch to inject a module.exports
Aug 7, 2017
4f1cc51
Add first simple Licensing test
Aug 7, 2017
b6ba29f
Add more tests, figure out potential problems on the way
Aug 7, 2017
3b1b813
Use .__eq__ instead of '==' and '==='
Aug 7, 2017
750be93
Add even more tests from test_license_expression.py
Aug 7, 2017
f94f5de
Drop issubclass from boolean.py
Aug 10, 2017
6d063ff
Drop bytes from as_symbols because Transcrypt does not do bytes
Aug 10, 2017
87c69b5
Drop 'if symbols' check from as_symbols
Aug 10, 2017
534f647
Rewrite as_symbols without the generator
Aug 10, 2017
79909c0
Drop generator from self.iterate of Trie
Aug 10, 2017
a6254d2
Drop iterator in self.add_unmatched of Trie
Aug 11, 2017
a10591f
Call reorder classmethod on an object instance of Result
Aug 11, 2017
b0197f4
Add first test for .tokenize and .parse that use predefined symbols
Aug 15, 2017
6245e9a
Drop del keyword from filter_overlapping of _pyahocorasick
Aug 15, 2017
f5de326
Add a ./configure call to .travis.yml to install transpile deps
Aug 15, 2017
a3ec6f2
Update Transcrypt to a custom version similar to 3.6.45
Aug 15, 2017
5214b33
Add transpile to norecursedirs
Aug 15, 2017
c33f1ef
Convert PosixPath to a string explicitly
Aug 16, 2017
a918372
Rewrite .travis.yml: use fixed versions of python and node
Aug 15, 2017
ff0664b
Change appveyor.yml: drop Python 2.7 and add Python 3.6
Aug 16, 2017
da90250
Rename test.js to tests.js to match python tests
Aug 17, 2017
57555c0
Add (simple) test cases for one predefined symbols (as a string)
Aug 17, 2017
432c86f
Add (simple) tests for one predefined symbol as LicenseSymbol
Aug 17, 2017
f56cca1
Add tests for single operation + two licenses
Aug 17, 2017
70cba45
Bump Transcrypt to a custom 3.6.47 version
Aug 18, 2017
48b7878
Avoid a key function that returns anything but a number
Aug 18, 2017
67f8944
Add tests for simple expressions with several predefined Symbols
Aug 18, 2017
0477cbd
Add a mixed OR-AND test case with several predefined symbols
Aug 18, 2017
0452bf7
Add a test that uses LicenseSymbol alias with 'or'
Aug 18, 2017
d525b72
Add the --browser flag to transpile.py
Aug 21, 2017
e56d606
Use the complete set of function arguments in LicenseSymbol
Aug 21, 2017
24d98c0
Rewrite Result.reorder classmethod as a standalone function
Aug 21, 2017
b399768
Rewrite LicenseSymbol.symbol_like classmethod as a standalone function
Aug 21, 2017
13f6f41
Add basic tests for the LicenseWithExceptionSymbol
Aug 21, 2017
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
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,12 @@ docs/_build
*.bak
/.cache/

# Transpilation results
__javascript__

# node.js and yarn
/node_modules/
yarn.lock

/share/
/local/
/local/
27 changes: 16 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
# This deliberately is not "python" as a work-around to support
# multi-os builds with custom Python versions in Travis CI.
language: cpp
language: generic

os:
- osx
- linux
os:
- osx
- linux

env:
matrix:
- PYTHON_EXE="`which python2`"
- PYTHON_EXE="`which python3.4`"
- PYTHON_EXE="`which python3.5`"
- PYENV_VERSION='3.6.1' NODE_VERSION='6.11.2' PYENV_VERSION_STRING='Python 3.6.1'
# - PYENV_VERSION='3.5.3' NODE_VERSION='8.4.0' PYENV_VERSION_STRING='Python 3.5.3'

before_install:
- nvm install ${NODE_VERSION} && nvm use ${NODE_VERSION}
- source setup-pyenv.sh

install:
- PYTHON_EXE=$PYTHON_EXE ./configure
- npm install
- ./configure
- ./configure ./etc/conf/dev/transpile
- ./bin/python transpile/transpile.py

script:
- "bin/py.test -vvs"
- ./bin/py.test -vvs
- npm test

notifications:
irc:
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ version: '{build}'

environment:
matrix:
- PYTHON_EXE: "C:\\Python27\\python.exe"
- PYTHON_EXE: "C:\\Python27-x64\\python.exe"
- PYTHON_EXE: "C:\\Python34\\python.exe"
- PYTHON_EXE: "C:\\Python34-x64\\python.exe"
- PYTHON_EXE: "C:\\Python35\\python.exe"
- PYTHON_EXE: "C:\\Python35-x64\\python.exe"
- PYTHON_EXE: "C:\\Python36\\python.exe"
- PYTHON_EXE: "C:\\Python36-x64\\python.exe"

install:
- configure
Expand Down
3 changes: 3 additions & 0 deletions etc/conf/dev/transpile/base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Transpiling
thirdparty/dev/Transcrypt-3.6.47-py2.py3-none-any.whl
thirdparty/dev/PyYAML-3.12.tar.gz
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "license-expression",
"version": "0.93.0",
"main": "src/license_expression.js/__javascript__/__init__.js",
"repository": "git@github.com:nexB/license-expression",
"author": "nexB Inc. <info@nexb.com>",
"license": "Apache-2.0",
"scripts": {
"test": "mocha tests.js"
},
"devDependencies": {
"mocha": "^3.5.0"
}
}
151 changes: 151 additions & 0 deletions setup-pyenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#!/usr/bin/env bash
# NOTE: This script needs to be sourced so it can modify the environment.
#
# Environment variables that can be set:
# - PYENV_VERSION
# Python to install [required]
# - PYENV_VERSION_STRING
# String to `grep -F` against the output of `python --version` to validate
# that the correct Python was installed (recommended) [default: none]
# - PYENV_ROOT
# Directory in which to install pyenv [default: ~/.travis-pyenv]
# - PYENV_RELEASE
# Release tag of pyenv to download [default: clone from master]
# - PYENV_CACHE_PATH
# Directory where full Python builds are cached (i.e., for Travis)

# PYENV_ROOT is exported because pyenv uses it
export PYENV_ROOT="${PYENV_ROOT:-$HOME/.travis-pyenv}"
PYENV_CACHE_PATH="${PYENV_CACHE_PATH:-$HOME/.pyenv_cache}"
version_cache_path="$PYENV_CACHE_PATH/$PYENV_VERSION"
version_pyenv_path="$PYENV_ROOT/versions/$PYENV_VERSION"

# Functions
#
# verify_python -- attempts to call the Python command or binary
# supplied in the first argument with the --version flag. If
# PYENV_VERSION_STRING is set, then it validates the returned version string
# as well (using grep -F). Returns whatever status code the command returns.
verify_python() {
local python_bin="$1"; shift

if [[ -n "$PYENV_VERSION_STRING" ]]; then
"$python_bin" --version 2>&1 | grep -F "$PYENV_VERSION_STRING" &>/dev/null
else
"$python_bin" --version &>/dev/null
fi
}

# use_cached_python -- Tries symlinking to the cached PYENV_VERSION and
# verifying that it's a working build. Returns 0 if it's found and it
# verifies, otherwise returns 1.
use_cached_python() {
if [[ -d "$version_cache_path" ]]; then
printf "Cached python found, %s. Verifying..." "$PYENV_VERSION"
ln -s "$version_cache_path" "$version_pyenv_path"
if verify_python "$version_pyenv_path/bin/python"; then
printf "success!\n"
return 0
else
printf "FAILED.\nClearing cached version..."
rm -f "$version_pyenv_path"
rm -rf "$version_cache_path"
printf "done.\n"
return 1
fi
else
echo "No cached python found."
return 1
fi
}

# output_debugging_info -- Outputs useful debugging information
output_debugging_info() {
echo "**** Debugging information"
printf "PYENV_VERSION\n%s\n" "$PYENV_VERSION"
printf "PYENV_VERSION_STRING\n%s\n" "$PYENV_VERSION_STRING"
printf "PYENV_CACHE_PATH\n%s\n" "$PYENV_CACHE_PATH"
set -x
python --version
"$version_cache_path/bin/python" --version
which python
pyenv which python
set +x
}

# Main script begins.

if [[ -z "$PYENV_VERSION" ]]; then
echo "PYENV_VERSION is not set. Not installing a pyenv."
return 0
fi

# Get out of the virtualenv we're in (if we're in one).
[[ -z "$VIRTUAL_ENV" ]] || deactivate

# Install pyenv
echo "**** Installing pyenv."
if [[ -n "$PYENV_RELEASE" ]]; then
# Fetch the release archive from Github (slightly faster than cloning)
mkdir "$PYENV_ROOT"
curl -fsSL "https://github.com/yyuu/pyenv/archive/$PYENV_RELEASE.tar.gz" \
| tar -xz -C "$PYENV_ROOT" --strip-components 1
else
# Don't have a release to fetch, so just clone directly
git clone --depth 1 https://github.com/yyuu/pyenv.git "$PYENV_ROOT"
fi

export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

# Make sure the cache directory exists
mkdir -p "$PYENV_CACHE_PATH"

# Try using an already cached PYENV_VERSION. If it fails or is not found,
# then install from scratch.
echo "**** Trying to find and use cached python $PYENV_VERSION."
if ! use_cached_python; then
echo "**** Installing python $PYENV_VERSION with pyenv now."
if pyenv install "$PYENV_VERSION"; then
if mv "$version_pyenv_path" "$PYENV_CACHE_PATH"; then
echo "Python was successfully built and moved to cache."
echo "**** Trying to find and use cached python $PYENV_VERSION."
if ! use_cached_python; then
echo "Python version $PYENV_VERSION was apparently successfully built"
echo "with pyenv, but, once cached, it could not be verified."
output_debugging_info
return 1
fi
else
echo "**** Warning: Python was succesfully built, but moving to cache"
echo "failed. Proceeding anyway without caching."
fi
else
echo "Python version $PYENV_VERSION build FAILED."
return 1
fi
fi

# Now we have to reinitialize pyenv, as we need the shims etc to be created so
# the pyenv activates correctly.
echo "**** Activating python $PYENV_VERSION and generating new virtualenv."
eval "$(pyenv init -)"
pyenv global "$PYENV_VERSION"

# Make sure virtualenv is installed and up-to-date...
pip install -U virtualenv

# Then make and source a new virtualenv
VIRTUAL_ENV="$HOME/ve-pyenv-$PYENV_VERSION"
virtualenv -p "$(which python)" "$VIRTUAL_ENV"
# shellcheck source=/dev/null
source "$VIRTUAL_ENV/bin/activate"

printf "One final verification that the virtualenv is working..."
if verify_python "python"; then
printf "success!\n"
else
printf "FAILED!\n"
output_debugging_info
return 1
fi
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ norecursedirs =
lib
Scripts
thirdparty
transpile
tmp
src/*/data
tests/*/data
Expand All @@ -39,4 +40,4 @@ addopts =
--ignore docs/conf.py
--ignore setup.py
--doctest-modules
--doctest-glob=README.rst
--doctest-glob=README.rst
25 changes: 25 additions & 0 deletions src/license_expression.js/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>License Expression Sandbox</title>
</head>
<body>
<p>
If you would like to run license expression in the browser,
you should tell Transcrypt to transpile it for the browser:
</p>
<code>./bin/python transpile/transpile.py --browser</code>
<p>
This will define function <code>__init__</code> on the
<code>window</code> object.
</p>
<p>
Without the <code>--browser</code> flag, the <code>__init__</code>
function will be defined on the <code>module.exports</code> object,
which works for node.js
</p>
<p>To debug license expression in the browser, open developer tools.</p>
<script src="./__javascript__/__init__.js"></script>
</body>
</html>
Loading