Skip to content

Conversation

@TomDonoghue
Copy link
Member

@TomDonoghue TomDonoghue commented Jul 8, 2023

Continuing the updates for things that are changing in the Python ecosystem - this updates away from calling setup.py directly in the build process, as this is now suggested against.

New versions of setuptools print this out when running our current build command (python setup.py sdist bdist_wheel):
Screen Shot 2023-07-08 at 10 26 46 AM

Link: https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html
I didn't do the deep dive - but there is a useful table that indicates the new approach, using
https://github.com/pypa/build

Related to which, this PR:

  • updates the Makefile to use build to create the distribution
  • adds the requirements.txt to the MANIFEST.in
    • it should probably have been in there (build needs it, as it builds the distribution in a venv)

Comparing the output distribution files, as far as I can tell they are the same from build as calling setup.py.

Notably, as far as I understand, since we are using setup.py (and not pyproject.toml), I think build in this case uses setuptools and the setup.py file in the same way, so nothing really changes under the hood. This PR therefore just moves into the current best practice, and perhaps makes us a bit more ready if we do decide to update to pyproject.toml at some point (which I think is becoming the new standard).

In terms of review - @ryanhammonds, when you get a chance could you double check that you can run the new build command and that it seems to work on your system?

@fooof-tools fooof-tools deleted a comment from codecov-commenter Jul 8, 2023
Copy link
Contributor

@ryanhammonds ryanhammonds left a comment

Choose a reason for hiding this comment

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

I'm having issues with python -m build. I had to first pip install build, but then got an error:

Traceback (most recent call last):
File "/Users/ryanhammonds/projects/fooof/.env/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in
main()
File "/Users/ryanhammonds/projects/fooof/.env/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ryanhammonds/projects/fooof/.env/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/fm/pn7dn_wn7mz0nw0h4v1_5p840000gn/T/build-env-olz3x4aj/lib/python3.11/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/fm/pn7dn_wn7mz0nw0h4v1_5p840000gn/T/build-env-olz3x4aj/lib/python3.11/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
self.run_setup()
File "/private/var/folders/fm/pn7dn_wn7mz0nw0h4v1_5p840000gn/T/build-env-olz3x4aj/lib/python3.11/site-packages/setuptools/build_meta.py", line 488, in run_setup
self).run_setup(setup_script=setup_script)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/fm/pn7dn_wn7mz0nw0h4v1_5p840000gn/T/build-env-olz3x4aj/lib/python3.11/site-packages/setuptools/build_meta.py", line 338, in run_setup
exec(code, locals())
File "", line 15, in
FileNotFoundError: [Errno 2] No such file or directory: 'requirements.txt'

ERROR Backend subprocess exited when trying to invoke get_requires_for_build_wheel

I'm trying to figure out what went wrong since requirements.txt should be in the path I'm running from.

@TomDonoghue
Copy link
Member Author

TomDonoghue commented Jul 17, 2023

@ryanhammonds - I originally had this error too! I think it's because the build approach makes it's own sandbox venv to build in, abstracting away from the current environment, which is why requirements.txt needs to be added to the MANIFEST.

Are you trying to run python -m build from the current branch? If so, the update to MANIFEST should be included and I'm not sure why it would still not work....

Also, yeh, build is an external dependency that is required for building (replacing / superceding 'setuptools'). I indirectly mentioned this in the Makefile, but we might also want to add some more explicit "developer requirements" for anyone who might want to test / manage things like installs so there's clear guidance.

@ryanhammonds
Copy link
Contributor

Thanks! That was it. I was accidentally running the build from system python and not env. Once I ran from an env with this branch everything worked.

@TomDonoghue TomDonoghue merged commit f8ed771 into main Jul 18, 2023
@TomDonoghue TomDonoghue deleted the install branch July 18, 2023 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.1 Targetted for a fooof 1.1 release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants