Skip to content

Commit e03db23

Browse files
committed
support-private-classifier
Signed-off-by: Varsha U N <[email protected]> Signed-off-by: Varsha U N <[email protected]> Signed-off-by: Varsha U N <[email protected]>
1 parent 15b76ea commit e03db23

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

src/packagedcode/pypi.py

+5
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,10 @@ def parse(cls, location, package_only=False):
517517
if license_file:
518518
extra_data['license_file'] = license_file
519519

520+
classifiers = project_data.get('classifiers', [])
521+
is_private = any('Private ::' in classifier for classifier in classifiers)
522+
cls.is_private=is_private
523+
520524
dependencies = []
521525
parsed_dependencies = get_requires_dependencies(
522526
requires=project_data.get("dependencies", []),
@@ -542,6 +546,7 @@ def parse(cls, location, package_only=False):
542546
keywords=get_keywords(project_data),
543547
parties=get_pyproject_toml_parties(project_data),
544548
dependencies=dependencies,
549+
is_private=is_private,
545550
extra_data=extra_data,
546551
**urls,
547552
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[
2+
{
3+
"datasource_id": "pypi_pyproject_toml",
4+
"type": "pypi",
5+
"primary_language": "Python",
6+
"name": "titanic_ml",
7+
"version": "0.1.0",
8+
"extracted_license_statement": null,
9+
"description": "titanic_ml example package",
10+
"keywords": [],
11+
"parties": [
12+
{
13+
"type": "author",
14+
"name": "Niels Zeilemaker",
15+
"email": "[email protected]"
16+
}
17+
],
18+
"dependencies": [
19+
{
20+
"dependency": "pyspark[ml]",
21+
"version": ""
22+
},
23+
{
24+
"dependency": "sklearn",
25+
"version": ""
26+
}
27+
],
28+
"is_private": true,
29+
"extra_data": {},
30+
"urls": {}
31+
}
32+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#Taken from : https://xebia.com/blog/minimal-pyproject-toml-example/
2+
3+
[project]
4+
name = "titanic_ml"
5+
description = "titanic_ml example package"
6+
version = "0.1.0"
7+
authors = [
8+
{ name = "Niels Zeilemaker", email = "[email protected]" }
9+
]
10+
dependencies = [
11+
"pyspark[ml]",
12+
"sklearn"
13+
]
14+
classifiers = [
15+
"Development Status :: 4 - Beta",
16+
"Intended Audience :: Developers",
17+
"Private :: Do Not Upload"
18+
]
19+
20+
[project.optional-dependencies]
21+
dev = [
22+
"tox",
23+
"pre-commit",
24+
"bump2version"
25+
]
26+
27+
[build-system]
28+
build-backend = "flit_core.buildapi"
29+
requires = ["flit_core >=3.2,<4"]

tests/packagedcode/test_pypi.py

+6
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ def test_parse_pyproject_toml_standard_lc0(self):
339339
expected_loc = self.get_test_loc('pypi/pyproject-toml/standard/lc0-pyproject.toml-expected.json')
340340
self.check_packages_data(package, expected_loc, regen=REGEN_TEST_FIXTURES)
341341

342+
def test_parse_pyproject_toml_private_package(self):
343+
test_file = self.get_test_loc('pypi/pyproject-toml/standard/python-private-classifier/pyproject.toml')
344+
packages = pypi.PyprojectTomlHandler.parse(test_file)
345+
expected_loc = self.get_test_loc('pypi/pyproject-toml/standard/private-classifier-pyproject.toml-expected.json')
346+
self.check_packages_data(packages, expected_loc, regen=REGEN_TEST_FIXTURES)
347+
342348

343349
class TestPoetryHandler(PackageTester):
344350

0 commit comments

Comments
 (0)