Skip to content
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

Error: python3 set_version.py -v 2.0.2 ., exit code: 1, expected: 0 #33

Closed
skwde opened this issue Oct 27, 2023 · 4 comments
Closed

Error: python3 set_version.py -v 2.0.2 ., exit code: 1, expected: 0 #33

skwde opened this issue Oct 27, 2023 · 4 comments

Comments

@skwde
Copy link

skwde commented Oct 27, 2023

Since the required python version now is 3.8 I use the docker image node:18-bullseye-slim which allows me to install python 3.9`.

However now I get following error:

[10:31:12 AM] [semantic-release] [semantic-release-pypi] › ℹ  Installing required python packages (pip~=23.2, build~=1.0, setuptools~=68.2, twine~=4.0, tomlkit~=0.12)
<usual pip log>
Successfully installed setuptools-68.2.2 tomlkit-0.12.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Traceback (most recent call last):
  File "/usr/local/lib/node_modules/semantic-release-pypi/dist/py/set_version.py", line 24, in <module>
    toml['project']['version'] = args.version
  File "/usr/local/lib/python3.9/dist-packages/tomlkit/container.py", line 613, in __getitem__
    raise NonExistentKey(key)
tomlkit.exceptions.NonExistentKey: 'Key "project" does not exist.'
[10:31:14 AM] [semantic-release] › ✘  Failed step "prepare" of plugin "semantic-release-pypi"
[10:31:14 AM] [semantic-release] › ✘  An error occurred while running semantic-release: Error: command: python3 /usr/local/lib/node_modules/semantic-release-pypi/dist/py/set_version.py -v 2.0.2 ., exit code: 1, expected: 0
    at assertExitCode (/usr/local/lib/node_modules/semantic-release-pypi/dist/verify.js:33:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async setVersionToml (/usr/local/lib/node_modules/semantic-release-pypi/dist/prepare.js:23:5)
    at async prepare (/usr/local/lib/node_modules/semantic-release-pypi/dist/prepare.js:79:9)
    at async validator (file:///usr/local/lib/node_modules/semantic-release/lib/plugins/normalize.js:36:24)
    at async file:///usr/local/lib/node_modules/semantic-release/lib/plugins/pipeline.js:38:36
    at async Promise.all (index 0)
    at async next (file:///usr/local/lib/node_modules/semantic-release/node_modules/p-reduce/index.js:15:44) {
  pluginName: 'semantic-release-pypi'
}
Error: command: python3 /usr/local/lib/node_modules/semantic-release-pypi/dist/py/set_version.py -v 2.0.2 ., exit code: 1, expected: 0
    at assertExitCode (/usr/local/lib/node_modules/semantic-release-pypi/dist/verify.js:33:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async setVersionToml (/usr/local/lib/node_modules/semantic-release-pypi/dist/prepare.js:23:5)
    at async prepare (/usr/local/lib/node_modules/semantic-release-pypi/dist/prepare.js:79:9)
    at async validator (file:///usr/local/lib/node_modules/semantic-release/lib/plugins/normalize.js:36:24)
    at async file:///usr/local/lib/node_modules/semantic-release/lib/plugins/pipeline.js:38:36
    at async Promise.all (index 0)
    at async next (file:///usr/local/lib/node_modules/semantic-release/node_modules/p-reduce/index.js:15:44) {
  pluginName: 'semantic-release-pypi'
}

Here is the gitlab-ci.yml I use

release:
  image: node:18-bullseye-slim
  stage: release
  tags:
    - docker
  before_script:
    - apt-get update && apt-get install -y --no-install-recommends git-core ca-certificates
    - apt-get install -y python3 python3-pip
    - python3 --version
    - pip3 install --upgrade pip
    - pip3 install setuptools wheel build twine
    - npm install -g semantic-release @semantic-release/{commit-analyzer,release-notes-generator,changelog,git,gitlab} semantic-release-pypi
    - npm list -g
  script:
    - semantic-release
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
@abichinger
Copy link
Owner

Hi @skwde

I guess a pyproject.toml exists, but you use setup.py to build. Same issue: pycasbin/django-orm-adapter#26

Here are some solutions:

  1. Migrate from setup.py to pyproject.toml
  2. use [email protected]
  3. Wait until I add an option to force the use of setup.py, even if pyproject.toml exists

@skwde
Copy link
Author

skwde commented Oct 30, 2023

Thanks for pointing it out.

I already migrated most to setup.cfg a while back.
Thus, my setup.py is fairly basic, I only have

import setuptools

setuptools.setup()

in it. So in principle I can just remove it?!

When I do so I still get the same error above. Any ideas?

@abichinger
Copy link
Owner

abichinger commented Oct 30, 2023

If pyproject.tomlexists in your project, semantic-release-pypi is going to set the version inside pyproject.toml. This causes the error above, because there is no project section in your pyproject.toml

I recommend migrating all metadata to pyproject.toml and deleting setup.py and setup.cfg

@skwde
Copy link
Author

skwde commented Oct 31, 2023

Alright, that worked. Thanks.

For others coming here, transition to pyproject.toml is fairly straight forward using

and then

Note, I also had to make sure ensurepip is available.

@skwde skwde closed this as completed Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants