stevearc / pypicloud

S3-backed pypi server implementation
MIT License
506 stars 141 forks source link

How to set summary field when uploading a package to repository #324

Closed MattGurney closed 2 years ago

MattGurney commented 2 years ago

The simple POST API, if successful, will return a response with a summary field. If Accept: application/json is set on the request header, the response in JSON looks like this:

{
  "name": "my-module",
  "filename": "my-module-0.0.1.tar.gz",
  "last_modified": 1665705020,
  "version": "0.0.1",
  "url": "https://my.stuff/api/package/my-module/my-module-0.0.1.tar.gz#sha256=97917c12a240asdfasdfsdfb38c7338289dd23e4b56fbee61c50e6462cbf723",
  "summary": null
}

I always see the summary as null. How can I set the summary field when uploading/posting a module into PyPiCloud?

I don't see an option on the POST API, and summary does not seem to be a field in the setuptools.setup object.

stevearc commented 2 years ago

How are you uploading the package? If I do a python setup.py sdist upload, the package description is sent up as the summary parameter (the "long_description" value is sent up as description)

MattGurney commented 2 years ago

I build the package using

python setup.py sdist

I then push the package to the repo using:

curl -u *****:*************** -H 'Accept: application/json' -F name=my_package -F version=0.0.1 -F content=@dist/my_package -0.0.1.tar.gz https://my_repo.net/#/simple

I get this response:

{
  "name": "my_package",
  "filename": "my_package-0.0.1.tar.gz",
  "last_modified": 1665705020,
  "version": "0.0.1",
  "url": "https://my.stuff/api/package/my_package/my_package-0.0.1.tar.gz#sha256=97917c12a240asdfasdfsdfb38c7338289dd23e4b56fbee61c50e6462cbf723",
  "summary": null
}

My setup.py looks like this:

from setuptools import setup, find_packages

setup(
    version="0.0.1",
    author_email="me@myplace.com",
    author="Me",
    description="My cool stuff ",
    long_description="My cool stuff long",
    include_package_data=True,
    install_requires=[],
    name="my_package",
    packages=find_packages(),
    url="https://github.com/my_package/my_package",
)

When I look in the Pypicloud UI at the base URL https://my_repo.net/#/, I see a table with my uploaded packages (with current date) but the Description column is blank.

stevearc commented 2 years ago

Ah, the curl is the culprit. You're manually setting the parameters for name, version, and content, but you haven't specified a summary. You can either pass the summary in statically with -F "summary=My cool stuff" or dynamically with -F "summary=$(python setup.py --description)"

MattGurney commented 2 years ago

Thanks, setting the summary in the curl as recommended above was the fix.