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

[BUG] --tag-date and --tag-build have no effect when building in PEP 517 mode #2955

Closed
1 task done
Thf772 opened this issue Dec 22, 2021 · 6 comments
Closed
1 task done

Comments

@Thf772
Copy link

Thf772 commented Dec 22, 2021

setuptools version

60.0.3

Python version

3.9.0

OS

Windows 10

Additional environment information

Other possibly relevant packages:

build==0.7.0
pip==21.3.1
wheel==0.37.0

Description

According to the Setuptools documentation, it is possible to specify a version tag from the command line. The typical usecase is a project with automated builds, in ordere to avoid modifying the setup files everytime to change the version (this is my usecase).

When building a PEP 518 project that has no setup.py, it is impossible to use --tag-build and --tag-date to add a version suffix from the command line.

All of the following commands will produce a distribution with no version tag:

python -m build --config-setting=--tag-date myproject
python -m build --config-setting=tag-date myproject

python -m build --config-setting=--global-options=--tag-date myproject
python -m build --config-setting=--global-options=tag-date myproject
python -m build --config-setting=global-options=--tag-date myproject
python -m build --config-setting=global-options=tag-date myproject

(I have tried the latter 4 after reading issue #2491)

The following command simply fails (which is normal):

python -m build --tag-date myproject

Expected behavior

The source and wheel distribution are produced with the version number from setup.cfg suffixed by the build tag or date tag (depending to the option used).

For instance, if the version number in setup.cfg is 0.0.0 and tag-build=nightly is used, the expected output is a source and wheel distribution with version 0.0.0.nightly.

How to Reproduce

  1. Create a valid PEP 518 project using setuptools.build_meta as the build backend
  2. Ensure there is a setup.cfg file but no setup.py
  3. Run any of the following commands:
python -m build --config-setting=--tag-date myproject
python -m build --config-setting=tag-date myproject
python -m build --config-setting=--global-options=--tag-date myproject
python -m build --config-setting=--global-options=tag-date myproject
python -m build --config-setting=global-options=--tag-date myproject
python -m build --config-setting=global-options=tag-date myproject

Output

Assuming the version number in setup.cfg is 0.0.0:

(myvenv) PS D:\myproject> python -m build --config-setting=tag-date myproject
[Redacted the build output for brievity]
Successfully built myproject-0.0.0.tar.gz and myproject-0.0.0-py3-none-any.whl

The source dist and wheel in the dist directory both have the version number 0.0.0.

Code of Conduct

  • I agree to follow the PSF Code of Conduct
@Thf772 Thf772 added bug Needs Triage Issues that need to be evaluated for severity and status. labels Dec 22, 2021
@jaraco
Copy link
Member

jaraco commented Dec 22, 2021

Thanks for the report. This is essentially a dupe of #2491.

@jaraco jaraco closed this as completed Dec 22, 2021
@jaraco jaraco added duplicate and removed bug Needs Triage Issues that need to be evaluated for severity and status. labels Dec 22, 2021
@layday
Copy link
Member

layday commented Dec 22, 2021

The option is called --global-option (singular). Try:

python -m build -C--global-option=--tag-build -C--global-option=<build> -C--global-option=--tag-date -C--global-option=<date>

@Thf772
Copy link
Author

Thf772 commented Dec 22, 2021

Thanks for the report. This is essentially a dupe of #2491.

Thanks, I wasn't sure about that. #2491 is about passing options to the underlying build command, but the two specific options I have problems with seem like they need to be used before that, and not sent to the build command (see below).

The option is called --global-option (singular). Try:

python -m build -C--global-option=--tag-build -C--global-option=<build> -C--global-option=--tag-date -C--global-option=<date>

Thanks, using the singular option works... but also doesn't work. It causes a failure in the "Building sdist" step.

Using either -C--global-option=--tag-build or -C--global-option=--tag-date alone results in an exception:

(myvenv) PS > py -m build -C--global-option=--tag-date mypackage
[Redacted for brievity]
* Building sdist...
Traceback (most recent call last):
  File "[...]\myvenv\lib\site-packages\pep517\in_process\_in_process.py", line 363, in <module>
    main()
  File "[...]\myvenv\lib\site-packages\pep517\in_process\_in_process.py", line 345, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "[...]\myvenv\lib\site-packages\pep517\in_process\_in_process.py", line 314, in build_sdist
    return backend.build_sdist(sdist_directory, config_settings)
  File "[...]\Temp\build-env-xarzif_6\lib\site-packages\setuptools\build_meta.py", line 234, in build_sdist
    return self._build_with_temp_dir(['sdist', '--formats', 'gztar'],
  File "[...]\Temp\build-env-xarzif_6\lib\site-packages\setuptools\build_meta.py", line 211, in _build_with_temp_dir
    sys.argv = (sys.argv[:1] + setup_command +
TypeError: can only concatenate list (not "str") to list

ERROR Backend subproccess exited when trying to invoke build_sdist

Using one of them with a second global option results in an unrecognized argument error:

(myvenv) PS > py -m build -C--global-option=--tag-build -C--global-option=testbuild mypackage
[Redacted for brievity]
* Building sdist...
usage: _in_process.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: _in_process.py --help [cmd1 cmd2 ...]
   or: _in_process.py --help-commands
   or: _in_process.py cmd --help

error: option --tag-build not recognized

ERROR Backend subproccess exited when trying to invoke build_sdist

@layday
Copy link
Member

layday commented Dec 22, 2021

What is the original command you are attempting to translate? Is --tag-build valid for sdists and wheels or is it only for egg_info? The PEP 517 backend will pass the the config settings to all commands that it runs.

@Thf772
Copy link
Author

Thf772 commented Dec 22, 2021

I tried using this page of the documentation: https://setuptools.pypa.io/en/latest/userguide/distribution.html#tagging-and-daily-build-or-snapshot-releases (which I linked in the opening post).

It seems these two parameters are valid for egg_info only, however, in PEP 517 mode it is not possible to explicitely call egg_info. This is why I thought (and still think) this issue is not a dupe of #2491.

@layday
Copy link
Member

layday commented Dec 22, 2021

There is a proposal at the bottom of #2491 about namespacing the config settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants