aboutcode-org / scancode-toolkit

:mag: ScanCode detects licenses, copyrights, dependencies by "scanning code" ... to discover and inventory open source and third-party packages used in your code. Sponsored by NLnet project https://nlnet.nl/project/vulnerabilitydatabase, the Google Summer of Code, Azure credits, nexB and others generous sponsors!
https://aboutcode.org/scancode/
2.14k stars 552 forks source link

Support for Python Private Packages Using Private : : Classifier #3968 #3982

Open alok1304 opened 1 week ago

alok1304 commented 1 week ago

Fixes #3968 Changes Implemented: Added support for the Private :: Do Not Upload classifier in the setup configuration. Updated the setup.cfg file to enable users to designate their packages as private using this classifier.

stefan6419846 commented 1 week ago

How does this solve the linked issue? Your change basically declares scancode-toolkit as a private package, which surely is not what the issue has been about.

alok1304 commented 1 week ago

Hi @stefan6419846 , thanks for the feedback! I see now that my recent commit may have inadvertently declared scancode-toolkit as private, which wasn’t the intention. I think here is the goal here is to add support for theis_privateflag by detecting the Private :: classifier in user packages, rather than marking scancode-toolkit itself as private.

can you tell how I work on it.

AyanSinhaMahapatra commented 1 week ago

@alok1304 you have to update the pyproject.toml parser at https://github.com/aboutcode-org/scancode-toolkit/blob/develop/src/packagedcode/pypi.py#L503 to make sure we handle these private package manifests correctly. See also https://github.com/aboutcode-org/scancode-toolkit/pull/3779/commits/f848741989d0d40309fc1220c58b5a9a145c897e to check how we did this for other package ecosystems. Start by adding a test file from https://github.com/aboutcode-org/scancode-toolkit/issues/3968#issuecomment-2455595655, similarly like the tests in https://github.com/aboutcode-org/scancode-toolkit/blob/develop/tests/packagedcode/test_pypi.py#L305

alok1304 commented 1 week ago

@AyanSinhaMahapatra Thankyou!!

alok1304 commented 1 week ago

@AyanSinhaMahapatra

name = project_data.get('name')
is_private = False

# Check for privacy classifier
classifiers = project_data.get('classifiers', [])
for classifier in classifiers:
    if 'Private ::' in classifier:
        is_private = True
        break  # Once a private classifier is found, no need to continue checking

# If no classifier or name, package is private by default
if not name:
    is_private = True

is this correct??