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

Move project setup to pyproject.toml and build package with "build". #1325

Merged
merged 3 commits into from Jan 2, 2023

Conversation

smithdc1
Copy link
Member

@smithdc1 smithdc1 commented Jan 1, 2023

When I first started working on this both python -m build and check-manifest were raising multiple errors.

I've now moved the setup to pyproject.toml inline with the current python packaging tutorial [1]. Updating the manifest.in file was also needed to ensure that all the correct files are included, and also to exclude others (e.g. __pycache__).

Here is the output of running python -m build locally.

* Creating virtualenv isolated environment...
* Installing packages in isolated environment... (setuptools>=61.0)
* Getting build dependencies for sdist...
C:\Users\smith\AppData\Local\Temp\build-env-6sev9jtg\Lib\site-packages\setuptools\config\setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_fil
es instead.
  warnings.warn(msg, warning_class)
C:\Users\smith\AppData\Local\Temp\build-env-6sev9jtg\Lib\site-packages\setuptools\config\pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *
beta*.
  warnings.warn(msg, _BetaConfiguration)
No `packages` or `py_modules` configuration, performing automatic discovery.
`flat-layout` detected -- analysing .
discovered packages -- ['crispy_forms', 'crispy_forms.templatetags']
running egg_info
writing django_crispy_forms.egg-info\PKG-INFO
writing dependency_links to django_crispy_forms.egg-info\dependency_links.txt
writing requirements to django_crispy_forms.egg-info\requires.txt
writing top-level names to django_crispy_forms.egg-info\top_level.txt
reading manifest file 'django_crispy_forms.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE.txt'
writing manifest file 'django_crispy_forms.egg-info\SOURCES.txt'
* Building sdist...
C:\Users\smith\AppData\Local\Temp\build-env-6sev9jtg\Lib\site-packages\setuptools\config\setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_fil
es instead.
  warnings.warn(msg, warning_class)
C:\Users\smith\AppData\Local\Temp\build-env-6sev9jtg\Lib\site-packages\setuptools\config\pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *
beta*.
  warnings.warn(msg, _BetaConfiguration)
