Giter Club home page Giter Club logo

Comments (12)

ofek avatar ofek commented on June 14, 2024

Please show your config and exact directory structure.

from hatch.

AiroPi avatar AiroPi commented on June 14, 2024

Please show your config and exact directory structure.

https://github.com/airopi/minesweeper

I tested with exactly the same pyproject.toml and the same directory structure except with:

minesweeper.py
py.typed

Instead of:

minesweeper/
├── __init__.py
├── minesweeper.py
└── py.typed

Which gave me the stub files missing error.

And tested with

minesweeper/
├── minesweeper.py
└── py.typed

Which wasn't working at all. (Don't correspond to any of https://hatch.pypa.io/1.9/plugins/builder/wheel/#default-file-selection)
I tried to manually specify the minesweeper.minesweeper file but I couldn't do it.

from hatch.

ofek avatar ofek commented on June 14, 2024

The config file is not formatted properly so I cannot test. Can you please fix that? In any case, you could probably achieve what you want with the following: https://hatch.pypa.io/latest/config/build/#rewriting-paths

from hatch.

AiroPi avatar AiroPi commented on June 14, 2024

The config file is not formatted properly so I cannot test. Can you please fix that? In any case, you could probably achieve what you want with the following: https://hatch.pypa.io/latest/config/build/#rewriting-paths

Thanks, I will check that!
On my side, I don't have any issue with the config file, so I don't really know what to fix 😬

from hatch.

ofek avatar ofek commented on June 14, 2024

Interesting! When viewed on GitHub the formatting was all broken and there was messed up syntax highlighting because of that but now it's fixed somehow...

from hatch.

AiroPi avatar AiroPi commented on June 14, 2024

Ok with these configs, I am able to resolve the missing stubs files problem while have a singlefile package at root:

[tool.hatch.build.targets.wheel]
include = ["py.typed", "minesweeper.py"]

[tool.hatch.build.targets.wheel.sources]
"" = "minesweeper"

However, this implies to use minesweeper.minesweeper.xxx instead of minesweeper.xxx because the module is not directly in site-packages, which is the case if we don't care about py.typed.

This looks like a PEP561 limitation, but the typing_extensions package is directly inside site-packages without stub files issue. But maybe it is a special exception for this package, due to its utility.

image

By the way, the warning is raised by Pylance inside VSCode (when minesweeper.py is directly under site-packages like typing_extensions.py)
image

from hatch.

ofek avatar ofek commented on June 14, 2024

What you could do is have two remappings to the direct location and for the code make that be minesweeper/__init__.py.

from hatch.

eli-schwartz avatar eli-schwartz commented on June 14, 2024

typing_extensions doesn't declare a py.typed as far as I can tell? What is the reason for thinking the desired goal can be achieved?

from hatch.

AiroPi avatar AiroPi commented on June 14, 2024

Ok I just founded this : python/typing#1297, my assumption was correct.
How can I map minesweeper.py to minesweeper/__init__.py (if this is possible)? I only see how to map directories, not files.

Otherwise, I will just keep the current structure 🤷 which works fine, but adds a useless folder.

from hatch.

ofek avatar ofek commented on June 14, 2024

https://hatch.pypa.io/latest/config/build/#forced-inclusion

[tool.hatch.build.targets.wheel.force-include]
"minesweeper.py" = "minesweeper/__init__.py"
"py.typed" = "minesweeper/py.typed"

from hatch.

AiroPi avatar AiroPi commented on June 14, 2024

Thank you! For the help and for the quick response.
This was exactly what I was looking for, it works like a charm.

from hatch.

ofek avatar ofek commented on June 14, 2024

Happy to help!

from hatch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.