Git Product home page Git Product logo

Comments (27)

ofek avatar ofek commented on June 18, 2024 2

So to make this work:

  1. Hatchling needs a way to load plugins based on file system paths rather than just relying on entry points metadata (this will be tough but doable)
  2. This project would change to:
    [build-system]
    requires = ["hatchling"]
    build-backend = "hatchling.build"
    backend-path = ['src']

Does that sound right?

from hatch-fancy-pypi-readme.

ofek avatar ofek commented on June 18, 2024 2

To confirm, my plan is to load all project.entry-points.hatch if build-system.backend-path is defined.

from hatch-fancy-pypi-readme.

hynek avatar hynek commented on June 18, 2024 1

fixed by 2f17c36 💔

from hatch-fancy-pypi-readme.

hroncok avatar hroncok commented on June 18, 2024 1

See the discussion in pypa/wheel#429 for some details.

from hatch-fancy-pypi-readme.

ofek avatar ofek commented on June 18, 2024

Works for me:

❯ python -m build -w
* Creating virtualenv isolated environment...
* Installing packages in isolated environment... (hatch-fancy-pypi-readme>=22.4.0, hatchling)
* Getting dependencies for wheel...
* Building wheel...
Successfully built hatch_fancy_pypi_readme-22.6.0.dev0-py3-none-any.whl

from hatch-fancy-pypi-readme.

kloczek avatar kloczek commented on June 18, 2024

So you have installed in build env hatch-fancy-pypi-readme>=22.4.0.
I cannot build 22.0.4 either ..

But again: code of requires version is in build tree and many other modules is possible to build self bootstrapping (whey, build)

from hatch-fancy-pypi-readme.

ofek avatar ofek commented on June 18, 2024

This isn't a build backend it's a plugin

from hatch-fancy-pypi-readme.

kloczek avatar kloczek commented on June 18, 2024

hatch-fancy-pypi-readme is required in exact minimum version so it cannot be used over PYTHONPATH=$PWD/src python -m build -w --no-isolation because in src/ there is no module metadata.
Other thing is that evebn after build it will be no metadata in src/ because hatchling as same as whey and poetry is not producing metadata in any other place than generated .whl archive.

It works for you because you executed build without --no-isolation which is causing that missing hatch-fancy-pypi-readme*.whl is downloaded duting build execution from pypi repo.
Try use that with --no-isolation to relay only what you have installed in build env and before that please uninstall hatch-fancy-pypi-readme module.

from hatch-fancy-pypi-readme.

hynek avatar hynek commented on June 18, 2024

@ofek is there a way around this or is every distro gonna complain about this now? :-/

from hatch-fancy-pypi-readme.

kloczek avatar kloczek commented on June 18, 2024