No `packages` or `py_modules` configuration, performing automatic discovery.
`flat-layout` detected -- analysing .
discovered packages -- ['crispy_forms', 'crispy_forms.templatetags']
running sdist
running egg_info
writing django_crispy_forms.egg-info\PKG-INFO
writing dependency_links to django_crispy_forms.egg-info\dependency_links.txt
writing requirements to django_crispy_forms.egg-info\requires.txt
writing top-level names to django_crispy_forms.egg-info\top_level.txt
reading manifest file 'django_crispy_forms.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE.txt'
writing manifest file 'django_crispy_forms.egg-info\SOURCES.txt'
running check
creating django-crispy-forms-2.0
creating django-crispy-forms-2.0\crispy_forms
creating django-crispy-forms-2.0\crispy_forms\templatetags
creating django-crispy-forms-2.0\django_crispy_forms.egg-info
creating django-crispy-forms-2.0\docs
creating django-crispy-forms-2.0\docs\_templates
creating django-crispy-forms-2.0\docs\images
creating django-crispy-forms-2.0\requirements
creating django-crispy-forms-2.0\tests
creating django-crispy-forms-2.0\tests\results
creating django-crispy-forms-2.0\tests\results\bootstrap
creating django-crispy-forms-2.0\tests\results\bootstrap\test_layout_objects
creating django-crispy-forms-2.0\tests\templates
copying files to django-crispy-forms-2.0...
copying .editorconfig -> django-crispy-forms-2.0
copying .pre-commit-config.yaml -> django-crispy-forms-2.0
copying CHANGELOG.md -> django-crispy-forms-2.0
copying CONTRIBUTORS.txt -> django-crispy-forms-2.0
copying LICENSE.txt -> django-crispy-forms-2.0
copying MANIFEST.in -> django-crispy-forms-2.0
copying Makefile -> django-crispy-forms-2.0
copying README.rst -> django-crispy-forms-2.0
copying pyproject.toml -> django-crispy-forms-2.0
copying requirements.txt -> django-crispy-forms-2.0
copying setup.cfg -> django-crispy-forms-2.0
copying tox.ini -> django-crispy-forms-2.0
copying crispy_forms\LICENSE -> django-crispy-forms-2.0\crispy_forms
copying crispy_forms\__init__.py -> django-crispy-forms-2.0\crispy_forms
copying crispy_forms\base.py -> django-crispy-forms-2.0\crispy_forms
copying crispy_forms\bootstrap.py -> django-crispy-forms-2.0\crispy_forms
copying crispy_forms\exceptions.py -> django-crispy-forms-2.0\crispy_forms
copying crispy_forms\helper.py -> django-crispy-forms-2.0\crispy_forms
copying crispy_forms\layout.py -> django-crispy-forms-2.0\crispy_forms
copying crispy_forms\layout_slice.py -> django-crispy-forms-2.0\crispy_forms
copying crispy_forms\utils.py -> django-crispy-forms-2.0\crispy_forms
copying crispy_forms\templatetags\__init__.py -> django-crispy-forms-2.0\crispy_forms\templatetags
copying crispy_forms\templatetags\crispy_forms_field.py -> django-crispy-forms-2.0\crispy_forms\templatetags
copying crispy_forms\templatetags\crispy_forms_filters.py -> django-crispy-forms-2.0\crispy_forms\templatetags
copying crispy_forms\templatetags\crispy_forms_tags.py -> django-crispy-forms-2.0\crispy_forms\templatetags
copying crispy_forms\templatetags\crispy_forms_utils.py -> django-crispy-forms-2.0\crispy_forms\templatetags
copying django_crispy_forms.egg-info\PKG-INFO -> django-crispy-forms-2.0\django_crispy_forms.egg-info
copying django_crispy_forms.egg-info\SOURCES.txt -> django-crispy-forms-2.0\django_crispy_forms.egg-info
copying django_crispy_forms.egg-info\dependency_links.txt -> django-crispy-forms-2.0\django_crispy_forms.egg-info
copying django_crispy_forms.egg-info\requires.txt -> django-crispy-forms-2.0\django_crispy_forms.egg-info
copying django_crispy_forms.egg-info\top_level.txt -> django-crispy-forms-2.0\django_crispy_forms.egg-info
copying docs\Makefile -> django-crispy-forms-2.0\docs
copying docs\__init__.py -> django-crispy-forms-2.0\docs
copying docs\api_bootstrap.rst -> django-crispy-forms-2.0\docs
copying docs\api_helpers.rst -> django-crispy-forms-2.0\docs
copying docs\api_layout.rst -> django-crispy-forms-2.0\docs
copying docs\api_templatetags.rst -> django-crispy-forms-2.0\docs
copying docs\concepts.rst -> django-crispy-forms-2.0\docs
copying docs\conf.py -> django-crispy-forms-2.0\docs
copying docs\contributing.rst -> django-crispy-forms-2.0\docs
copying docs\crispy_tag_forms.rst -> django-crispy-forms-2.0\docs
copying docs\crispy_tag_formsets.rst -> django-crispy-forms-2.0\docs
copying docs\dynamic_layouts.rst -> django-crispy-forms-2.0\docs
copying docs\faq.rst -> django-crispy-forms-2.0\docs
copying docs\filters.rst -> django-crispy-forms-2.0\docs
copying docs\form_helper.rst -> django-crispy-forms-2.0\docs
copying docs\index.rst -> django-crispy-forms-2.0\docs
copying docs\install.rst -> django-crispy-forms-2.0\docs
copying docs\layouts.rst -> django-crispy-forms-2.0\docs
copying docs\make.bat -> django-crispy-forms-2.0\docs
copying docs\requirements.txt -> django-crispy-forms-2.0\docs
copying docs\settings.py -> django-crispy-forms-2.0\docs
copying docs\template_packs.rst -> django-crispy-forms-2.0\docs
copying docs\_templates\sidebarintro.html -> django-crispy-forms-2.0\docs\_templates
copying docs\images\accordiongroup_and_accordion.jpg -> django-crispy-forms-2.0\docs\images
copying docs\images\alert.png -> django-crispy-forms-2.0\docs\images
copying docs\images\appended_prepended_text.png -> django-crispy-forms-2.0\docs\images
copying docs\images\appended_text.png -> django-crispy-forms-2.0\docs\images
copying docs\images\bootstrap3_horizontal_form.jpg -> django-crispy-forms-2.0\docs\images
copying docs\images\bootstrap3_inline_form.jpg -> django-crispy-forms-2.0\docs\images
copying docs\images\checkbox.png -> django-crispy-forms-2.0\docs\images
copying docs\images\custom_checkbox.png -> django-crispy-forms-2.0\docs\images
copying docs\images\custom_file_field.png -> django-crispy-forms-2.0\docs\images
copying docs\images\custom_radio.png -> django-crispy-forms-2.0\docs\images
copying docs\images\custom_select.png -> django-crispy-forms-2.0\docs\images
copying docs\images\field_disabled.png -> django-crispy-forms-2.0\docs\images
copying docs\images\field_with_buttons.png -> django-crispy-forms-2.0\docs\images
copying docs\images\file_field.png -> django-crispy-forms-2.0\docs\images
copying docs\images\form_actions.png -> django-crispy-forms-2.0\docs\images
copying docs\images\inline_checkboxes.png -> django-crispy-forms-2.0\docs\images
copying docs\images\inline_radios.jpg -> django-crispy-forms-2.0\docs\images
copying docs\images\modal.png -> django-crispy-forms-2.0\docs\images
copying docs\images\prepended_text.png -> django-crispy-forms-2.0\docs\images
copying docs\images\radio.png -> django-crispy-forms-2.0\docs\images
copying docs\images\select.png -> django-crispy-forms-2.0\docs\images
copying docs\images\strict_button.png -> django-crispy-forms-2.0\docs\images
copying docs\images\tab_and_tabholder.jpg -> django-crispy-forms-2.0\docs\images
copying requirements\dev.txt -> django-crispy-forms-2.0\requirements
copying requirements\lint.txt -> django-crispy-forms-2.0\requirements
copying requirements\testing.txt -> django-crispy-forms-2.0\requirements
copying tests\__init__.py -> django-crispy-forms-2.0\tests
copying tests\conftest.py -> django-crispy-forms-2.0\tests
copying tests\forms.py -> django-crispy-forms-2.0\tests
copying tests\test_dynamic_api.py -> django-crispy-forms-2.0\tests
copying tests\test_form_helper.py -> django-crispy-forms-2.0\tests
copying tests\test_layout.py -> django-crispy-forms-2.0\tests
copying tests\test_layout_objects.py -> django-crispy-forms-2.0\tests
copying tests\test_settings.py -> django-crispy-forms-2.0\tests
copying tests\test_tags.py -> django-crispy-forms-2.0\tests
copying tests\test_utils.py -> django-crispy-forms-2.0\tests
copying tests\urls.py -> django-crispy-forms-2.0\tests
copying tests\utils.py -> django-crispy-forms-2.0\tests
copying tests\results\test_formset_layout.html -> django-crispy-forms-2.0\tests\results
copying tests\results\test_modelformset_layout.html -> django-crispy-forms-2.0\tests\results
copying tests\results\test_render_hidden_fields.html -> django-crispy-forms-2.0\tests\results
copying tests\results\utils_test.html -> django-crispy-forms-2.0\tests\results
copying tests\results\bootstrap\test_layout_objects\test_field_with_buttons.html -> django-crispy-forms-2.0\tests\results\bootstrap\test_layout_objects
copying tests\templates\crispy_render_template.html -> django-crispy-forms-2.0\tests\templates
copying tests\templates\custom_field_template.html -> django-crispy-forms-2.0\tests\templates
copying tests\templates\custom_form_template.html -> django-crispy-forms-2.0\tests\templates
copying tests\templates\custom_form_template_with_context.html -> django-crispy-forms-2.0\tests\templates
Writing django-crispy-forms-2.0\setup.cfg
Creating tar archive
removing 'django-crispy-forms-2.0' (and everything under it)
* Building wheel from sdist
* Creating virtualenv isolated environment...
* Installing packages in isolated environment... (setuptools>=61.0)
* Getting build dependencies for wheel...
C:\Users\smith\AppData\Local\Temp\build-env-dbfsqwo5\Lib\site-packages\setuptools\config\setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_fil
es instead.
  warnings.warn(msg, warning_class)
C:\Users\smith\AppData\Local\Temp\build-env-dbfsqwo5\Lib\site-packages\setuptools\config\pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *
beta*.
  warnings.warn(msg, _BetaConfiguration)
No `packages` or `py_modules` configuration, performing automatic discovery.
`flat-layout` detected -- analysing .
discovered packages -- ['crispy_forms', 'crispy_forms.templatetags']
running egg_info
writing django_crispy_forms.egg-info\PKG-INFO
writing dependency_links to django_crispy_forms.egg-info\dependency_links.txt
writing requirements to django_crispy_forms.egg-info\requires.txt
writing top-level names to django_crispy_forms.egg-info\top_level.txt
reading manifest file 'django_crispy_forms.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'docs\_build'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
adding license file 'LICENSE.txt'
writing manifest file 'django_crispy_forms.egg-info\SOURCES.txt'
* Installing packages in isolated environment... (wheel)
* Building wheel...
C:\Users\smith\AppData\Local\Temp\build-env-dbfsqwo5\Lib\site-packages\setuptools\config\setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_fil
es instead.
  warnings.warn(msg, warning_class)
C:\Users\smith\AppData\Local\Temp\build-env-dbfsqwo5\Lib\site-packages\setuptools\config\pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *
beta*.
  warnings.warn(msg, _BetaConfiguration)
