-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
python-poetry/poetry-core
#710Labels
kind/featureFeature requests/implementationsFeature requests/implementationsstatus/triageThis issue needs to be triagedThis issue needs to be triaged
Description
I noticed that the undocumented build.py step is executed after tool.poetry.scripts. This is bad if build.py is used to generate one of those scripts. My proposal is to run build.py before tool.poetry.scripts.
Example
pyproject.toml:
[tool.poetry]
name = "sample"
version = "0.1.0"
description = ""
authors = []
[tool.poetry.build]
generate-setup-file = true
script = "build.py" # generates sample/sample_script
[tool.poetry.scripts]
generated_script = { reference = "sample/sample_script", type = "file" }
[build-system]
requires = ["poetry-core", "setuptools"]
build-backend = "poetry.core.masonry.api"
build.py:
import os
def build(_setup_kwargs):
script_dir = os.path.dirname(os.path.realpath(__file__))
output_file = os.path.join(script_dir, 'sample/sample_script')
with open(output_file, 'w') as stream:
stream.write('#!/usr/bin/env bash\necho "Sample Script"\n')
os.chmod(output_file, 0o755)Current output:
tmp/sample$ poetry --version
Poetry (version 1.8.2)
tmp/sample$ mkdir -p sample
tmp/sample$ touch sample/__init__.py
tmp/sample$ poetry build
Preparing build environment with build-system requirements poetry-core, setuptools
Building sample (0.1.0)
- Building sdist
/home/weisslj/tmp/sample/sample/sample_script in script specification (generated_script) is not found.
Expected output:
tmp/sample$ poetry --version
Poetry (version 1.8.2)
tmp/sample$ mkdir -p sample
tmp/sample$ touch sample/__init__.py
tmp/sample$ poetry build
Preparing build environment with build-system requirements poetry-core, setuptools
Building sample (0.1.0)
- Building sdist
- Built sample-0.1.0.tar.gz
- Building wheel
running build
running build_py
creating /home/weisslj/tmp/sample/build
creating /home/weisslj/tmp/sample/build/lib
creating /home/weisslj/tmp/sample/build/lib/sample
copying sample/__init__.py -> /home/weisslj/tmp/sample/build/lib/sample
copying sample/__init__.py -> /home/weisslj/tmp/sample/build/lib/sample
copying sample/sample_script -> /home/weisslj/tmp/sample/build/lib/sample
running build_scripts
creating /home/weisslj/tmp/sample/build/scripts-3.11
copying sample/sample_script -> /home/weisslj/tmp/sample/build/scripts-3.11
- Built sample-0.1.0-cp311-cp311-manylinux_2_36_x86_64.whl
The wheel should contain sample_script as script:
tmp/sample$ unzip -l dist/sample-0.1.0-cp311-cp311-manylinux_2_36_x86_64.whl | grep sample_script
41 1980-01-01 00:00 sample/sample_script
41 1980-01-01 00:00 sample-0.1.0.data/scripts/sample_script
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind/featureFeature requests/implementationsFeature requests/implementationsstatus/triageThis issue needs to be triagedThis issue needs to be triaged