forked from BigfootDev/flatbuffers
Stage the Python license file during builds (#9015)
Copy the repo-root LICENSE into the Python package directory for the duration of setup() so license_files = LICENSE remains valid without using deprecated parent-directory paths. Remove the staged copy after the build completes.
This commit is contained in:
@@ -12,8 +12,26 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
|
||||
_THIS_DIR = Path(__file__).resolve().parent
|
||||
_ROOT_LICENSE = _THIS_DIR.parent / 'LICENSE'
|
||||
_LOCAL_LICENSE = _THIS_DIR / 'LICENSE'
|
||||
|
||||
|
||||
def _stage_license_file():
|
||||
if _LOCAL_LICENSE.exists() or not _ROOT_LICENSE.exists():
|
||||
return False
|
||||
shutil.copyfile(_ROOT_LICENSE, _LOCAL_LICENSE)
|
||||
return True
|
||||
|
||||
_remove_staged_license = _stage_license_file()
|
||||
|
||||
try:
|
||||
setup(
|
||||
name='flatbuffers',
|
||||
version='25.12.19',
|
||||
@@ -42,3 +60,6 @@ setup(
|
||||
'Source': 'https://github.com/google/flatbuffers',
|
||||
},
|
||||
)
|
||||
finally:
|
||||
if _remove_staged_license and _LOCAL_LICENSE.exists():
|
||||
_LOCAL_LICENSE.unlink()
|
||||
|
||||
Reference in New Issue
Block a user