diff --git a/src/packagedcode/pypi.py b/src/packagedcode/pypi.py index 271e98a69e..7d97dabe18 100644 --- a/src/packagedcode/pypi.py +++ b/src/packagedcode/pypi.py @@ -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", []), @@ -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, ) diff --git a/tests/packagedcode/data/pypi/pyproject-toml/standard/private-classifier-pyproject.toml-expected.json b/tests/packagedcode/data/pypi/pyproject-toml/standard/private-classifier-pyproject.toml-expected.json new file mode 100644 index 0000000000..ef7fe126ac --- /dev/null +++ b/tests/packagedcode/data/pypi/pyproject-toml/standard/private-classifier-pyproject.toml-expected.json @@ -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": "nielszeilemaker@xebia.com" + } + ], + "dependencies": [ + { + "dependency": "pyspark[ml]", + "version": "" + }, + { + "dependency": "sklearn", + "version": "" + } + ], + "is_private": true, + "extra_data": {}, + "urls": {} + } +] diff --git a/tests/packagedcode/data/pypi/pyproject-toml/standard/python-private-classifier/pyproject.toml b/tests/packagedcode/data/pypi/pyproject-toml/standard/python-private-classifier/pyproject.toml new file mode 100644 index 0000000000..d03383271f --- /dev/null +++ b/tests/packagedcode/data/pypi/pyproject-toml/standard/python-private-classifier/pyproject.toml @@ -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 = "nielszeilemaker@xebia.com" } +] +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"] diff --git a/tests/packagedcode/test_pypi.py b/tests/packagedcode/test_pypi.py index 37bd204327..56b5b4f2d2 100644 --- a/tests/packagedcode/test_pypi.py +++ b/tests/packagedcode/test_pypi.py @@ -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):