Skip to content

Commit

Permalink
support-private-classifier
Browse files Browse the repository at this point in the history
Signed-off-by: Varsha U N <[email protected]>

Signed-off-by: Varsha U N <[email protected]>

Signed-off-by: Varsha U N <[email protected]>
  • Loading branch information
VarshaUN committed Jan 11, 2025
1 parent 15b76ea commit e03db23
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/packagedcode/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,10 @@ def parse(cls, location, package_only=False):
if license_file:
extra_data['license_file'] = license_file

classifiers = project_data.get('classifiers', [])
is_private = any('Private ::' in classifier for classifier in classifiers)
cls.is_private=is_private

dependencies = []
parsed_dependencies = get_requires_dependencies(
requires=project_data.get("dependencies", []),
Expand All @@ -542,6 +546,7 @@ def parse(cls, location, package_only=False):
keywords=get_keywords(project_data),
parties=get_pyproject_toml_parties(project_data),
dependencies=dependencies,
is_private=is_private,
extra_data=extra_data,
**urls,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"datasource_id": "pypi_pyproject_toml",
"type": "pypi",
"primary_language": "Python",
"name": "titanic_ml",
"version": "0.1.0",
"extracted_license_statement": null,
"description": "titanic_ml example package",
"keywords": [],
"parties": [
{
"type": "author",
"name": "Niels Zeilemaker",
"email": "[email protected]"
}
],
"dependencies": [
{
"dependency": "pyspark[ml]",
"version": ""
},
{
"dependency": "sklearn",
"version": ""
}
],
"is_private": true,
"extra_data": {},
"urls": {}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#Taken from : https://xebia.com/blog/minimal-pyproject-toml-example/

[project]
name = "titanic_ml"
description = "titanic_ml example package"
version = "0.1.0"
authors = [
{ name = "Niels Zeilemaker", email = "[email protected]" }
]
dependencies = [
"pyspark[ml]",
"sklearn"
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Private :: Do Not Upload"
]

[project.optional-dependencies]
dev = [
"tox",
"pre-commit",
"bump2version"
]

[build-system]
build-backend = "flit_core.buildapi"
requires = ["flit_core >=3.2,<4"]
6 changes: 6 additions & 0 deletions tests/packagedcode/test_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@ def test_parse_pyproject_toml_standard_lc0(self):
expected_loc = self.get_test_loc('pypi/pyproject-toml/standard/lc0-pyproject.toml-expected.json')
self.check_packages_data(package, expected_loc, regen=REGEN_TEST_FIXTURES)

def test_parse_pyproject_toml_private_package(self):
test_file = self.get_test_loc('pypi/pyproject-toml/standard/python-private-classifier/pyproject.toml')
packages = pypi.PyprojectTomlHandler.parse(test_file)
expected_loc = self.get_test_loc('pypi/pyproject-toml/standard/private-classifier-pyproject.toml-expected.json')
self.check_packages_data(packages, expected_loc, regen=REGEN_TEST_FIXTURES)


class TestPoetryHandler(PackageTester):

Expand Down

0 comments on commit e03db23

Please sign in to comment.