No `packages` or `py_modules` configuration, performing automatic discovery.
`flat-layout` detected -- analysing .
discovered packages -- ['crispy_forms', 'crispy_forms.templatetags']
running bdist_wheel
running build
running build_py
creating build
creating build\lib
creating build\lib\crispy_forms
copying crispy_forms\base.py -> build\lib\crispy_forms
copying crispy_forms\bootstrap.py -> build\lib\crispy_forms
copying crispy_forms\exceptions.py -> build\lib\crispy_forms
copying crispy_forms\helper.py -> build\lib\crispy_forms
copying crispy_forms\layout.py -> build\lib\crispy_forms
copying crispy_forms\layout_slice.py -> build\lib\crispy_forms
copying crispy_forms\utils.py -> build\lib\crispy_forms
copying crispy_forms\__init__.py -> build\lib\crispy_forms
creating build\lib\crispy_forms\templatetags
copying crispy_forms\templatetags\crispy_forms_field.py -> build\lib\crispy_forms\templatetags
copying crispy_forms\templatetags\crispy_forms_filters.py -> build\lib\crispy_forms\templatetags
copying crispy_forms\templatetags\crispy_forms_tags.py -> build\lib\crispy_forms\templatetags
copying crispy_forms\templatetags\crispy_forms_utils.py -> build\lib\crispy_forms\templatetags
copying crispy_forms\templatetags\__init__.py -> build\lib\crispy_forms\templatetags
running egg_info
writing django_crispy_forms.egg-info\PKG-INFO
writing dependency_links to django_crispy_forms.egg-info\dependency_links.txt
writing requirements to django_crispy_forms.egg-info\requires.txt
writing top-level names to django_crispy_forms.egg-info\top_level.txt
reading manifest file 'django_crispy_forms.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'docs\_build'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
adding license file 'LICENSE.txt'
writing manifest file 'django_crispy_forms.egg-info\SOURCES.txt'
copying crispy_forms\LICENSE -> build\lib\crispy_forms
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\crispy_forms
copying build\lib\crispy_forms\base.py -> build\bdist.win-amd64\wheel\.\crispy_forms
copying build\lib\crispy_forms\bootstrap.py -> build\bdist.win-amd64\wheel\.\crispy_forms
copying build\lib\crispy_forms\exceptions.py -> build\bdist.win-amd64\wheel\.\crispy_forms
copying build\lib\crispy_forms\helper.py -> build\bdist.win-amd64\wheel\.\crispy_forms
copying build\lib\crispy_forms\layout.py -> build\bdist.win-amd64\wheel\.\crispy_forms
copying build\lib\crispy_forms\layout_slice.py -> build\bdist.win-amd64\wheel\.\crispy_forms
copying build\lib\crispy_forms\LICENSE -> build\bdist.win-amd64\wheel\.\crispy_forms
creating build\bdist.win-amd64\wheel\crispy_forms\templatetags
copying build\lib\crispy_forms\templatetags\crispy_forms_field.py -> build\bdist.win-amd64\wheel\.\crispy_forms\templatetags
copying build\lib\crispy_forms\templatetags\crispy_forms_filters.py -> build\bdist.win-amd64\wheel\.\crispy_forms\templatetags
copying build\lib\crispy_forms\templatetags\crispy_forms_tags.py -> build\bdist.win-amd64\wheel\.\crispy_forms\templatetags
copying build\lib\crispy_forms\templatetags\crispy_forms_utils.py -> build\bdist.win-amd64\wheel\.\crispy_forms\templatetags
copying build\lib\crispy_forms\templatetags\__init__.py -> build\bdist.win-amd64\wheel\.\crispy_forms\templatetags
copying build\lib\crispy_forms\utils.py -> build\bdist.win-amd64\wheel\.\crispy_forms
copying build\lib\crispy_forms\__init__.py -> build\bdist.win-amd64\wheel\.\crispy_forms
running install_egg_info
Copying django_crispy_forms.egg-info to build\bdist.win-amd64\wheel\.\django_crispy_forms-2.0-py3.11.egg-info
running install_scripts
creating build\bdist.win-amd64\wheel\django_crispy_forms-2.0.dist-info\WHEEL
creating 'C:\Users\smith\projects\django-crispy-forms\dist\.tmp-kxgqrf59\django_crispy_forms-2.0-py3-none-any.whl' and adding 'build\bdist.win-amd64\wheel' to it
adding 'crispy_forms/LICENSE'
adding 'crispy_forms/__init__.py'
adding 'crispy_forms/base.py'
adding 'crispy_forms/bootstrap.py'
adding 'crispy_forms/exceptions.py'
adding 'crispy_forms/helper.py'
adding 'crispy_forms/layout.py'
adding 'crispy_forms/layout_slice.py'
adding 'crispy_forms/utils.py'
adding 'crispy_forms/templatetags/__init__.py'
adding 'crispy_forms/templatetags/crispy_forms_field.py'
adding 'crispy_forms/templatetags/crispy_forms_filters.py'
adding 'crispy_forms/templatetags/crispy_forms_tags.py'
adding 'crispy_forms/templatetags/crispy_forms_utils.py'
adding 'django_crispy_forms-2.0.dist-info/LICENSE.txt'
adding 'django_crispy_forms-2.0.dist-info/METADATA'
adding 'django_crispy_forms-2.0.dist-info/WHEEL'
adding 'django_crispy_forms-2.0.dist-info/top_level.txt'
adding 'django_crispy_forms-2.0.dist-info/RECORD'
removing build\bdist.win-amd64\wheel
Successfully built django-crispy-forms-2.0.tar.gz and django_crispy_forms-2.0-py3-none-any.whl

