Closed wrkhenddher closed 9 months ago
If I remove "versionista" from [build-system.requires]
File "/private/var/folders/md/y_nfnc2j6bs7g8b67tf10tfr0000gn/T/pip-build-env-o2jxb8a_/overlay/lib/python3.8/site-packages/versioningit/methods.py", line 64, in load
raise ConfigError(
versioningit.errors.ConfigError: versioningit.format entry point 'format' not found
[end of output]
In my other project ("dummy"), I've got this:
# pyproject.toml
[tool.versioningit.format]
method = "format"
While with this:
# pyproject.toml
[tool.versioningit.format]
method = { module = "versionista.main", value = "format" }
I get this:
File "/private/var/folders/md/y_nfnc2j6bs7g8b67tf10tfr0000gn/T/pip-build-env-zj9l184m/overlay/lib/python3.8/site-packages/versioningit/config.py", line 35, in load
return VersioningitMethod(self.method_spec.load(project_dir), self.params)
File "/private/var/folders/md/y_nfnc2j6bs7g8b67tf10tfr0000gn/T/pip-build-env-zj9l184m/overlay/lib/python3.8/site-packages/versioningit/methods.py", line 115, in load
obj = import_module(self.module)
File "/Users/henddher/.pyenv/versions/3.8.17/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'versionista.main'
[end of output]
FYI - This is what my stub "versionista" looks like:
# versionista/src/versionista/main.py
from typing import Any, Dict
import versioningit
def format(*, description: versioningit.VCSDescription, base_version: str, next_version: str, params: Dict[str, Any]) -> str:
print(description, base_version, next_version, params)
return "{base_version}.m"
def main():
print("main")
if __name__ == "__main__":
main()
$ python
Python 3.8.17 (default, Nov 14 2023, 12:28:42)
[Clang 15.0.0 (clang-1500.0.40.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import versionista
>>> import versionista.main
>>> versionista.main.format()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: format() missing 4 required keyword-only arguments: 'description', 'base_version', 'next_version', and 'params'
Modified "versionista" as I realized the method declaration instructions are for setup.cfg
With this, I can pip install .
"versionista" ok.
...
[project.scripts]
versionista-format = "versionista.main:format"
It runs although with traceback:
$ versionista-format
Traceback (most recent call last):
File "/Users/henddher/Documents/github/dummy/venv/bin/versionista-format", line 8, in <module>
sys.exit(format())
TypeError: format() missing 4 required keyword-only arguments: 'description', 'base_version', 'next_version', and 'params'
Yet, I cannot use it my other project:
[tool.versioningit.format]
method = "versionista-format"
> pip install .
...
File "/private/var/folders/md/y_nfnc2j6bs7g8b67tf10tfr0000gn/T/pip-build-env-p8__auxi/overlay/lib/python3.8/site-packages/versioningit/core.py", line 190, in from_config
format=config.format.load(project_dir),
File "/private/var/folders/md/y_nfnc2j6bs7g8b67tf10tfr0000gn/T/pip-build-env-p8__auxi/overlay/lib/python3.8/site-packages/versioningit/config.py", line 35, in load
return VersioningitMethod(self.method_spec.load(project_dir), self.params)
File "/private/var/folders/md/y_nfnc2j6bs7g8b67tf10tfr0000gn/T/pip-build-env-p8__auxi/overlay/lib/python3.8/site-packages/versioningit/methods.py", line 64, in load
raise ConfigError(
versioningit.errors.ConfigError: versioningit.format entry point 'versionista-format' not found
[end of output]
The "No matching distribution found for versionista" message occurs because pip install
installs the build-system.requires
for a package in an isolated virtualenv, which means that it tries to download versionista
from PyPI, yet you haven't uploaded it there yet. There are two different ways to deal with this before uploading to PyPI:
--no-build-isolation
to pip install
. This will require you to already have versionista
, versioningit
, setuptools
, and wheel
all already installed in your virtualenv.Specify a VCS URL for versionista
in build-system.requires
. For example, if versionista
were available on GitHub at https://github.com/wrkhenddher/versionista, you could write:
[build-system]
requires = [
"setuptools >= 61",
"wheel",
"versioningit",
"versionista @ git+https://github.com/wrkhenddher/versionista",
]
build-backend = "setuptools.build_meta"
Testing versionista
via the versioningit
command should work as long as (a) both versioningit
and versionista
are installed in the same environment, and (b) your "dummy" package specifies your versionista
method correctly.
In order to declare a method entrypoint in pyproject.toml
, versionista
's pyproject.toml
must contain this:
[project.entry-points."versioningit.format"]
versionista-format = "versionista.main:format"
I'll add this syntax to the docs in a bit.
Side note: If you're actually planning on using {base_version}.m
as your version format, that's not going to work, as it's not a valid PEP 440 version. versioningit
will just give you a warning about this, but newer versions of setuptools will error out completely, and I don't think you'll be able to upload to PyPI with such a version.
Thank you @jwodder!!!
The "No matching distribution found for versionista" ...
Yes - That was it!
I also managed to solve it by using "versionista @ file:///Users/wrkhenddher/Documents/github/versionista"
and/or "versionista @ file:///Users/wrkhenddher/Documents/github/versionista/dist/versionista-0.0.2-py3-none-any.whl"
.
For the former, I had to pip cache remove versionista
from my "dummy"'s "venv". For the latter, versionista/ $ python -m build
was enough.
Testing versionista via the ...
👍 👍
In order to declare a method entrypoint ...
I think I tried it but didn't work. I must have been because of [build-system.requires]
not having a valid URI.
Side note: If you're actually planning ...
Yes. the "m" was just to verify if my stub was getting called.
I think I'm good!
Again, thank you very much @jwodder!!!
Hi!
I am trying to create my own versioningit "plugin",
"versionista"
. It has its own customformat()
function. My goal is to use"versionista"
in other projects.I'm following these instructions:
However, when I try to install my other project, using the same "venv" where "versionista" is installed, it fails:
My other project ("dummy"):
In my "versionista" project:
Am I missing anything obvious? Can I test my "versionista" plugin wired onto "versioningit" outside a build? (e.g. https://versioningit.readthedocs.io/en/stable/command.html#command)