-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add generated python bindings (fixes #14)
- Loading branch information
1 parent
c1462db
commit 3d837ee
Showing
13 changed files
with
192 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
these are maintainer instructions, check the readme's in the binding | ||
directories for user guides | ||
|
||
# requirements | ||
* swig | ||
* docker | ||
* twine (pip) | ||
|
||
# building all bindings | ||
```sh | ||
./build.sh | ||
``` | ||
|
||
# publishing all bindings | ||
```sh | ||
PUBLISH=1 ./build.sh | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
|
||
runall() { | ||
for d in ./*/; do | ||
[ "$d" = "." ] && continue | ||
cd "$d" | ||
./build.sh || return $? | ||
[ ! -z $PUBLISH ] && ./publish.sh | ||
cd .. | ||
done | ||
} | ||
|
||
dir="$(dirname "$0")" | ||
olddir="$(pwd)" | ||
cd "$dir" | ||
runall | ||
res=$? | ||
cd "$olddir" | ||
exit $res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
%module oppai | ||
%feature("autodoc", "3"); | ||
%apply int *OUTPUT {int*} | ||
%{ | ||
#define OPPAI_IMPLEMENTATION | ||
#include "oppai.c" | ||
%} | ||
#include "oppai.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
osu! pp and difficulty calculator. automatically generated C bindings for | ||
https://github.com/Francesco149/oppai-ng | ||
|
||
usage | ||
=========== | ||
.. code-block:: sh | ||
pip install oppai | ||
.. code-block:: python | ||
#!/usr/bin/env python | ||
import sys | ||
from oppai import * | ||
ez = ezpp_new() | ||
ezpp(ez, sys.argv[1]) | ||
print("%g pp" % ezpp_pp(ez)) | ||
ezpp_free(ez) | ||
.. code-block:: sh | ||
./example.py /path/to/file.osu | ||
.. code-block:: sh | ||
python -c 'help("oppai")' | ||
for a list of functions, or just read the top of oppai.c for better doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
rm -rf ./dist | ||
cp ../../oppai.c . | ||
cp ../oppai.i . | ||
swig -python -includeall oppai.i || exit | ||
for img in quay.io/pypa/manylinux1_x86_64 quay.io/pypa/manylinux1_i686; do | ||
docker run --user 1000:1000 --rm -v $(pwd):/io -w /io $img \ | ||
./build_wheels.sh || exit | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
# this is meant to be used from docker | ||
|
||
rm *.so | ||
for pybin in /opt/python/*/bin | ||
do | ||
"$pybin/python" ./setup.py build_ext --inplace || exit | ||
"$pybin/pip" wheel . -w dist/ || exit | ||
done | ||
|
||
"$pybin/python" ./setup.py sdist || exit | ||
|
||
for w in dist/*linux_*.whl; do | ||
auditwheel repair "$w" -w dist/ || exit | ||
done | ||
rm dist/*linux_*.whl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
from oppai import * | ||
|
||
ez = ezpp_new() | ||
ezpp(ez, sys.argv[1]) | ||
print("%g pp" % ezpp_pp(ez)) | ||
ezpp_free(ez) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
from oppai import * | ||
|
||
ez = ezpp_new() | ||
ezpp_set_autocalc(ez, 1) | ||
for osufile in sys.argv[1:]: | ||
ezpp(ez, osufile) | ||
print("%s - %s [%s]" % (ezpp_artist(ez), ezpp_title(ez), ezpp_version(ez))) | ||
print("%g stars" % ezpp_stars(ez)) | ||
for acc in range(95, 101): | ||
ezpp_set_accuracy_percent(ez, acc) | ||
print("%g%% -> %g pp" % (acc, ezpp_pp(ez))) | ||
print("") | ||
ezpp_free(ez) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
twine upload dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build_ext] | ||
swig-opts=-includeall |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
|
||
try: | ||
from setuptools import setup, Extension | ||
except ImportError: | ||
from distutils.core import setup, Extension | ||
|
||
try: | ||
from oppai import oppai_version_str | ||
except Exception: | ||
def oppai_version_str(): | ||
return "INVALID" | ||
|
||
oppai_classifiers = [ | ||
"Programming Language :: Python :: 2", | ||
"Programming Language :: Python :: 3", | ||
"Intended Audience :: Developers", | ||
"License :: Public Domain", | ||
"Topic :: Software Development :: Libraries", | ||
"Topic :: Utilities", | ||
] | ||
|
||
f = open("README.rst", "r") | ||
oppai_readme = f.read() | ||
f.close() | ||
|
||
oppai_sources=['oppai.i'] | ||
if os.system('swig') != 0: | ||
oppai_sources=['oppai_wrap.c', 'oppai.c'] | ||
|
||
setup( | ||
name="oppai", | ||
version=oppai_version_str(), | ||
author="Franc[e]sco", | ||
author_email="[email protected]", | ||
url="https://github.com/Francesco149/oppai-ng", | ||
ext_modules=[Extension('_oppai', oppai_sources)], | ||
py_modules=["oppai"], | ||
description="osu! pp and difficulty calculator, C bindings", | ||
long_description=oppai_readme, | ||
license="Unlicense", | ||
classifiers=oppai_classifiers, | ||
keywords="osu! osu" | ||
) |