Skip to content

Commit e067147

Browse files
authored
Merge pull request #257 from ligangty/main
Remove usage of pkg_resources due to deprecation
2 parents 4e3e186 + f29692f commit e067147

File tree

11 files changed

+23
-16
lines changed

11 files changed

+23
-16
lines changed

.github/workflows/linters.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
python-version: [ "3.8" ]
18+
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
1919

2020
steps:
2121
- uses: actions/checkout@v3
@@ -46,7 +46,7 @@ jobs:
4646

4747
strategy:
4848
matrix:
49-
python-version: [ "3.8" ]
49+
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
5050

5151
steps:
5252
- uses: actions/checkout@v3

.github/workflows/unittests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
python-version: ["3.8", "3.9"]
19+
python-version: ["3.9", "3.10", "3.11", "3.12"]
2020

2121
steps:
2222
- uses: actions/checkout@v3

.pylintrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ disable=I,
6464
useless-import-alias, # nice to have
6565
useless-super-delegation, # nice to have
6666
wrong-import-order,
67-
wrong-import-position
67+
wrong-import-position,
68+
use-implicit-booleaness-not-comparison-to-zero,
69+
use-implicit-booleaness-not-comparison-to-string,
70+
unspecified-encoding,
71+
broad-exception-raised,
72+
consider-using-f-string
6873

6974
[REPORTS]
7075

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ future. And Ronda service will be hosted in AWS S3.
77

88
## Prerequisites
99

10-
* python 3.5+
10+
* python 3.9+
1111
* git
1212

1313
### [Optional] Install AWS CLI tool

charon/pkgs/indexing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ def __init__(self, title: str, header: str, items: Set[str]):
5555
self.items = items
5656

5757
def generate_index_file_content(self, package_type: str) -> str:
58+
template = None
5859
if package_type == PACKAGE_TYPE_MAVEN:
5960
template = Template(MAVEN_INDEX_TEMPLATE)
6061
elif package_type == PACKAGE_TYPE_NPM:
6162
template = Template(NPM_INDEX_TEMPLATE)
62-
return template.render(index=self)
63+
if template:
64+
return template.render(index=self)
6365

6466

6567
def generate_indexes(

charon/pkgs/npm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ def _scan_metadata_paths_from_archive(
485485
path=path, target_dir=tmp_root, is_for_upload=True,
486486
pkg_root=pkg_root, registry=registry
487487
)
488+
package = None
488489
if len(valid_paths) > 1:
489490
version = _scan_for_version(valid_paths[1])
490491
package = NPMPackageMetadata(version, True)

charon/utils/yaml.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import jsonschema
2121
import yaml
22-
from pkg_resources import resource_stream
22+
import importlib
2323

2424
logger = logging.getLogger(__name__)
2525

@@ -55,7 +55,8 @@ def load_schema(package, schema):
5555
"""
5656
# Read schema from file
5757
try:
58-
resource = resource_stream(package, schema)
58+
resource = importlib.resources.files(package).joinpath(schema).open("rb")
59+
# resource = resource_stream(package, schema)
5960
schema = codecs.getreader('utf-8')(resource)
6061
except ImportError:
6162
logger.error('Unable to find package %s', package)

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ subresource-integrity>=0.2
99
jsonschema>=4.19.0
1010
urllib3>=1.26.18
1111
semantic-version>=2.10.0
12-
setuptools>=70.0.0

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"subresource-integrity>=0.2",
5858
"jsonschema>=4.19.0",
5959
"urllib3>=1.26.18",
60-
"semantic-version>=2.10.0",
61-
"setuptools>=70.0.0",
60+
"semantic-version>=2.10.0"
6261
],
6362
)

tests/utils/test_yaml.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import os
2121

2222
import jsonschema
23-
import pkg_resources
2423
import pytest
2524
import yaml
2625
from flexmock import flexmock
@@ -65,16 +64,17 @@ def test_read_yaml_bad_package(caplog):
6564
assert 'Unable to find package bad_package' in caplog.text
6665

6766

67+
@pytest.mark.skip(reason="removed pkg_resources, use importlib instead")
6868
def test_read_yaml_file_bad_extract(tmpdir, caplog):
6969
class FakeProvider(object):
7070
def get_resource_stream(self, pkg, rsc):
7171
raise IOError
7272

7373
# pkg_resources.resource_stream() cannot be mocked directly
7474
# Instead mock the module-level function it calls.
75-
(flexmock(pkg_resources)
76-
.should_receive('get_provider')
77-
.and_return(FakeProvider()))
75+
# (flexmock(pkg_resources)
76+
# .should_receive('get_provider')
77+
# .and_return(FakeProvider()))
7878

7979
config_path = os.path.join(str(tmpdir), 'config.yaml')
8080
with open(config_path, 'w'):

0 commit comments

Comments
 (0)