Giter Club home page Giter Club logo

Comments (3)

steiza avatar steiza commented on July 22, 2024

Oh interesting, I haven't worked with packages with a period in their name before. I'm open to changing the implementation, but it isn't clear to me yet what the standard is here.

I made a test package (using python -m build, instead of Flit), which happily produced abc.xyz-0.0.1-py3-none-any.whl that I uploaded to simplepypi with twine upload --repository-url http://127.0.0.1:8000 dist/abc.xyz-0.0.1-py3-none-any.whl.

I was able to view and download that package with the web interface (here's the server logs):

INFO - 200 GET /packages/abc.xyz (127.0.0.1) 0.72ms
INFO - 200 GET /packages/abc.xyz/0.0.1/abc.xyz-0.0.1-py3-none-any.whl (127.0.0.1) 1.01ms

... but when I did pip install -i http://127.0.0.1:8000/pypi abc.xyz that did not work (again, here are the server logs):

WARNING - 404 GET /pypi/abc-xyz/ (127.0.0.1) 0.57ms

So it looks like pip is substituting . for - when it queries the server. But it sounds like your pip + Flit wheel replaces . with _?

It seems like simplepypi should follow pip's lead and replace . with -, but I'm not sure that will solve your problem - is there additional information you could provide about how you ended up with . replaced with _? Like what's your project name in pyproject.toml? I don't think there is, but just in case, is there a setup.cfg / setup.py with a name specified as well?

from simplepypi.

WillDaSilva avatar WillDaSilva commented on July 22, 2024

Thank you for looking into this.

tl;dr: I believe the normalize function (below) should be applied to package names when they are being uploaded to the simplepypi server.

import re

def normalize(name: str) -> str:
    return re.sub(r'[-_.]+', '-', name).lower()

I do not have a setup.cfg or setup.py for this project. The name in pyproject.toml is abc.xyz.

Some justification for the name choice: it was chosen to be this since that's the only way to use Flit's namespace package feature. abc.xyz is installed such that from abc import xyz is possible - this allows for improved organization within the company I'm working for, as we can keep the xyz part in a separate repository from other parts of the abc package.

It looks like the standard for Python package name normalization is documented in PEP503.

I captured the HTTPS requests for pip install [flags omitted] abc.xyz, which downloaded the wheel file off of my company's PyPI server (hosted via Nexus):

https://nexus.[A].com/[B]/simple/abc-xyz
https://nexus.[A].com/[B]/packages/abc-xyz/0.1.2/abc_xyz-0.1.2-py3-none-any.whl

The parts inside the square brackets have been omitted. I assume these are GET requests.

It looks like my request for the package abc.xyz is being normalized into abc-xyz by pip, which is then requested from the PyPI server. The PyPI server normalized the names of the packages it stores when they were initially uploaded. When I open https://nexus.[A].com/[B]/simple/ in a web browser I see that the period has been replaced by a hyphen in the package index.

It looks like the normalization does not apply to the wheel file when it is uploaded, but that's not necessary since by the time the wheel file itself is being selected, the package name and version have already been dealt with (because we are already in the <package name>/<version number>/ subdirectory.

from simplepypi.

steiza avatar steiza commented on July 22, 2024

Makes sense to me! I believe this should be fixed with f0906b6

from simplepypi.

Related Issues (8)

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.