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

Modernize Python metadata (pyproject.toml) #1013

Closed
wants to merge 4 commits into from

Conversation

mkoeppe
Copy link
Contributor

@mkoeppe mkoeppe commented Feb 21, 2024

No description provided.

rocky
rocky previously approved these changes Feb 22, 2024
@rocky
Copy link
Member

rocky commented Feb 22, 2024

@mkoeppe I have noticed that since switching over to toml projects the pre-commit hooks are broken due to some weird interaction between poetry when installing isort.

To see this run pip install pre-commit; pre-commit init and then make a change to a Python file and run:

$ git commit .
[INFO] Installing environment for https://github.com/pycqa/isort.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/home/rocky/.cache/pre-commit/repolu2119iv/py_env-python3/bin/python', '-mpip', 'install', '.')
return code: 1
stdout:
    Processing /home/rocky/.cache/pre-commit/repolu2119iv
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'done'
      Preparing metadata (pyproject.toml): started
      Preparing metadata (pyproject.toml): finished with status 'error'
stderr:
      error: subprocess-exited-with-error
      
      × Preparing metadata (pyproject.toml) did not run successfully.
      │ exit code: 1
      ╰─> [17 lines of output]
          Traceback (most recent call last):
            File "/home/rocky/.cache/pre-commit/repolu2119iv/py_env-python3/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
              main()
            File "/home/rocky/.cache/pre-commit/repolu2119iv/py_env-python3/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
              json_out['return_val'] = hook(**hook_input['kwargs'])
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/home/rocky/.cache/pre-commit/repolu2119iv/py_env-python3/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
              return hook(metadata_directory, config_settings)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/tmp/pip-build-env-4772twpp/overlay/lib/python3.12/site-packages/poetry/core/masonry/api.py", line 42, in prepare_metadata_for_build_wheel
              poetry = Factory().create_poetry(Path(".").resolve(), with_groups=False)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/tmp/pip-build-env-4772twpp/overlay/lib/python3.12/site-packages/poetry/core/factory.py", line 60, in create_poetry
              raise RuntimeError("The Poetry configuration is invalid:\n" + message)
          RuntimeError: The Poetry configuration is invalid:
            - data.extras.pipfile_deprecated_finder[2] must match pattern ^[a-zA-Z-_.0-9]+$
          
          [end of output]
      
      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: metadata-generation-failed
    
    × Encountered error while generating package metadata.
    ╰─> See above for output.
    
    note: This is an issue with the package mentioned above, not pip.
    hint: See above for details.
Check the log at /home/rocky/.cache/pre-commit/pre-commit.log

I think something needs to be added to the toml file with regards to isort or poetry configuration.

Have you been able to get pre-commit hooks working? If so what versions of Python, isort, and poetry are you using?

@rocky rocky self-requested a review February 22, 2024 11:44
@rocky rocky dismissed their stale review February 22, 2024 11:45

pre-commit hooks are broken with this

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 24, 2024

I'll check

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 24, 2024

I also get with upstream master @ 8436347:

$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
$ pre-commit run 
An error has occurred: InvalidManifestError: 
==> File /Users/mkoeppe/.cache/pre-commit/reponjodrsgv/.pre-commit-hooks.yaml
==> At Hook(id='black')
==> At key: stages
==> At index 0
=====> Expected one of commit, commit-msg, manual, merge-commit, post-checkout, post-commit, post-merge, post-rewrite, prepare-commit-msg, push but got: 'pre-commit'
Check the log at /Users/mkoeppe/.cache/pre-commit/pre-commit.log

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 24, 2024

Sorry for the noise; this went away as I switched to a non-ancient python.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 24, 2024

I've installed the pre-commit now, and it works without problems

mathics-core ➤ git commit -m "setup.py: Use logging instead of print" -a                                                                                           git:pyproject_toml
check for merge conflicts................................................Passed
debug statements (python)................................................Passed
fix end of files.........................................................Passed
isort....................................................................Failed
- hook id: isort
- files were modified by this hook

Fixing /Users/mkoeppe/s/sage/mathics-core/setup.py

black....................................................................Passed
mathics-core ➤ git commit -m "setup.py: Use logging instead of print" -a                                                                                          git:pyproject_toml*
check for merge conflicts................................................Passed
debug statements (python)................................................Passed
fix end of files.........................................................Passed
isort....................................................................Passed
black....................................................................Passed
[pyproject_toml 28f465d0] setup.py: Use logging instead of print
 1 file changed, 5 insertions(+), 1 deletion(-)

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 25, 2024

I think this may have been auto-closed by mistake

@rocky
Copy link
Member

rocky commented Feb 25, 2024

@mkoeppe if I did this, I am sorry.

@rocky rocky reopened this Feb 25, 2024
@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 25, 2024

No worries! It happened automatically when Mathics3/mathics-scanner#61 was merged because GitHub parsed my comment in Mathics3/mathics-scanner#61 (comment) as a closing reference.

rocky added a commit that referenced this pull request Mar 2, 2024
In some versions, black seems to want optional "," at the end of the
last parameter.

In support of getting #1013 to build cleanly
rocky added a commit that referenced this pull request Mar 12, 2024
Local fork of #1013 - Adds redoes packaging in the form that 3.12 is
going to need since setuptools is deprecated.

In the process, something happened with the way that Cython gets run and
we were then getting lots of Cython type annotation mismatch failures.
So these have been corrected.

We could split this into just the Cython corrections and then apply the
packaging toml changes in #1013.

Your thoughts? @mmatera  and @mkoeppe

---------

Co-authored-by: Matthias Koeppe <[email protected]>
@rocky
Copy link
Member

rocky commented Mar 12, 2024

Changes have been included into #1014

@rocky rocky closed this Mar 12, 2024
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.

2 participants