Skip to content

Commit

Permalink
Add setup.py
Browse files Browse the repository at this point in the history
This installs the emsdk script as a proper Python entry point
  • Loading branch information
martinRenou committed Apr 29, 2022
1 parent e34773a commit ff6d47f
Show file tree
Hide file tree
Showing 25 changed files with 49 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*.pyc
__pycache__
emsdk.egg-info
dist
build

# Support for --embedded configs
/.emscripten
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include emsdk
2 changes: 1 addition & 1 deletion emsdk
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ if [ -z "$EMSDK_PYTHON" ]; then
EMSDK_PYTHON=python
fi

exec "$EMSDK_PYTHON" "$0.py" "$@"
exec "$EMSDK_PYTHON" "emsdkpy/$0.py" "$@"
1 change: 1 addition & 0 deletions emsdkpy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .emsdk import main # noqa
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions emsdk.py → emsdkpy/emsdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2833,7 +2833,9 @@ def expand_sdk_name(name, activating):
return name


def main(args):
def main():
args = sys.argv[1:]

if not args:
errlog("Missing command; Type 'emsdk help' to get a list of commands.")
return 1
Expand Down Expand Up @@ -3268,4 +3270,4 @@ def print_tools(t):


if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
sys.exit(main())
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/create_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def main(args):
release_info['releases'] = OrderedDict(reversed(releases))
release_info['aliases']['latest'] = new_version

with open(os.path.join(root_dir, 'emscripten-releases-tags.json'), 'w') as f:
with open(os.path.join(root_dir, 'emsdkpy', 'emscripten-releases-tags.json'), 'w') as f:
f.write(json.dumps(release_info, indent=2))
f.write('\n')

Expand Down
6 changes: 3 additions & 3 deletions scripts/update_bazel_workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cd $(dirname $0)/..
# If the previous command succeeded. We are in the emsdk root. Check to make
# sure the files and directories we need are present.
if [[ $? = 0 ]]; then
if [[ ! -f emscripten-releases-tags.json ]]; then
if [[ ! -f emsdkpy/emscripten-releases-tags.json ]]; then
echo "Cannot find emscripten-releases-tags.json."
ERR=1
fi
Expand All @@ -38,7 +38,7 @@ URL2=/wasm-binaries

# Get commit hash for $1 version
get_hash () {
echo $(grep "$1" emscripten-releases-tags.json | grep -v latest | grep -v asserts | cut -f4 -d\")
echo $(grep "$1" emsdkpy/emscripten-releases-tags.json | grep -v latest | grep -v asserts | cut -f4 -d\")
}

# Get sha256 for $1 os $2 extname $3 hash $4 architecture
Expand All @@ -65,7 +65,7 @@ append_revision () {

# Get the latest version number from emscripten-releases-tag.json.
VER=$(grep -oP '(?<=latest\": \")([\d\.]+)(?=\")' \
emscripten-releases-tags.json \
emsdkpy/emscripten-releases-tags.json \
| sed --expression "s/\./\\\./g")

append_revision ${VER}
Expand Down
26 changes: 26 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[metadata]
name = emsdk
version = 3.1.9
description = Emscripten SDK
long_description = file: README.md
long_description_content_type = text/markdown
license_file = LICENSE
author = Emscripten authors
url = https://github.com/emscripten-core/emsdk
platforms = Windows, Linux, Mac OS X
keywords = emscripten, sdk

[bdist_wheel]
universal = 1

[options]
include_package_data = True
packages = find:
python_requires = >=3.7

[options.entry_points]
console_scripts =
emsdk = emsdkpy.emsdk:main

[options.package_data]
emsdkpy = *.txt, *.bat, *.csh, *.fish, *.ps1, *.sh, *.json
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import setuptools

setuptools.setup()
2 changes: 1 addition & 1 deletion test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def hack_emsdk(marker, replacement):

# Set up

TAGS = json.loads(open('emscripten-releases-tags.json').read())
TAGS = json.loads(open('emsdkpy/emscripten-releases-tags.json').read())

# Tests

Expand Down
6 changes: 3 additions & 3 deletions test/test_bazel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ set -e

# Get the latest version number from emscripten-releases-tag.json.
VER=$(grep -oP '(?<=latest\": \")([\d\.]+)(?=\")' \
emscripten-releases-tags.json \
emsdkpy/emscripten-releases-tags.json \
| sed --expression "s/\./\\\./g")
# Based on the latest version number, get the commit hash for that version.
HASH=$(grep "\"${VER}\"" emscripten-releases-tags.json \
HASH=$(grep "\"${VER}\"" emsdkpy/emscripten-releases-tags.json \
| grep -v latest \
| cut -f4 -d\")

Expand All @@ -31,4 +31,4 @@ bazel build //:hello-embind-wasm --compilation_mode dbg # debug
# Test use of the closure compiler
bazel build //:hello-embind-wasm --compilation_mode opt # release
# This function should not be minified if the externs file is loaded correctly.
grep "customJSFunctionToTestClosure" bazel-bin/hello-embind-wasm/hello-embind.js
grep "customJSFunctionToTestClosure" bazel-bin/hello-embind-wasm/hello-embind.js
4 changes: 2 additions & 2 deletions test/test_bazel_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ set -e

# Get the latest version number from emscripten-releases-tag.json.
VER=$(ggrep -oP '(?<=latest\": \")([\d\.]+)(?=\")' \
emscripten-releases-tags.json \
emsdkpy/emscripten-releases-tags.json \
| sed "s/\./\\\./g")
# Based on the latest version number, get the commit hash for that version.
HASH=$(grep "\"${VER}\"" emscripten-releases-tags.json \
HASH=$(grep "\"${VER}\"" emsdkpy/emscripten-releases-tags.json \
| grep -v latest \
| cut -f4 -d\")

Expand Down

0 comments on commit ff6d47f

Please sign in to comment.