Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize packaging system #80

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

derekbarbosa
Copy link

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 using pip install . and editable install using pip install -e .

Solves #79

@derekbarbosa
Copy link
Author

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

@leforestier
Copy link
Owner

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
Copy link
Author

derekbarbosa commented Jun 13, 2024

@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
Copy link
Owner

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
Copy link

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?

@@ -0,0 +1,49 @@
[build-system]
requires = ["setuptools"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
requires = ["setuptools"]
requires = ["setuptools", "wheel"]

If you add the wheel directive here, a pure Python wheel will also be generated during the build phase. This wheel can be useful for compatibility with some Python environments, e.g., Pyodide

authors = [
{name = "Benjamin Le Forestier", email = "benjamin@leforestier.org"},
]
version = "1.15.2"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can avoid duplicating the version here by substituting this line with

dynamic = ["version"]

and adding the following at the bottom of the file

[tool.setuptools.dynamic]
version = {attr = "yattag.__version__"}

@leforestier
Copy link
Owner

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
Copy link

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants