robbievanleeuwen / section-properties

Analysis of an arbitrary cross-section in python using the finite element method.
https://sectionproperties.rtfd.io
MIT License
427 stars 94 forks source link

Invalid pyproject.toml #208

Closed Czarified closed 2 years ago

Czarified commented 2 years ago

Describe the bug Pip errors out when attempting to install a local branch. Pyproject.toml has invalid fields.

To Reproduce Steps to reproduce the behaviour:

  1. Create a new virtual environment, and pip install --upgrade pip
  2. Clone a branch of the repo locally
  3. Navigate to this branch in your terminal
  4. `pip install -e .'

Expected behaviour Should install the local repo in "editable" mode, using the pyproject.toml and setup.cfg to gather and install dependencies.

Screenshots image

Desktop (please complete the following information):

Additional Traceback Information

LONG traceback... ``` (section-properties) C:\Users\bcrews\Documents\GitHub\section-properties>pip list Package Version ---------- ------- pip 22.0.4 setuptools 47.1.0 (section-properties) C:\Users\bcrews\Documents\GitHub\section-properties>pip install -e . Obtaining file:///C:/Users/bcrews/Documents/GitHub/section-properties Installing build dependencies ... done Checking if build backend supports build_editable ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [515 lines of output] C:\Users\bcrews\AppData\Local\Temp\pip-build-env-_44d8lae\overlay\Lib\site-packages\setuptools\config\pyprojecttoml.py:100: _ExperimentalProjectMetadata: Support for project metadata in `pyproject.toml` is still experimental and may be removed (or change) in future releases. warnings.warn(msg, _ExperimentalProjectMetadata) configuration error: `project` must contain ['name'] properties DESCRIPTION: Data structure for the **project** table inside ``pyproject.toml`` (as initially defined in :pep:`621`) GIVEN VALUE: { "requires-python": ">=3.7,<3.10" } OFFENDING RULE: 'required' DEFINITION: { "$schema": "http://json-schema.org/draft-07/schema", "$id": "https://packaging.python.org/en/latest/specifications/declaring-project-metadata/", "title": "Package metadata stored in the ``project`` table", "type": "object", "properties": { "name": { "type": "string", "description": "The name (primary identifier) of the project. MUST be statically defined.", "format": "pep508-identifier" }, "version": { "type": "string", "description": "The version of the project as supported by :pep:`440`.", "format": "pep440" }, "description": { "type": "string", "$$description": [ "The `summary description of the project", "`_" ] }, "readme": { "$$description": [ "`Full/detailed description of the project in the form of a README", "`_", "with meaning similar to the one defined in `core metadata's Description", "`_" ], "oneOf": [ { "type": "string", "$$description": [ "Relative path to a text file (UTF-8) containing the full description", "of the project. If the file path ends in case-insensitive ``.md`` or", "``.rst`` suffixes, then the content-type is respectively", "``text/markdown`` or ``text/x-rst``" ] }, { "type": "object", "allOf": [ { "anyOf": [ { "properties": { "file": { "type": "string", "$$description": [ "Relative path to a text file containing the full description", "of the project." ] } }, "required": [ "file" ] }, { "properties": { "text": { "type": "string", "description": "Full text describing the project." } }, "required": [ "text" ] } ] }, { "properties": { "content-type": { "type": "string", "$$description": [ "Content-type (:rfc:`1341`) of the full description", "(e.g. ``text/markdown``). The ``charset`` parameter is assumed", "UTF-8 when not present." ], "$comment": "TODO: add regex pattern or format?" } }, "required": [ "content-type" ] } ] } ] }, "requires-python": { "type": "string", "format": "pep508-versionspec", "$$description": [ "`The Python version requirements of the project", "`_." ] }, "license": { "description": "`Project license `_.", "oneOf": [ { "properties": { "file": { "type": "string", "$$description": [ "Relative path to the file (UTF-8) which contains the license for the", "project." ] } }, "required": [ "file" ] }, { "properties": { "text": { "type": "string", "$$description": [ "The license of the project whose meaning is that of the", "`License field from the core metadata", "`_." ] } }, "required": [ "text" ] } ] }, "authors": { "type": "array", "items": { "$id": "#/definitions/author", "title": "Author or Maintainer", "$comment": "https://www.python.org/dev/peps/pep-0621/#authors-maintainers", "type": "object", "properties": { "name": { "type": "string", "$$description": [ "MUST be a valid email name, i.e. whatever can be put as a name, before an", "email, in :rfc:`822`." ] }, "email": { "type": "string", "format": "idn-email", "description": "MUST be a valid email address" } } }, "$$description": [ "The people or organizations considered to be the 'authors' of the project.", "The exact meaning is open to interpretation (e.g. original or primary authors,", "current maintainers, or owners of the package)." ] }, "maintainers": { "type": "array", "items": { "$id": "#/definitions/author", "title": "Author or Maintainer", "$comment": "https://www.python.org/dev/peps/pep-0621/#authors-maintainers", "type": "object", "properties": { "name": { "type": "string", "$$description": [ "MUST be a valid email name, i.e. whatever can be put as a name, before an", "email, in :rfc:`822`." ] }, "email": { "type": "string", "format": "idn-email", "description": "MUST be a valid email address" } } }, "$$description": [ "The people or organizations considered to be the 'maintainers' of the project.", "Similarly to ``authors``, the exact meaning is open to interpretation." ] }, "keywords": { "type": "array", "items": { "type": "string" }, "description": "List of keywords to assist searching for the distribution in a larger catalog." }, "classifiers": { "type": "array", "items": { "type": "string", "format": "trove-classifier", "description": "`PyPI classifier `_." }, "$$description": [ "`Trove classifiers `_", "which apply to the project." ] }, "urls": { "type": "object", "description": "URLs associated with the project in the form ``label => value``.", "additionalProperties": false, "patternProperties": { "^.+$": { "type": "string", "format": "url" } } }, "scripts": { "$id": "#/definitions/entry-point-group", "title": "Entry-points", "type": "object", "$$description": [ "Entry-points are grouped together to indicate what sort of capabilities they", "provide.", "See the `packaging guides", "`_", "and `setuptools docs", "`_", "for more information." ], "propertyNames": { "format": "python-entrypoint-name" }, "additionalProperties": false, "patternProperties": { "^.+$": { "type": "string", "$$description": [ "Reference to a Python object. It is either in the form", "``importable.module``, or ``importable.module:object.attr``." ], "format": "python-entrypoint-reference", "$comment": "https://packaging.python.org/specifications/entry-points/" } } }, "gui-scripts": { "$id": "#/definitions/entry-point-group", "title": "Entry-points", "type": "object", "$$description": [ "Entry-points are grouped together to indicate what sort of capabilities they", "provide.", "See the `packaging guides", "`_", "and `setuptools docs", "`_", "for more information." ], "propertyNames": { "format": "python-entrypoint-name" }, "additionalProperties": false, "patternProperties": { "^.+$": { "type": "string", "$$description": [ "Reference to a Python object. It is either in the form", "``importable.module``, or ``importable.module:object.attr``." ], "format": "python-entrypoint-reference", "$comment": "https://packaging.python.org/specifications/entry-points/" } } }, "entry-points": { "$$description": [ "Instruct the installer to expose the given modules/functions via", "``entry-point`` discovery mechanism (useful for plugins).", "More information available in the `Python packaging guide", "`_." ], "propertyNames": { "format": "python-entrypoint-group" }, "additionalProperties": false, "patternProperties": { "^.+$": { "$id": "#/definitions/entry-point-group", "title": "Entry-points", "type": "object", "$$description": [ "Entry-points are grouped together to indicate what sort of capabilities they", "provide.", "See the `packaging guides", "`_", "and `setuptools docs", "`_", "for more information." ], "propertyNames": { "format": "python-entrypoint-name" }, "additionalProperties": false, "patternProperties": { "^.+$": { "type": "string", "$$description": [ "Reference to a Python object. It is either in the form", "``importable.module``, or ``importable.module:object.attr``." ], "format": "python-entrypoint-reference", "$comment": "https://packaging.python.org/specifications/entry-points/" } } } } }, "dependencies": { "type": "array", "description": "Project (mandatory) dependencies.", "items": { "$id": "#/definitions/dependency", "title": "Dependency", "type": "string", "description": "Project dependency specification according to PEP 508", "format": "pep508" } }, "optional-dependencies": { "type": "object", "description": "Optional dependency for the project", "propertyNames": { "format": "pep508-identifier" }, "additionalProperties": false, "patternProperties": { "^.+$": { "type": "array", "items": { "$id": "#/definitions/dependency", "title": "Dependency", "type": "string", "description": "Project dependency specification according to PEP 508", "format": "pep508" } } } }, "dynamic": { "type": "array", "$$description": [ "Specifies which fields are intentionally unspecified and expected to be", "dynamically provided by build tools" ], "items": { "enum": [ "version", "description", "readme", "requires-python", "license", "authors", "maintainers", "keywords", "classifiers", "urls", "scripts", "gui-scripts", "entry-points", "dependencies", "optional-dependencies" ] } } }, "required": [ "name" ], "additionalProperties": false, "if": { "not": { "required": [ "version" ], "$$description": [ "version is statically defined in the ``version`` field" ] }, "$$comment": [ "According to :pep:`621`:", " If the core metadata specification lists a field as \"Required\", then", " the metadata MUST specify the field statically or list it in dynamic", "In turn, `core metadata`_ defines:", " The required fields are: Metadata-Version, Name, Version.", " All the other fields are optional.", "Since ``Metadata-Version`` is defined by the build back-end, ``name`` and", "``version`` are the only mandatory information in ``pyproject.toml``.", ".. _core metadata: https://packaging.python.org/specifications/core-metadata/" ] }, "then": { "properties": { "dynamic": { "contains": { "const": "version" }, "$$description": [ "version should be listed in ``dynamic``" ] } } }, "definitions": { "author": { "$id": "#/definitions/author", "title": "Author or Maintainer", "$comment": "https://www.python.org/dev/peps/pep-0621/#authors-maintainers", "type": "object", "properties": { "name": { "type": "string", "$$description": [ "MUST be a valid email name, i.e. whatever can be put as a name, before an", "email, in :rfc:`822`." ] }, "email": { "type": "string", "format": "idn-email", "description": "MUST be a valid email address" } } }, "entry-point-group": { "$id": "#/definitions/entry-point-group", "title": "Entry-points", "type": "object", "$$description": [ "Entry-points are grouped together to indicate what sort of capabilities they", "provide.", "See the `packaging guides", "`_", "and `setuptools docs", "`_", "for more information." ], "propertyNames": { "format": "python-entrypoint-name" }, "additionalProperties": false, "patternProperties": { "^.+$": { "type": "string", "$$description": [ "Reference to a Python object. It is either in the form", "``importable.module``, or ``importable.module:object.attr``." ], "format": "python-entrypoint-reference", "$comment": "https://packaging.python.org/specifications/entry-points/" } } }, "dependency": { "$id": "#/definitions/dependency", "title": "Dependency", "type": "string", "description": "Project dependency specification according to PEP 508", "format": "pep508" } } } Traceback (most recent call last): File "c:\users\bcrews\.venv\section-properties\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in main() File "c:\users\bcrews\.venv\section-properties\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 345, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "c:\users\bcrews\.venv\section-properties\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 164, in prepare_metadata_for_build_wheel return hook(metadata_directory, config_settings) File "C:\Users\bcrews\AppData\Local\Temp\pip-build-env-_44d8lae\overlay\Lib\site-packages\setuptools\build_meta.py", line 188, in prepare_metadata_for_build_wheel self.run_setup() File "C:\Users\bcrews\AppData\Local\Temp\pip-build-env-_44d8lae\overlay\Lib\site-packages\setuptools\build_meta.py", line 174, in run_setup exec(compile(code, __file__, 'exec'), locals()) File "setup.py", line 4, in setuptools.setup() File "C:\Users\bcrews\AppData\Local\Temp\pip-build-env-_44d8lae\overlay\Lib\site-packages\setuptools\__init__.py", line 77, in setup return distutils.core.setup(**attrs) File "C:\Users\bcrews\AppData\Local\Temp\pip-build-env-_44d8lae\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 122, in setup dist.parse_config_files() File "C:\Users\bcrews\AppData\Local\Temp\pip-build-env-_44d8lae\overlay\Lib\site-packages\setuptools\dist.py", line 836, in parse_config_files pyprojecttoml.apply_configuration(self, filename, ignore_option_errors) File "C:\Users\bcrews\AppData\Local\Temp\pip-build-env-_44d8lae\overlay\Lib\site-packages\setuptools\config\pyprojecttoml.py", line 52, in apply_configuration config = read_configuration(filepath, True, ignore_option_errors, dist) File "C:\Users\bcrews\AppData\Local\Temp\pip-build-env-_44d8lae\overlay\Lib\site-packages\setuptools\config\pyprojecttoml.py", line 114, in read_configuration validate(subset, filepath) File "C:\Users\bcrews\AppData\Local\Temp\pip-build-env-_44d8lae\overlay\Lib\site-packages\setuptools\config\pyprojecttoml.py", line 43, in validate raise error from None ValueError: invalid pyproject.toml config: `project` [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. ```
robbievanleeuwen commented 2 years ago

