无法使用twine上传包

问题描述 投票:0回答:1

当我构建 Python 包时,我没有收到任何警告或错误:

H:\git\graphab4py>py -m build
* Creating venv isolated environment...
* Installing packages in isolated environment... (setuptools>=61.0, wheel)
* Getting build dependencies for sdist...
running egg_info
writing src\graphab4py.egg-info\PKG-INFO
writing dependency_links to src\graphab4py.egg-info\dependency_links.txt
writing requirements to src\graphab4py.egg-info\requires.txt
writing top-level names to src\graphab4py.egg-info\top_level.txt
reading manifest file 'src\graphab4py.egg-info\SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'src\graphab4py.egg-info\SOURCES.txt'
* Building sdist...
running sdist
running egg_info
writing src\graphab4py.egg-info\PKG-INFO
writing dependency_links to src\graphab4py.egg-info\dependency_links.txt
writing requirements to src\graphab4py.egg-info\requires.txt
writing top-level names to src\graphab4py.egg-info\top_level.txt
reading manifest file 'src\graphab4py.egg-info\SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'src\graphab4py.egg-info\SOURCES.txt'
running check
creating graphab4py-1.0.4
creating graphab4py-1.0.4\src
creating graphab4py-1.0.4\src\graphab4py
creating graphab4py-1.0.4\src\graphab4py.egg-info
copying files to graphab4py-1.0.4...
copying LICENSE -> graphab4py-1.0.4
copying README.rst -> graphab4py-1.0.4
copying pyproject.toml -> graphab4py-1.0.4
copying setup.py -> graphab4py-1.0.4
copying src\graphab4py\__init__.py -> graphab4py-1.0.4\src\graphab4py
copying src\graphab4py\functions.py -> graphab4py-1.0.4\src\graphab4py
copying src\graphab4py\project.py -> graphab4py-1.0.4\src\graphab4py
copying src\graphab4py.egg-info\PKG-INFO -> graphab4py-1.0.4\src\graphab4py.egg-info
copying src\graphab4py.egg-info\SOURCES.txt -> graphab4py-1.0.4\src\graphab4py.egg-info
copying src\graphab4py.egg-info\dependency_links.txt -> graphab4py-1.0.4\src\graphab4py.egg-info
copying src\graphab4py.egg-info\requires.txt -> graphab4py-1.0.4\src\graphab4py.egg-info
copying src\graphab4py.egg-info\top_level.txt -> graphab4py-1.0.4\src\graphab4py.egg-info
copying src\graphab4py.egg-info\SOURCES.txt -> graphab4py-1.0.4\src\graphab4py.egg-info
Writing graphab4py-1.0.4\setup.cfg
Creating tar archive
removing 'graphab4py-1.0.4' (and everything under it)
* Building wheel from sdist
* Creating venv isolated environment...
* Installing packages in isolated environment... (setuptools>=61.0, wheel)
* Getting build dependencies for wheel...
running egg_info
writing src\graphab4py.egg-info\PKG-INFO
writing dependency_links to src\graphab4py.egg-info\dependency_links.txt
writing requirements to src\graphab4py.egg-info\requires.txt
writing top-level names to src\graphab4py.egg-info\top_level.txt
reading manifest file 'src\graphab4py.egg-info\SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'src\graphab4py.egg-info\SOURCES.txt'
* Installing packages in isolated environment... (wheel)
* Building wheel...
running bdist_wheel
running build
running build_py
creating build
creating build\lib
creating build\lib\graphab4py
copying src\graphab4py\functions.py -> build\lib\graphab4py
copying src\graphab4py\project.py -> build\lib\graphab4py
copying src\graphab4py\__init__.py -> build\lib\graphab4py
running egg_info
writing src\graphab4py.egg-info\PKG-INFO
writing dependency_links to src\graphab4py.egg-info\dependency_links.txt
writing requirements to src\graphab4py.egg-info\requires.txt
writing top-level names to src\graphab4py.egg-info\top_level.txt
reading manifest file 'src\graphab4py.egg-info\SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'src\graphab4py.egg-info\SOURCES.txt'
installing to build\bdist.win-amd64\wheel
running install
running install_lib
creating build\bdist.win-amd64
creating build\bdist.win-amd64\wheel
creating build\bdist.win-amd64\wheel\graphab4py
copying build\lib\graphab4py\functions.py -> build\bdist.win-amd64\wheel\.\graphab4py
copying build\lib\graphab4py\project.py -> build\bdist.win-amd64\wheel\.\graphab4py
copying build\lib\graphab4py\__init__.py -> build\bdist.win-amd64\wheel\.\graphab4py
running install_egg_info
Copying src\graphab4py.egg-info to build\bdist.win-amd64\wheel\.\graphab4py-1.0.4-py3.11.egg-info
running install_scripts
creating build\bdist.win-amd64\wheel\graphab4py-1.0.4.dist-info\WHEEL
creating 'H:\git\graphab4py\dist\.tmp-wmoibnbf\graphab4py-1.0.4-py3-none-any.whl' and adding 'build\bdist.win-amd64\wheel' to it
adding 'graphab4py/__init__.py'
adding 'graphab4py/functions.py'
adding 'graphab4py/project.py'
adding 'graphab4py-1.0.4.dist-info/LICENSE'
adding 'graphab4py-1.0.4.dist-info/METADATA'
adding 'graphab4py-1.0.4.dist-info/WHEEL'
adding 'graphab4py-1.0.4.dist-info/top_level.txt'
adding 'graphab4py-1.0.4.dist-info/RECORD'
removing build\bdist.win-amd64\wheel
Successfully built graphab4py-1.0.4.tar.gz and graphab4py-1.0.4-py3-none-any.whl