No as long as you are requiring in pyprojest.toml module build needs metadata of tjose mofdules somewhere in build env. Just checked my +1k spec files with python moduls. Try to have look on buildd, calver, dbusmockandflit` code. In those cases I've managed to prepare build procedure which would not require installed in build env those moduels by use

%build
export PYTHONPATH=$PWD/src
%pyproject_wheel

or

%build
export PYTHONPATH=$PWD
%pyproject_wheel

to break self dependencies.

from hatch-fancy-pypi-readme.

ofek avatar ofek commented on June 18, 2024

cc other Linux distro experts @musicinmybrain @frenzymadness @stefanor @hroncok

Is there really no way for a package to depend on itself? I wanted Hatchling to start using hatch-vcs so I can version using Git. Is that impossible?

from hatch-fancy-pypi-readme.

hroncok avatar hroncok commented on June 18, 2024

It should be possible to:

  1. not list the self-dependency
  2. use the https://peps.python.org/pep-0517/#in-tree-build-backends feature

from hatch-fancy-pypi-readme.

Czaki avatar Czaki commented on June 18, 2024

Is there really no way for a package to depend on itself

it may be possible, but such a package cannot depend on itself in build-system.requires section so in the case of hatch there should be introduced to detect plugins stored locally in the filesystem, not only installed packages.

from hatch-fancy-pypi-readme.

hroncok avatar hroncok commented on June 18, 2024

or if there is a a Python way to "register" a hatch plugin, the build backend could be set to a local script that imports the plugin, registers it and "returns" the hatch backend

from hatch-fancy-pypi-readme.

Czaki avatar Czaki commented on June 18, 2024

It looks like a place to touch: https://github.com/pypa/hatch/blob/master/backend/src/hatchling/plugin/manager.py#L97

from hatch-fancy-pypi-readme.

hroncok avatar hroncok commented on June 18, 2024

Pseudo-code:

[build-system]
requires = ["hatch"]
build-backend = "intree_plugin_loader:build"
backend-path = ["tools", "src"]
# tools/intree_plugin_loader.py

from hatchling import build as build_original
from hatch import register_plugin_xxx
__all__ = ['build']

def build(*args, **kwargs):
    register_plugin_xxx(...)
    return build_original(*args, **kwargs)

from hatch-fancy-pypi-readme.

ofek avatar ofek commented on June 18, 2024

Ah okay I think I understand for Hatchling, ty! Though I don't understand why this package can't depend on an older version of itself for builds. The code is under src/ so imports would correctly use the old version, no?

from hatch-fancy-pypi-readme.

hroncok avatar hroncok commented on June 18, 2024

It can technically depend on itself only when it is already packaged as a wheel. It makes it impossible to bootstrap from the source. That it a distro maintainers' problem to solve but OTOH it's always nice to try to avoid it. I think some of the relevant PEPs discourages this but I am not entirely sure.

from hatch-fancy-pypi-readme.

ofek avatar ofek commented on June 18, 2024

Ohhhh right distros build from source all the way down. I get it now, bummer. Thank you!

from hatch-fancy-pypi-readme.

hroncok avatar hroncok commented on June 18, 2024

PEP 517 even forbids this, see https://www.python.org/dev/peps/pep-0517/#build-requirements

Project build requirements will define a directed graph of requirements (project A needs B to build, B needs C and D, etc.) This graph MUST NOT contain cycles. If (due to lack of co-ordination between projects, for example) a cycle is present, front ends MAY refuse to build the project.

However front ends MAY have modes where they do not consider wheels when locating build requirements, and so projects MUST NOT assume that publishing wheels is sufficient to break a requirement cycle.

from hatch-fancy-pypi-readme.

ofek avatar ofek commented on June 18, 2024

I do wonder if by cycle it implicitly means package only or the traditional package + version.

from hatch-fancy-pypi-readme.

Czaki avatar Czaki commented on June 18, 2024

PEP 517 even forbids this, see

It does not. It prohibits making cycles, not depending on local code.

from hatch-fancy-pypi-readme.

hroncok avatar hroncok commented on June 18, 2024

Yes. "depending on self" is a cycle. I was answering to

I don't understand why this package can't depend on an older version of itself

from hatch-fancy-pypi-readme.

Czaki avatar Czaki commented on June 18, 2024

Agree. On the older version is a cycle. It will be nice to have some citations or paraphrases for context.

from hatch-fancy-pypi-readme.

hroncok avatar hroncok commented on June 18, 2024

That is a way to do it. Maybe hatch could have a configuration section that would made the plugin lookup from sys.path more explicit.

from hatch-fancy-pypi-readme.

hroncok avatar hroncok commented on June 18, 2024

I got an idea: Since the configuration already has:

[project.entry-points.hatch]
fancy-pypi-readme = "hatch_fancy_pypi_readme.hooks"

Hatch could also load the plugin entrypoints from the pyproject.toml it is reading. That should be easier than "a way to load plugins based on file system paths"

from hatch-fancy-pypi-readme.

ofek avatar ofek commented on June 18, 2024

Clever! I will do that 🚀

from hatch-fancy-pypi-readme.

Related Issues (7)

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.