Update pyproject.toml with a [project] stanza #11197

Closed
opened 2025-12-29 21:41:49 +01:00 by adam · 7 comments
Owner

Originally created by @hblandford on GitHub (May 19, 2025).

Originally assigned to: @pheus on GitHub.

NetBox version

v4.3.1

Feature type

Other

Proposed functionality

Include a project stanza in the pyproject.toml file to assist users who would like to run uv.

This would not have to be comprehensive, but it could be useful to include some information.
I have not added the dependencies section to file as that is easily sorted from the requirements.txt but that could be included as well.

I have inserted it after the comment and before the [tool.black] stanza:

[project]
name = "netbox"
version = "4.3.1"
description = """\
NetBox exists to empower network engineers. Since its release in 2016, it has become the go-to solution for modeling\
 and documenting network infrastructure for thousands of organizations worldwide. As a successor to legacy IPAM and\
 DCIM applications, NetBox provides a cohesive, extensive, and accessible data model for all things networked.\
 By providing a single robust user interface and programmable APIs for everything from cable maps to device\
 configurations, NetBox serves as the central source of truth for the modern network.
"""
readme = "README.md"
license = { file = "LICENSE.txt" }
authors = [{ name = "NetBox Community" }]
requires-python = ">=3.10"
classifiers = [
    "License :: OSI Approved :: Apache Software License",
    "Programming Language :: Python :: 3",
    "Framework :: Django",
    "Intended Audience :: Developers",
    "Intended Audience :: System Administrators",
]

[project.urls]
Homepage = "https://netbox.readthedocs.io/"
Source = "https://github.com/netbox-community/netbox"
Documentation = "https://docs.netbox.dev/"

Use case

If users wish to use uv for their virtual environment, they have to edit the pyproject.toml file to include the [project] section or uv fails when running any commands:

root@netbox:/opt/netbox# uv run python --version
error: No project table found in: /opt/netbox/pyproject.toml

Database changes

None

External dependencies

None

Originally created by @hblandford on GitHub (May 19, 2025). Originally assigned to: @pheus on GitHub. ### NetBox version v4.3.1 ### Feature type Other ### Proposed functionality Include a project stanza in the pyproject.toml file to assist users who would like to run uv. This would not have to be comprehensive, but it could be useful to include some information. I have not added the dependencies section to file as that is easily sorted from the requirements.txt but that could be included as well. I have inserted it after the comment and before the [tool.black] stanza: ```toml [project] name = "netbox" version = "4.3.1" description = """\ NetBox exists to empower network engineers. Since its release in 2016, it has become the go-to solution for modeling\ and documenting network infrastructure for thousands of organizations worldwide. As a successor to legacy IPAM and\ DCIM applications, NetBox provides a cohesive, extensive, and accessible data model for all things networked.\ By providing a single robust user interface and programmable APIs for everything from cable maps to device\ configurations, NetBox serves as the central source of truth for the modern network. """ readme = "README.md" license = { file = "LICENSE.txt" } authors = [{ name = "NetBox Community" }] requires-python = ">=3.10" classifiers = [ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3", "Framework :: Django", "Intended Audience :: Developers", "Intended Audience :: System Administrators", ] [project.urls] Homepage = "https://netbox.readthedocs.io/" Source = "https://github.com/netbox-community/netbox" Documentation = "https://docs.netbox.dev/" ``` ### Use case If users wish to use uv for their virtual environment, they have to edit the pyproject.toml file to include the [project] section or uv fails when running any commands: root@netbox:/opt/netbox# uv run python --version error: No `project` table found in: `/opt/netbox/pyproject.toml` ### Database changes None ### External dependencies None
adam added the status: acceptedtype: featurecomplexity: low labels 2025-12-29 21:41:49 +01:00
adam closed this issue 2025-12-29 21:41:49 +01:00
Author
Owner

@hblandford commented on GitHub (May 31, 2025):

I am happy to attempt to do this. I might need some help as it would be my first commit.

@hblandford commented on GitHub (May 31, 2025): I am happy to attempt to do this. I might need some help as it would be my first commit.
Author
Owner

@pheus commented on GitHub (May 31, 2025):

Hi @hblandford,
Thanks for the suggestion! I went ahead and wrote the proposed changes based on your example — really helpful, by the way. I haven’t had a chance to test it with uv yet, though.

If you’d like, I can push the commit to my fork so you can give it a try. Or if you’d prefer to open the PR yourself, that works for me too — happy to support either way.

Let me know how you'd like to proceed!

@pheus commented on GitHub (May 31, 2025): Hi @hblandford, Thanks for the suggestion! I went ahead and wrote the proposed changes based on your example — really helpful, by the way. I haven’t had a chance to test it with `uv` yet, though. If you’d like, I can push the commit to my fork so you can give it a try. Or if you’d prefer to open the PR yourself, that works for me too — happy to support either way. Let me know how you'd like to proceed!
Author
Owner

@hblandford commented on GitHub (Jun 1, 2025):

All good, I got stuck at work/uni so glad you had the chance to do it.

Happy to give it a test if you send me the details re the fork.

@hblandford commented on GitHub (Jun 1, 2025): All good, I got stuck at work/uni so glad you had the chance to do it. Happy to give it a test if you send me the details re the fork.
Author
Owner

@pheus commented on GitHub (Jun 1, 2025):

No worries at all — totally understand how that goes!
Thanks for offering to test it, much appreciated.

You can find the branch here: Branch for 19535
Let me know how it goes or if anything needs adjusting!

@pheus commented on GitHub (Jun 1, 2025): No worries at all — totally understand how that goes! Thanks for offering to test it, much appreciated. You can find the branch here: [Branch for 19535](https://github.com/pheus/netbox/tree/19535-add-project-stanza-to-pyproject-toml) Let me know how it goes or if anything needs adjusting!
Author
Owner

@hblandford commented on GitHub (Jun 3, 2025):

I have tested your fork and it seems to be working fine.

I was wondering whether there were any scripts that get run when creating a build. If so maybe we could update those to grab the version from the file and update the entry in pyproject.toml so that someone doesn't have to manually update it.

@hblandford commented on GitHub (Jun 3, 2025): I have tested your fork and it seems to be working fine. I was wondering whether there were any scripts that get run when creating a build. If so maybe we could update those to grab the version from the file and update the entry in pyproject.toml so that someone doesn't have to manually update it.
Author
Owner

@pheus commented on GitHub (Jun 4, 2025):

Thank you very much for your time and effort — great to hear that it’s working!

I did some testing myself as well, though I haven’t worked with uv before. The initial version of the pyproject.toml I wrote used an older spec, so I’ve updated it now to follow the more recent format.

Regarding the version bump:
I looked into using dynamic versioning as a workaround, but that would require building NetBox as a package, which isn't really what we want here.
I'm not aware of any automated version bump script in the NetBox source, but it's possible the maintainers have something they use internally.

So that might be something for a maintainer to weigh in on — whether a manual version update in pyproject.toml is fine in this case.

@pheus commented on GitHub (Jun 4, 2025): Thank you very much for your time and effort — great to hear that it’s working! I did some testing myself as well, though I haven’t worked with `uv` before. The initial version of the `pyproject.toml` I wrote used an older spec, so I’ve updated it now to follow the more recent format. Regarding the version bump: I looked into using dynamic versioning as a workaround, but that would require building NetBox as a package, which isn't really what we want here. I'm not aware of any automated version bump script in the NetBox source, but it's possible the maintainers have something they use internally. So that might be something for a maintainer to weigh in on — whether a manual version update in `pyproject.toml` is fine in this case.
Author
Owner

@jnovinger commented on GitHub (Jun 4, 2025):

So that might be something for a maintainer to weigh in on — whether a manual version update in pyproject.toml is fine in this case.

Thanks, @pheus . I agree that manually updating the version in pyproject.toml is the right direction here.

@jnovinger commented on GitHub (Jun 4, 2025): > So that might be something for a maintainer to weigh in on — whether a manual version update in pyproject.toml is fine in this case. Thanks, @pheus . I agree that manually updating the version in `pyproject.toml` is the right direction here.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11197