-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automate publishing Python package on PyPI #1580
base: main
Are you sure you want to change the base?
Conversation
c584a37
to
2492b7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
I think snapcraft 8 lets us get rid of the setup.py
file, but we'll find out when I run the CI
2492b7c
to
9ed5e8a
Compare
The
From a Python (packaging) point of view the use of |
9ed5e8a
to
f40db10
Compare
The ModuleNotFoundError: No module named 'craft_cli' I can't see that the Can anyone see what is the problem? |
Okay, looks like there is a problem with the
The problem is that that with the new setup the returned version string also contains the package name. I'll try to find a solution. Suggestions welcome! EDIT: Stupid me! A closing |
98ab399
to
b1bf7dc
Compare
The CI jobs all pass now (on my personal fork). I rebased the branch, and I made separate commits to document the specific changes that were necessary to work around a few build issues. 📜 Hope that looks good enough now for the PR to be merged. 🤞 |
b1bf7dc
to
f7b9151
Compare
I have signed the CLA now. I use a different email address on Launchpad than on GitHub, that's why the check probably didn't find my Launchpad account. |
The cla-check still fails. I checked my Launchpad account again; looks like there was another account with the email address I use on GitHub. I merged the accounts on Launchpad now. |
I received an email notification this morning saying, I was added as a member of Canonical Contributor Agreement. I assume, the cla-check job would now succeed. |
@@ -138,7 +138,7 @@ parts: | |||
# Ensure we don't have a dubious ownership error from git with a remote build. | |||
git config --global --add safe.directory $CRAFT_PART_SRC | |||
# set the version | |||
version="$(python3 setup.py --version)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems to be always making the charmcraft snap that gets built report the version dev
, I'm guessing because it's not recognised as installed at this point, so there's not a _version.py
file in the charmcraft directory from which to report.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't setuptools-scm take care of generating the _version.py
file, transparently? Have you seen any issues in the build process? 😲
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The snap artefact from the build is reporting that, and I've been unable to come up with something else that makes it work as intended. Could you revert the removal of setup.py
for now, since having it there shouldn't break things?
@lengau Let me know what needs to be changed, if anything, so that I can help getting this merged. Thank you! 👍 |
b93b823
to
c4dd4a3
Compare
I rebased the branch of this PR again to keep it up-to-date with the If the changes look okay, I'd be happy to see this merged. Otherwise, please let me know what needs to be changed. |
c4dd4a3
to
a6679f7
Compare
The GHA process expects a semantic Git tag and verifies that the package version matches that tag, before publishing the package on PyPI.
Was: ModuleNotFoundError 'craft_cli'
a6679f7
to
e6cc956
Compare
Is there a reason why this PR isn't considered for merging? Any arguments against the changes? Anything that needs to be updated? It would be very helpful if the recent release(s) of charmcraft were published also on PyPI. For example, I'm currently blocked by the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please re-add setup.py, and then I'm happy with this :-)
I've created #1635 for seeing if we can remove setup.py at a later date so we don't block this PR with it
@@ -1,4 +1,4 @@ | |||
attrs==23.2.0 | |||
attrs==22.2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version downgrade?
This PR removes the now superflous
setup.py
and adds 2 Tox environments that help with publishing the Python package on PyPI.tox -e package
can be used for linting to help detect packaging issues.tox -e package -- upload
allows to publish the package on PyPI.tox -e ensure_version_matches $GIT_TAG
verifies that the package version matches the semantic Git tag on the current commit. This is used by the GHA configuration to prevent a mismatch of tags and the version of the published package.To make publishing work, you need to add the 2 secrets
PYPI_USERNAME
andPYPI_PASSWORD
to Settings ➜ Secrets ➜ Actions with the PyPI access token for the project, as described in the Python packaging user guide.Related
setup.py
deprecated? – The use as a command line tool is deprecated