Giter Site home page Giter Site logo

Python package names not normalized about cli HOT 4 CLOSED

maxrake avatar maxrake commented on August 24, 2024
Python package names not normalized

from cli.

Comments (4)

cd-work avatar cd-work commented on August 24, 2024

#1273 has been dismissed, is this even still useful without it?

from cli.

maxrake avatar maxrake commented on August 24, 2024

#1273 has been dismissed, is this even still useful without it?

I still think so. Here is another example that shows how the results of parsing the same input package results in different names, where the only difference is whether it gets parsed as a lockfile or manifest.

❯ phylum --version
phylum v5.8.1

❯ cat requirements.txt
RuAmEl...YAML---CLib==0.2.8

❯ phylum parse --lockfile-type pip requirements.txt
[
  {
    "name": "RuAmEl...YAML---CLib",
    "version": "0.2.8",
    "type": "pypi",
    "lockfile": "requirements.txt"
  }
]

❯ vim requirements.txt

❯ cat requirements.txt
RuAmEl...YAML---CLib

❯ phylum parse --lockfile-type pip requirements.txt
Generating lockfile for manifest "requirements.txt" using Pip…
[
  {
    "name": "ruamel.yaml.clib",
    "version": "0.2.8",
    "type": "pypi",
    "lockfile": "requirements.txt"
  }
]

The expectation is that name of the parsed package is normalized and will be the same in both cases...ruamel-yaml-clib in this case.

from cli.

kylewillmon avatar kylewillmon commented on August 24, 2024

My concern here is that "normalization" is not the correct behavior. As can be seen from your example:

❯ phylum parse --lockfile-type pip requirements.txt
Generating lockfile for manifest "requirements.txt" using Pip…
[
  {
    "name": "PyYAML",
    "version": "6.0.1",
    "type": "pypi",
    "lockfile": "requirements.txt"
  },
  {
    "name": "Pillow",
    "version": "10.1.0",
    "type": "pypi",
    "lockfile": "requirements.txt"
  }
]

These package names are provided by pip because lockfile generation happened, but they are not "normalized". Instead, they are the canonical names for these packages... The normalization rules that you provide are only used for deduplication.

The canonical name for a package can only be known by looking up that package in the registry. Which leaves us with two options:

  1. Output the normalized name instead of the canonical name
  2. Make network requests to the registry to find the canonical name

Option 2 is clearly outside the scope of a lockfile parser and Option 1 leads to results that are technically incorrect...

And just like #1273, this issue really only exists when using requirements.txt files as lockfiles... Because any lockfile generator should convert package names to the canonical name.

So unless there is an option that I am missing, I don't think there is any reasonable action that we can take to resolve this issue.

from cli.

maxrake avatar maxrake commented on August 24, 2024

Okay...points taken. This issue will be closed.

from cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.