但是,当我尝试将其上传到 PyPI 时,它失败并显示以下输出:

H:\git\graphab4py>twine upload dist/*
Uploading distributions to https://upload.pypi.org/legacy/
Uploading graphab4py-1.0.4-py3-none-any.whl
100% ---------------------------------------- 29.3/29.3 kB • 00:00 • 271.1 kB/s
WARNING  Error during upload. Retry with the --verbose option for more details.
ERROR    HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
         The description failed to render for 'text/x-rst'. See https://pypi.org/help/#description-content-type for
         more information.

使用

--verbose
选项,我得到:

H:\git\graphab4py>twine upload dist/* --verbose
INFO     Using configuration from C:\Users\poppman\.pypirc
Uploading distributions to https://upload.pypi.org/legacy/
INFO     dist\graphab4py-1.0.4-py3-none-any.whl (18.3 KB)
INFO     dist\graphab4py-1.0.4.tar.gz (19.2 KB)
INFO     username set from config file
INFO     password set from config file
INFO     username: __token__
INFO     password: <hidden>
Uploading graphab4py-1.0.4-py3-none-any.whl
100% ---------------------------------------- 29.3/29.3 kB • 00:00 • 1.3 MB/s
INFO     Response from https://upload.pypi.org/legacy/:
         400 The description failed to render for 'text/x-rst'. See https://pypi.org/help/#description-content-type for
         more information.
INFO     <html>
          <head>
           <title>400 The description failed to render for 'text/x-rst'. See
         https://pypi.org/help/#description-content-type for more information.</title>
          </head>
          <body>
           <h1>400 The description failed to render for 'text/x-rst'. See
         https://pypi.org/help/#description-content-type for more information.</h1>
           The server could not comply with the request since it is either malformed or otherwise incorrect.<br/><br/>
         The description failed to render for &#x27;text/x-rst&#x27;. See
         https://pypi.org/help/#description-content-type for more information.


          </body>
         </html>
ERROR    HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
         The description failed to render for 'text/x-rst'. See https://pypi.org/help/#description-content-type for
         more information.

我能够上传早期版本。从那时起,我只更改了一些文档字符串并使用 Sphinx 构建了文档。此版本的软件包已位于 GitHub 上,其中 README.rst 已正确显示。

我认为问题与 Sphinx 文件有关并排除了 setup.py 中的 ./docs,但我仍然收到错误。

当前的 README.rst 如下所示:

.. role:: bash(code)
   :language: bash

.. role:: python(code)
   :language: python

.. raw:: html

   <p align="center">
     <img src="/docs/img/Ga4Py.png" alt="Graphab4py Logo" width="400">
   </p>
   

----

.. image:: https://img.shields.io/pypi/v/graphab4py.svg
   :target: https://pypi.org/project/graphab4py/

.. image:: https://img.shields.io/pypi/pyversions/graphab4py.svg
   :target: https://pypi.org/project/graphab4py

.. _Supported Python Versions: https://pypi.org/project/graphab4py

.. image:: https://travis-ci.org/username/graphab4py.svg?branch=master
   :target: https://travis-ci.org/username/graphab4py

.. _Build Status: https://travis-ci.org/username/graphab4py

.. image:: https://img.shields.io/pypi/dm/graphab4py.svg?label=PyPI%20downloads
   :target: https://pypi.org/project/graphab4py

.. _PyPI Downloads: https://pypi.org/project/graphab4py

.. image:: https://img.shields.io/badge/license-UNLICENSE-green.svg
   :target: https://unlicense.org/

=====
About
=====
This package provides a Python interface to the program `Graphab <https://sourcesup.renater.fr/www/graphab/en/home.html/>`_.
The author(s) of this Python package are not developing Graphab.
Rather, Graphab is an independent software which provides a graphical user interface, as well as a command line interface.
Further information on Graphab can be found `here <https://sourcesup.renater.fr/www/graphab/en/home.html>`_.

Also view the `documentation <https://htmlpreview.github.io/?https://github.com/ManuelPopp/graphab4py/blob/main/docs/build/html/index.html>`_ of this Python package.

=============
Prerequisites
=============
In order to install and use Graphab4py, `Python <https://www.python.org>`_ >= 3.8 and `Java <https://www.java.com>`_ >= 8 are both required.
It is also recommended to have `pip <https://pip.pypa.io/en/stable/installation/>`_ available to install the `latest version <https://pypi.org/project/graphab4py/#history>`_ of Graphab4py.
Graphab is not required for installation. It can be installed through Graphab4py if missing. Alternatively, Graphab4py can be set up to use an existing Graphab Java executable.

============
Installation
============
Graphab4Py is available on `PyPI <https://pypi.org/project/graphab4py>`_. To install Graphab4Py, simply run the following line:

.. code-block:: console
   
   pip install graphab4py
   

========
Examples
========
With Graphab4py installed, we will now look at a few examples.

Creating a project
++++++++++++++++++
In the following, we will create a new Graphab project from scratch.

.. code-block:: python
   
   import graphab4py
   graphab4py.set_graphab("/home/rca/opt/")
   prj = graphab4py.Project()
   
   prj.create_project(
       name = "MyProject", patches = "/home/rca/dat/pat/Patches.tif",
       habitat = 1, directory = "/home/rca/prj"
       )
   
   prj.create_linkset(
       disttype = "cost",
       linkname = "L1",
       threshold = 100000,
       cost_raster = "/home/rca/dat/res/resistance_surface.tif"
       )
   
   prj.create_graph(graphname = "G1")
   
   prj.save()
   
In this example, Graphab has already been downloaded and saved to a folder named :bash:`/home/rca/opt/`.
In a first step, Graphab4py is pointed to this folder. ALternatively, the :python:`get_graphab()` function can be used to download Graphab to a specific location.
Subsequently, the project is initialized. Here, the project is given a name and a project folder is created. Moreover, a file containing habitat patches must be provided.
This file is a raster (e.g., a GeoTIFF \*.tif file) with values encoded as INT2S. (Graphab does not accept another format.) The value or values for habitat patches must also be provided.
Now, we create a linkset. The values allowed for :python:`disttype` are :python:`"euclid"` and :python:`"cost"`, which refer to euclidean distance and cumulated cost.
For a linkset based on euclidean distances, the :python:`cost_raster` argument is not used. When, instead, a resistance surface is used, it needs to be provided as a raster file, as indicated in the example.
Moreover, a threshold can be set, to limit the distance for which links are calculated. This may be necessary when dealing with large sets of habitat patches in order to limit computing time.
Finally, we create a graph and save the project.

Loading an existing project
+++++++++++++++++++++++++++
Graphab4py can load existing Graphab projects (\*.xml). However, it also has its own format (\*.g4p) to save and load projects.

.. code-block:: python
   
   import graphab4py
   prj = graphab4py.Project()
   prj.load_project_xml("/home/rca/prj/MyProject/MyProject.g4p")
   
   prj.enable_distance_conversion(
      save_plot = "/home/rca/out/Distance_conversion.png", max_euc = 2200
      )
   
   prj.convert_distance(500, regression = "log")
   
   out = prj.calculate_metric(metric = "EC", d = 1500, p = 0.05)
   ec = out["metric_value"]
   
In this example, we load a project from a Graphab4py project file. Subsequently, we use the linkset that we have created in the previous step to establish a relationship between euclidean and cost distance.
We can set limits to the euclidean distance considered for fitting the model, in order to fit the model to a relevant interval of our data.
When :python:`save_plot` is set to a valid path, a figure is created, so we can inspect the relationship and decide whether we want to use the respective regression mode.
By default, a linear regression is forced through zero. We decided that in our case, a log-log regression might give better results.
We can use the :python:`convert_distance` function directly to establish a relationship and return an estimation for a distance translation.
If no relationship for the given distance interval and regression model has established so far, the method will internally call :python:`enable_distance_conversion` and pass the required arguments.
Note that changing the distance interval will overwrite any previously fit model for the same linkset and model type.
In the last line, we calculate the metric "equivalent connectivity" (EC) for the entire graph. This metric requires additional parameters :python:`d` and :python:`p`.
Other metrics might not require additional parameters. A list of all the available metrics and their parameters and properties can be viewed in the original `Graphab manual <https://sourcesup.renater.fr/www/graphab/en/documentation.html>`_.

=======
License
=======
This is free and unencumbered software released into the public domain, as declared in the `LICENSE <https://github.com/ManuelPopp/graphab4py/blob/main/LICENSE>`_ file.

并且它在

setup.py
中用于参数
long_description
open()
。我将其替换为空字符串,但随后
twine check dist/*
返回:


Checking dist\graphab4py-1.0.4-py3-none-any.whl: FAILED
ERROR    `long_description` has syntax errors in markup and would not be rendered on PyPI.
         line 7: Warning: "raw" directive disabled.
Checking dist\graphab4py-1.0.4.tar.gz: FAILED
ERROR    `long_description` has syntax errors in markup and would not be rendered on PyPI.
         line 7: Warning: "raw" directive disabled.
python sphinx restructuredtext twine
1个回答
0
投票

我发现问题是

.. raw:: html

在 README.rst 文件中。删除它后,一切都会按预期进行。只是使用时图像不再在 GitHub 页面居中

.. image:: ./docs/img/Ga4Py.png
   :align: center
   :alt: Logo
   :width: 400px

而不是 html。

© www.soinside.com 2019 - 2024. All rights reserved.