leforestier / yattag

Python library to generate HTML or XML in a readable, concise and pythonic way.
328 stars 31 forks source link

Standardize packaging system #80

Open derekbarbosa opened 3 months ago

derekbarbosa commented 3 months ago
DEPRECATION: yattag is being installed using the legacy 'setup.py install' method, 
because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. 

Pip 23.1 will enforce this behaviour change. 

A possible replacement is to enable the '--use-pep517' option. 

Discussion can be found at https://github.com/pypa/pip/issues/8559

Convert this project to use a more standard method of installation (pyproject.toml). This enables setup tools to be used on the backend, and have metadata configured via a .toml frontend.

While setup.py is not fully deprecated for the time being, convert the current setup.py project structure to include a pyproject.toml to prevent any deprecation (as demonstrated by this [guide] (https://packaging.python.org/en/latest/guides/modernize-setup-py-project/#modernize-setup-py-project)).

This will also allow for installation locally usingpip install . and editable install using pip install -e .

Solves #79

derekbarbosa commented 3 months ago

@leforestier sorry for the delay, here's the PR.

leforestier commented 3 months ago

Hello Derek, thanks for the pull request, that looks great. I saw you deleted the setup.py file. Was there no way to keep it in case some people still rely on that method of installing? Yattag is quite an old project so it's possible some people have install scripts that install Yattag using the old method/old tooling. Thanks again for your contribution.

derekbarbosa commented 3 months ago

@leforestier heya,

thanks.

let me give it a try. we certainly don't want to break it for people using a manual install from source (and have it scripted).

my only counterpoint would be that those scripts as entry points (i.e. the python setup.py method) would be very old, and deprecated at this point (see: https://packaging.python.org/en/latest/discussions/setup-py-deprecated/#)

nothing has really changed other than the invocation command being pip install . -- setup tools is still working on the backend.

But, it doesn't hurt to try. I will reincorporate setup.py to the repository and see if both files can live in harmony :)

EDIT: seems like some metadata fields in setup.py override pyproject.toml -- however, a blank setup.py seems to work. I am met with this error in Python 3.11+ however:

 SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!
  self.initialize_options()
/Users/derekbarbosa/workspace/venv/lib/python3.12/site-packages/setuptools/_distutils/cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` and ``easy_install``.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://github.com/pypa/setuptools/issues/917 for details.
        ********************************************************************************

!!
  self.initialize_options()
zip_safe flag not set; analyzing archive contents...
leforestier commented 2 months ago

I'm going to look into this setup.py issue as soon as I have a bit of time, and if can't be solved better than this, I think I will just merge your pull request as is. Sorry for the slow reply time and thank you again for your contribution.

stianlagstad commented 2 months ago

In other projects I have this small setup.py:

from setuptools import setup  # type: ignore

if __name__ == "__main__":
    setup()

Maybe try to just add that?

leforestier commented 2 weeks ago

Thanks for your advice, Glass.

By the way, I was wondering in what environment you got a warning/deprecation message by installing yattag? I've tested a pip install yattag in two recent Python docker image (python:3.12-rc-slim-bullseye and python:3.13-rc-slim-bullseye) and got no warning message, so I tend to think the issue is not urgent. I still plan to look into the most recent packaging methods soon, but I was wondering in what environment you got that deprecation message.

GlassOfWhiskey commented 2 weeks ago

Hi @leforestier, I don't know exactly because I was not the original opener of this PR and the related issue. However, here you can find the current status of setup.py and pyproject.toml as packaging manifests. The trend is to favor the latter as the new preferred way to express Python packages' metadata. Honestly, what concerned me the most was the lack of a Python wheel, which prevents Pyodide to correctly compile the package without further hacks :)