Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support-python-private-classifier #4075

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading