Wie können Sie die Paketversion mit Setup.py und dem Paket richtig teilen?

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie können Sie die Paketversion mit Setup.py und dem Paket richtig teilen?

by Anonymous » 05 Apr 2025, 21:29

mit Distutils , setuptools usw. Eine Paketversion ist in setup.py :

angegeben

Code: Select all

# file: setup.py
...
setup(
name='foobar',
version='1.0.0',
# other attributes
)
< /code>

Ich möchte aus dem Paket auf dieselbe Versionsnummer zugreifen können: < /p>

>>> import foobar
>>> foobar.__version__
'1.0.0'


I could add __version__ = '1.0.0' to my package's __init__.py, but I would also like to include additional imports in my package to create a simplified interface to the package:

# file: __init__.py

from foobar import foo
from foobar.bar import Bar

__version__ = '1.0.0'
< /code>

und < /p>

# file: setup.py

from foobar import __version__
...
setup(
name='foobar',
version=__version__,
# other attributes
)
< /code>

Diese zusätzlichen Importe können jedoch dazu führen, dass die Installation von Foobar < /code> fehlschlägt, wenn sie andere Pakete importieren, die noch nicht installiert sind. Wie können Sie die Paketversion mit setup.py und dem Paket richtig teilen?

Top