Hi @Czarified, thanks for this!

I based the structure for the project from this.

It seems like now pip is looking for the name metadata in pyproject.toml, is this your take on this? This sees goes against what is stated in the above link?

Does PEP 621 remove setup.cfg and put everything in pyproject.toml?

I'm not enough of a python guru to quite understand what's going on here 😆

Czarified commented 2 years ago

I got a bit distracted on Friday, but I was going to dig into this more. I'll do some reading and see if I can fix it. Thanks for the links!

On Sat, Mar 26, 2022, 12:14 AM Robbie van Leeuwen @.***> wrote:

Hi @Czarified https://github.com/Czarified, thanks for this!

I based the structure for the project from this https://packaging.python.org/en/latest/tutorials/packaging-projects/.

It seems like now pip is looking for the name metadata in pyproject.toml, is this your take on this? This sees goes against what is stated in the above link?

Does PEP 621 https://peps.python.org/pep-0621/ remove setup.cfg and put everything in pyproject.toml?

I'm not enough of a python guru to quite understand what's going on here 😆

— Reply to this email directly, view it on GitHub https://github.com/robbievanleeuwen/section-properties/issues/208#issuecomment-1079607778, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVBQOVPB227MV3CIFTYRJLVB2MJTANCNFSM5RUNNQBQ . You are receiving this because you were mentioned.Message ID: @.***>

Czarified commented 2 years ago

So I think there's a couple things here. PEP621 does seem to allow metadata definitions in the pyproject.toml, however we area already using a setup.cfg for static metadata. I don't see a need to refactor for that.

Part of using a setup.cfg for static metadata means that we don't need a setup.py file anymore.

And finally, the pyproject.toml doesn't need the information outside of the [build-system] table. My theory is that including more categories (which overlap with the setup.cfg), confuses pip when it tries to install the directory. I'm kinda surprised that build worked...

I'll submit a PR later today. I'd love to get confirmation from @connorferster and/or @Spectre5. I know Spectre wants to move to a Poetry-based build, and maybe we'll get there! For starters, we at least should clean up what we have. Defining the "boring" static metadata in the pyproject.toml (according to PEP621) would more easily allow switching of build systems in the future.