Skip to content

Commit

Permalink
Support Python 3.10
Browse files Browse the repository at this point in the history
This closes #28.
  • Loading branch information
HuangXingBo committed Jan 11, 2023
1 parent 8c5514b commit c2c4110
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_wheels.yml
Expand Up @@ -73,7 +73,7 @@ jobs:
matrix:
buildplat:
- [macos-latest, macosx_*]
python: ["cp37", "cp38", "cp39"]
python: ["cp37", "cp38", "cp39", "cp310"]
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/java_tests.yml
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
matrix:
os: ['macos-latest', 'ubuntu-20.04']
python-version: ['3.7', '3.8', '3.9']
python-version: ['3.7', '3.8', '3.9', '3.10']
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion dev/build-wheels.sh
Expand Up @@ -19,7 +19,7 @@ set -e -x
dev/lint-python.sh -s py_env

PY_ENV_DIR=`pwd`/dev/.conda/envs
py_env=("3.7" "3.8" "3.9")
py_env=("3.7" "3.8" "3.9" "3.10")
## 2. install dependency
for ((i=0;i<${#py_env[@]};i++)) do
if [[ "$(uname)" != "Darwin" ]]; then
Expand Down
1 change: 0 additions & 1 deletion dev/dev-requirements.txt
Expand Up @@ -14,5 +14,4 @@
# limitations under the License.
setuptools>=18.0
wheel
numpy==1.21.4
find-libpython
6 changes: 3 additions & 3 deletions dev/lint-python.sh
Expand Up @@ -217,7 +217,7 @@ function install_miniconda() {
# Install some kinds of py env.
function install_py_env() {
py_env=("3.7" "3.8" "3.9")
py_env=("3.7" "3.8" "3.9" "3.10")
for ((i=0;i<${#py_env[@]};i++)) do
if [[ -d "$CURRENT_DIR/.conda/envs/${py_env[i]}" ]]; then
rm -rf "$CURRENT_DIR/.conda/envs/${py_env[i]}"
Expand Down Expand Up @@ -391,7 +391,7 @@ function install_environment() {
print_function "STEP" "install miniconda... [SUCCESS]"

# step-3 install python environment which includes
# 3.7 3.8 3.9
# 3.7 3.8 3.9 3.10
if [[ ${STEP} -lt 3 ]] && [[ `need_install_component "py_env"` = true ]]; then
print_function "STEP" "installing python environment..."
install_py_env
Expand Down Expand Up @@ -585,7 +585,7 @@ usage: $0 [options]
so do not use this option with -e,-i simultaneously.
Examples:
./lint-python -s basic => install environment with basic components.
./lint-python -s py_env => install environment with python env(3.7,3.8,3.9).
./lint-python -s py_env => install environment with python env(3.7,3.8,3.9,3.10).
./lint-python -s all => install environment with all components such as python env,tox,flake8,sphinx,mypy etc.
./lint-python -s tox,flake8 => install environment with tox,flake8.
./lint-python -s tox -f => reinstall environment with tox.
Expand Down
23 changes: 4 additions & 19 deletions setup.py
Expand Up @@ -29,7 +29,7 @@
file=sys.stderr)
sys.exit(-1)

if sys.version_info >= (3, 10):
if sys.version_info >= (3, 11):
fmt = "Pemja may not yet support Python {}.{}."
warnings.warn(
fmt.format(*sys.version_info[:2]),
Expand Down Expand Up @@ -137,22 +137,6 @@ def get_java_include():
paths.append(include_bsd)
return paths


def get_numpy_include():
numpy_include = []
try:
import numpy

include_path = os.path.join(numpy.__path__[0], 'core', 'include')
if os.path.exists(include_path):
print('numpy include found at', include_path)
numpy_include = [include_path]
except ImportError:
print('numpy not found', file=sys.stderr)
sys.exit(-1)
return numpy_include


def get_src_include():
return ['src/main/c/Include']

Expand Down Expand Up @@ -181,7 +165,7 @@ def build_extension(self, ext):
sources=get_files('src/main/c/pemja/core', '.c'),
libraries=get_python_libs(),
extra_link_args=get_java_linker_args(),
include_dirs=get_java_include() + ['src/main/c/pemja/core/include'] + get_numpy_include(),
include_dirs=get_java_include() + ['src/main/c/pemja/core/include'],
language=3),
Extension(
name="pemja_utils",
Expand Down Expand Up @@ -210,7 +194,7 @@ def build_extension(self, ext):
license='https://www.apache.org/licenses/LICENSE-2.0',
author_email='hxbks2ks@gmail.com',
python_requires='>=3.7',
install_requires=['numpy==1.21.4', 'find-libpython'],
install_requires=['find-libpython'],
cmdclass={'build_ext': build_ext},
description='PemJa',
long_description=long_description,
Expand All @@ -222,6 +206,7 @@ def build_extension(self, ext):
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: Implementation :: CPython',
'Operating System :: Unix',
'Operating System :: MacOS', ],
Expand Down
6 changes: 2 additions & 4 deletions src/test/java/pemja/core/PythonInterpreterTest.java
Expand Up @@ -504,10 +504,9 @@ public void testMultiThread() throws InterruptedException {
new PythonInterpreter(
PythonInterpreterConfig.newBuilder().build())) {
try {
interpreter.exec("import numpy as np");
interpreter.exec("import math");
interpreter.exec(
"in_array = (0, math.pi / 2, np.pi / 3, np.pi)");
"in_array = (0, math.pi / 2, math.pi / 3, math.pi)");
Object[] res =
new Object[] {
0L,
Expand All @@ -532,10 +531,9 @@ public void testMultiThread() throws InterruptedException {
new PythonInterpreter(
PythonInterpreterConfig.newBuilder().build())) {
try {
interpreter.exec("import numpy as np");
interpreter.exec("import math");
interpreter.exec(
"in_array = (0, math.pi / 2, np.pi / 3, np.pi)");
"in_array = (0, math.pi / 2, math.pi / 3, math.pi)");
Object[] res =
new Object[] {
0L,
Expand Down

0 comments on commit c2c4110

Please sign in to comment.