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

(Not) Exclude tests from source distribution, and drop python2 tag for wheel #202

Merged
merged 6 commits into from
Sep 20, 2024

Conversation

DanielYang59
Copy link
Collaborator

@DanielYang59 DanielYang59 commented Sep 19, 2024

Summary

MANIFEST.in Outdated
Copy link
Owner

Choose a reason for hiding this comment

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

is there any way to do this without a MANIFEST.in file? i try to minimize config files in the repo root directory, esp. if they just have a few lines

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At least from pypa/setuptools#3260 (comment), the answer might be no:

If you want to modify the contents of the sdist (process A), you cannot do that via the pyproject.toml. Either you have to use MANIFEST.in or rely on the selection done by your plugin of choice (e.g. setuptools-scm).

Personally I prefer to avoid including additional config files whenever possible too. I would do some more research on this.

Copy link
Owner

Choose a reason for hiding this comment

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

i think if MANIFEST.in is the only way to exclude them, i slightly prefer to leave the tests file in the source dist

Copy link
Collaborator Author

@DanielYang59 DanielYang59 Sep 20, 2024

Choose a reason for hiding this comment

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

I don't have a strong preference this time, mostly because the tests are pretty small in size and don't include any test file.

I might do some further research later, hoping I missed something here :) Looks like no way around this except for the below

Pin another related discussion on why tests are still included in sdist when exclude tests in packages: pypa/setuptools#3922 (comment)

There is some level of agreement in the community that believe it is a good practice to include test files into the sdists, that is why setuptools include them by default.

If you don't want to include files in the sdist, that is still possible, but the configuration that you need to change is the one in MANIFEST.in: https://setuptools.pypa.io/en/latest/userguide/miscellaneous.html (not packages).

Copy link
Collaborator Author

@DanielYang59 DanielYang59 Sep 20, 2024

Choose a reason for hiding this comment

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

Other workarounds I just thought of might be:

  1. rename tests (to pmv_tests for example), now that we have:

    pymatviz/pyproject.toml

    Lines 70 to 71 in b551581

    [tool.pytest.ini_options]
    testpaths = ["tests"]

    Files that match the following glob patterns: tests/test*.py, test/test*.py;

  2. move to the src layout

Frankly I like neither of them, just mention them.


[tool.setuptools.package-data]
pymatviz = ["*.csv"]

[tool.distutils.bdist_wheel]
universal = true
Copy link
Collaborator Author

@DanielYang59 DanielYang59 Sep 19, 2024

Choose a reason for hiding this comment

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

This tag might have been misused here:

If your project also supports Python 2 and contains no C extensions, then you should create what’s called a Universal Wheel by adding the following to your setup.cfg file:
[bdist_wheel]
universal=1

For our pure python code:

The wheel package will detect that the code is pure Python, and build a wheel that’s named such that it’s usable on any Python 3 installation. For details on the naming of wheel files, see PEP 425.

Now:

python3 -m build --wheel
>>> Successfully built pymatviz-0.11.0-py3-none-any.whl

Copy link
Owner

Choose a reason for hiding this comment

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

good to know! thanks for troubleshooting. 👍

i have that line in a bunch of my projects. sounds like i should remove it everywhere. could you remove it here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep it has already been removed :)

@DanielYang59 DanielYang59 changed the title Exclude tests from source distribution Exclude tests from source distribution, and drop python2 tag for wheel Sep 19, 2024
* `element_pair_rdfs` plots radial distribution functions (RDFs) for element pairs in a structure (#203)

* improve set_plotly_template auto-complete with Literal type

* add element_pair_rdfs(structure) -> go.Figure in new pymatviz/rdf.py module

* add tests/test_rdf.py

* remove ase.Atoms conversion to avoid new pkg dep

* show element_pair_rdfs examples in readme

* should have used save_and_compress_svg

* fix rds svg path

---------

Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com>
@janosh janosh marked this pull request as ready for review September 20, 2024 14:14
Copy link
Owner

@janosh janosh left a comment

Choose a reason for hiding this comment

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

thanks @DanielYang59! 👍 i'll go ahead and merge if you don't mind?

@DanielYang59
Copy link
Collaborator Author

Sure thanks!

@janosh janosh merged commit 9c6f926 into main Sep 20, 2024
22 checks passed
@janosh janosh deleted the exclude-tests-from-pkg branch September 20, 2024 15:03
@DanielYang59 DanielYang59 changed the title Exclude tests from source distribution, and drop python2 tag for wheel (Not) Exclude tests from source distribution, and drop python2 tag for wheel Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg Package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tests are included in source distribution?
2 participants