pypa/flit

Unable to use project name containing hyphens

edmorley opened this issue · 5 comments

Summary

The flit docs say this about the project.name attribute in pyproject.toml:

name

The name your package will have on PyPI. This field is required. For Flit, this name, with any hyphens replaced by underscores, is also the default value of the import name (see Module section if that needs to be different).

However if I try to use a name that contains a hyphen, I get an error.

This means I cannot use a distribution name containing a hyphen, even though the upstream spec allows it.

Steps to reproduce

  1. mkdir testcase && cd $_
  2. mkdir my_package && touch my_package/__init__.py
  3. Create the pyproject.toml using:
    cat > pyproject.toml<< 'EOF'
    [build-system]
    requires = ["flit_core >=3.2,<4"]
    build-backend = "flit_core.buildapi"
    
    [project]
    name = "my-package"
    version = "0.0.0"
    description = ""
    EOF
    
  4. pip install -e .

Expected

Pip install succeeds.

Actual

(venv) testcase $ pip install -e .
Obtaining file:///Users/emorley/src/testcase
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error

  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      Traceback (most recent call last):
        File "/Users/emorley/src/testcase/venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/Users/emorley/src/testcase/venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/emorley/src/testcase/venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 144, in get_requires_for_build_editable
          return hook(config_settings)
        File "/private/var/folders/kp/1j9qfrqn79b867c9xzshx9kr0000gp/T/pip-build-env-ov8_3n9i/overlay/lib/python3.10/site-packages/flit_core/buildapi.py", line 31, in get_requires_for_build_wheel
          module = Module(info.module, Path.cwd())
        File "/private/var/folders/kp/1j9qfrqn79b867c9xzshx9kr0000gp/T/pip-build-env-ov8_3n9i/overlay/lib/python3.10/site-packages/flit_core/common.py", line 59, in __init__
          raise ValueError("No file/folder found for module {}".format(name))
      ValueError: No file/folder found for module my-package
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.

Notes

  • Using flit 3.7.1, pip 22.2.2, Python 3.10 (from homebrew), macOS
  • Flit seems to not be normalising the module name, contrary to what the docs say.

You're looking at /latest/ documentation, which reflects the state of main and not the current release of flit.

https://flit.pypa.io/en/stable/pyproject_toml.html#new-style-metadata is the page, with the documentation for the current release of flit.

Ah, I followed the link from the GitHub repo's description, which is https://flit.pypa.io/ and redirects to /latest/.

Perhaps the default for the redirect should be /stable/?

Also, checking https://pypi.org/project/flit/ I see the "documentation" link actually directly links to /latest/, so should probably be changed too :-)

I've changed that in the default -- it'll take a while to purge from the cache. :)

Wanna file a PR to drop the en/latest/ from

Documentation = "https://flit.readthedocs.io/en/latest/"
? :)

I've changed that in the default -- it'll take a while to purge from the cache. :)

Thank you!

Wanna file a PR to drop the en/latest/ from

Sure - opened #589 :-)