[1] https://packaging.python.org/en/latest/tutorials/packaging-projects/

@codecov-commenter
Copy link

codecov-commenter commented Jan 1, 2023

Codecov Report

Merging #1325 (8b057da) into main (d8f0d34) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1325   +/-   ##
=======================================
  Coverage   89.30%   89.30%           
=======================================
  Files          12       12           
  Lines        1010     1010           
  Branches      192      192           
=======================================
  Hits          902      902           
  Misses         78       78           
  Partials       30       30           
Flag Coverage Δ
unittests 89.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d8f0d34...8b057da. Read the comment docs.

url="https://github.com/django-crispy-forms/django-crispy-forms",
license="MIT",
packages=find_packages(exclude=["docs"]),
include_package_data=True,
Copy link
Member Author

Choose a reason for hiding this comment

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

include_package_data defaults to True when using pyproject.toml. Therefore no need to migrate this setting.

https://setuptools.pypa.io/en/latest/userguide/datafiles.html#include-package-data

license="MIT",
packages=find_packages(exclude=["docs"]),
include_package_data=True,
zip_safe=False,
Copy link
Member Author

Choose a reason for hiding this comment

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

zip_safe is obsolete, so no need to migrate this one.
https://setuptools.pypa.io/en/latest/deprecated/zip_safe.html

author_email="miguel.araujo.perez@gmail.com",
url="https://github.com/django-crispy-forms/django-crispy-forms",
license="MIT",
packages=find_packages(exclude=["docs"]),
Copy link
Member Author

Choose a reason for hiding this comment

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

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

We have a standard package setup (docs in a docs, folder, tests in a tests folder) and therefore can rely on automatic discovery. This works testing locally where the output of the discovery is:

No `packages` or `py_modules` configuration, performing automatic discovery.
`flat-layout` detected -- analysing .
discovered packages -- ['crispy_forms', 'crispy_forms.templatetags']

@smithdc1
Copy link
Member Author

smithdc1 commented Jan 1, 2023

Ha! broke the linter. One for another day.

Happy New Year All! 🥳

@smithdc1 smithdc1 merged commit fedf64a into main Jan 2, 2023
@smithdc1 smithdc1 deleted the setup branch January 2, 2023 15:48
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.

None yet

2 participants