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

chore: migrate project metadata to pyproject.toml #436

Merged
merged 5 commits into from
Mar 16, 2025

Conversation

afuetterer
Copy link
Contributor

@afuetterer afuetterer commented Mar 6, 2025

Fixes #435

I migrated the information found in setup.py to pyproject.toml.

What do you think?

Tasks

  • replace xmlschema[codegen,docs] with xmlschema[docs] in dev group
  • include tool settings from .coveragerc
  • include tool settings from mypy.ini
  • add tool.setuptools.license-files key
  • fix or skip failing test (depends on setup.py)

@afuetterer
Copy link
Contributor Author

Do you want to include the settings from .coveragerc and mypy.ini here as well?

@brunato
Copy link
Member

brunato commented Mar 7, 2025

Do you want to include the settings from .coveragerc and mypy.ini here as well?

Yes, include them
thanks

@brunato
Copy link
Member

brunato commented Mar 7, 2025

Fixes #435

I migrated the information found in setup.py to pyproject.toml.

What do you think?

Seems clear e simpler to maintain. I will approve after an inclusion of a link to the LICENSE file.
thank you

mypy
lxml-stubs
-e .
-e .[dev]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure if you need to have this list as well? It is redundant with the dev group. What do you think?

@@ -1,2 +0,0 @@
[mypy]
show_error_codes = True
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is now enabled by default.

@afuetterer
Copy link
Contributor Author

You have test cases that rely on setup.py in https://github.com/sissaschool/xmlschema/blob/master/tests/test_package.py.

Remove those?

@afuetterer
Copy link
Contributor Author

I am a huge fan of this github action: https://github.com/hynek/build-and-inspect-python-package

It checks if the package can be built and it outputs inspection results. You want to test it?

@brunato
Copy link
Member

brunato commented Mar 8, 2025

You have test cases that rely on setup.py in https://github.com/sissaschool/xmlschema/blob/master/tests/test_package.py.

Remove those?

try to replace 'setup.py' with 'pyproject.toml' or decorate with unittest.skip

@brunato
Copy link
Member

brunato commented Mar 8, 2025

I am a huge fan of this github action: https://github.com/hynek/build-and-inspect-python-package

It checks if the package can be built and it outputs inspection results. You want to test it?

Not now, it's very interesting but the testing process of xmlschema it's a mix of package's tests and W3C xsdtests, so deciding when is the package is ready for publishing doesn't depend only on CI tests.

@afuetterer
Copy link
Contributor Author

How to proceed?

FAILED (failures=5, errors=1, skipped=3)

  • tests/test_package.py
  • tests/test_typing.py

You want to unittest.skip those tests?

@brunato
Copy link
Member

brunato commented Mar 15, 2025

How to proceed?

FAILED (failures=5, errors=1, skipped=3)

* tests/test_package.py

* tests/test_typing.py

You want to unittest.skip those tests?

I can merge anyway despite the failing tests (minor things anyway, but static typing errors have to be checked also against the next major release of elementpath that is ready) because the contribution will be then merged in v4.0 develop for final tests of the new major release).

Waiting for your feedback, if you can, add a skip on failing tests, but don't mind about that if you can't.

Then if it's okay for you, I'll squash and merge your commits after your feedback.

Best

@afuetterer
Copy link
Contributor Author

I am not sure, if I understand what you mean.

I skipped two tests, that depend on setup.py being present.

Still: FAILED (failures=5, skipped=5)

I don't know, why the typing tests fail. I did not touch the code itself. Were they passing before?

Yes, feel free to squash and merge, if you want to work on the tests individually.

@brunato brunato merged commit 36b831f into sissaschool:master Mar 16, 2025
20 checks passed
@brunato
Copy link
Member

brunato commented Mar 17, 2025

Hi,
I'm trying to build a v3.4.4 of the package after fixed type annotation errors but the packages discovery method of setuptools with pyproject.toml seems to not work like with setup.py configuration.

Within setup.py there was these config entries:

    packages=find_packages(include=['xmlschema*']),
    package_data={
        'xmlschema': ['py.typed', 'locale/**/*.mo', 'locale/**/*.po', 'schemas/*/*.xsd'],
        'xmlschema.extras': ['templates/*/*.jinja'],
    },

using packages = ["xmlschema"] (the configuration of your PR) or replacing it with [tool.setuptools.packages.find] and [tool.setuptools.package-data] sections produces a bunch of warnings like that:

/tmp/build-env-lg2nte8h/lib64/python3.13/site-packages/setuptools/command/build_py.py:212: _Warning: Package 'xmlschema.schemas.XHTML' is absent from the `packages` configuration.
!!

        ********************************************************************************
        ############################
        # Package would be ignored #
        ############################
        Python recognizes 'xmlschema.schemas.XHTML' as an importable package[^1],
        but it is absent from setuptools' `packages` configuration.

        This leads to an ambiguous overall configuration. If you want to distribute this
        package, please make sure that 'xmlschema.schemas.XHTML' is explicitly added
        to the `packages` configuration field.

        Alternatively, you can also rely on setuptools' discovery methods
        (for example by using `find_namespace_packages(...)`/`find_namespace:`
        instead of `find_packages(...)`/`find:`).

        You can read more about "package discovery" on setuptools documentation page:

        - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

        If you don't want 'xmlschema.schemas.XHTML' to be distributed and are
        already explicitly excluding 'xmlschema.schemas.XHTML' via
        `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
        you can try to use `exclude_package_data`, or `include-package-data=False` in
        combination with a more fine grained `package-data` configuration.

        You can read more about "package data files" on setuptools documentation page:

        - https://setuptools.pypa.io/en/latest/userguide/datafiles.html


        [^1]: For Python, any directory (with suitable naming) can be imported,
              even if it does not contain any `.py` files.
              On the other hand, currently there is no concept of package data
              directory, all directories are treated like packages.
        ********************************************************************************

Tried all the possible options on these sections but the result is a correct wheel with a bunch of warnings or an incomplete wheel (package-data is not included).

Any ideas for that?

Thank you

@afuetterer
Copy link
Contributor Author

Per documentation include-package-data defaults to True, so package data should be included.
Ref: https://setuptools.pypa.io/en/latest/userguide/datafiles.html

What command are you running, that results in the errors / warnings?

python -m build?

@brunato
Copy link
Member

brunato commented Mar 17, 2025

What command are you running, that results in the errors / warnings?

python -m build?

yes, using tox -e build

@brunato
Copy link
Member

brunato commented Mar 18, 2025

The difference is mainly on include-package-data that was False with setup.py.

An new-style configuration that works as expected (full wheel, no discover warnings) includes:

[tool.setuptools]
license-files = [ "LICENSE" ]
include-package-data = false

[tool.setuptools.package-data]
xmlschema = [
    'py.typed', 
    'locale/**/*.mo', 
    'locale/**/*.po', 
    'schemas/*/*.xsd',
    'extras/templates/*/*.jinja'
]

[tool.setuptools.packages.find]
include = ["xmlschema*"]
namespaces = false

The alternative with include-package-data enabled is:

[tool.setuptools]
license-files = [ "LICENSE" ]

[tool.setuptools.exclude-package-data]
xmlschema = ["xmlschema.egg-info*"]

[tool.setuptools.packages.find]
include = ["xmlschema*"]

but warnings appear adding namespaces = false (the other configuration works with or without namespaces).

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.

Migrate project metadata to pyproject.toml (PEP 621)
2 participants