Skip to content

Commit 16d38ad

Browse files
committed
👽 Migrate to toml and apply isort to pythonpackage.py
Because `pytoml` is deprecated See also: https://pypi.org/project/pytoml/
1 parent 3aa2aec commit 16d38ad

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

pythonforandroid/pythonpackage.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,23 @@
3333
"""
3434

3535

36-
from io import open # needed for python 2
3736
import functools
3837
import os
39-
from pep517.envbuild import BuildEnvironment
40-
from pep517.wrappers import Pep517HookCaller
41-
import pytoml
4238
import shutil
4339
import subprocess
4440
import sys
4541
import tarfile
4642
import tempfile
4743
import textwrap
4844
import time
49-
try:
50-
from urllib.parse import urlparse
51-
from urllib.parse import unquote as urlunquote
52-
except ImportError: # Python 2...
53-
from urlparse import urlparse
54-
from urlparse import unquote as urlunquote
5545
import zipfile
46+
from io import open # needed for python 2
47+
from urllib.parse import unquote as urlunquote
48+
from urllib.parse import urlparse
49+
50+
import toml
51+
from pep517.envbuild import BuildEnvironment
52+
from pep517.wrappers import Pep517HookCaller
5653

5754

5855
def transform_dep_for_pip(dependency):
@@ -486,7 +483,7 @@ def _extract_metainfo_files_from_package_unsafe(
486483

487484
# Get build backend and requirements from pyproject.toml:
488485
with open(os.path.join(path, 'pyproject.toml')) as f:
489-
build_sys = pytoml.load(f)['build-system']
486+
build_sys = toml.load(f)['build-system']
490487
backend = build_sys["build-backend"]
491488
build_requires.extend(build_sys["requires"])
492489

@@ -630,7 +627,7 @@ def _extract_info_from_package(dependency,
630627
) and include_build_requirements:
631628
# Read build system from pyproject.toml file: (PEP518)
632629
with open(os.path.join(output_folder, 'pyproject.toml')) as f:
633-
build_sys = pytoml.load(f)['build-system']
630+
build_sys = toml.load(f)['build-system']
634631
if "requires" in build_sys:
635632
requirements += build_sys["requires"]
636633
elif include_build_requirements:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
install_reqs = [
2424
'appdirs', 'colorama>=0.3.3', 'jinja2', 'six',
2525
'enum34; python_version<"3.4"', 'sh>=1.10; sys_platform!="nt"',
26-
'pep517<0.7.0"', 'pytoml', 'virtualenv<20'
26+
'pep517<0.7.0"', 'toml', 'virtualenv<20'
2727
]
2828
# (pep517, pytoml and virtualenv are used by pythonpackage.py)
2929

tests/test_pythonpackage_basic.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ def test_venv(self):
340340
os.path.join(test_dir, "venv", "bin", "pip"),
341341
"install", "-U", "pep517<0.7.0"
342342
])
343+
subprocess.check_output([
344+
os.path.join(test_dir, "venv", "bin", "pip"),
345+
"install", "-U", "toml"
346+
])
343347
sys_python_path = self.run__get_system_python_executable(
344348
os.path.join(test_dir, "venv", "bin", "python")
345349
)

0 commit comments

Comments
 (0)