-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt setup.py to add entry-points in dist-info.data/scripts/rez
Signed-off-by: Jean-Christophe Morin <[email protected]>
- Loading branch information
1 parent
3178230
commit 984b310
Showing
4 changed files
with
163 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["setuptools"] | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,15 @@ | |
import os | ||
import os.path | ||
import sys | ||
import logging | ||
import tempfile | ||
import platform | ||
import shutil | ||
|
||
|
||
try: | ||
from setuptools import setup, find_packages | ||
import distutils.command.build_scripts | ||
except ImportError: | ||
print("install failed - requires setuptools", file=sys.stderr) | ||
sys.exit(1) | ||
|
@@ -51,6 +56,62 @@ def find_files(pattern, path=None, root="rez"): | |
long_description = f.read() | ||
|
||
|
||
SCRIPT_TEMPLATE = """#!/usr/bin/python -E | ||
# -*- coding: utf-8 -*- | ||
import re | ||
import sys | ||
from rez.cli._entry_points import {0} | ||
if __name__ == '__main__': | ||
sys.argv[0] = re.sub(r'(-script\\.pyw|\\.exe)?$', '', sys.argv[0]) | ||
sys.exit({0}()) | ||
""" | ||
|
||
class build_scripts(distutils.command.build_scripts.build_scripts): | ||
def finalize_options(self): | ||
super().finalize_options() | ||
self.build_dir = os.path.join(self.build_dir, "rez") | ||
|
||
def run(self): | ||
logging.getLogger().info("running rez's customized build_scripts command") | ||
|
||
scripts = [] | ||
tmpdir = tempfile.mkdtemp("rez-scripts") | ||
|
||
os.makedirs(self.build_dir) | ||
|
||
for command in self.scripts: | ||
spec = get_specifications()[command] | ||
|
||
filename = "{0}.py".format(command) | ||
if platform.system() == "Windows": | ||
filename = "{0}-script.py".format(command) | ||
|
||
path = os.path.join(tmpdir, filename) | ||
with open(path, "w") as fd: | ||
fd.write(SCRIPT_TEMPLATE.format(spec["func"])) | ||
|
||
scripts.append(path) | ||
|
||
if platform.system() == "Windows": | ||
launcher = "t64.exe" | ||
if spec["type"] == "window": | ||
launcher = "w64.exe" | ||
|
||
self.copy_file( | ||
os.path.join("launcher", launcher), | ||
os.path.join(self.build_dir, "{0}.exe".format(command)) | ||
) | ||
|
||
prod_install_path = os.path.join(tmpdir, ".rez_production_install") | ||
with open(prod_install_path, "w") as fd: | ||
fd.write("# Production install installed with pip") | ||
|
||
scripts.append(prod_install_path) | ||
|
||
self.scripts = scripts | ||
return super().run() | ||
|
||
|
||
setup( | ||
name="rez", | ||
version=_rez_version, | ||
|
@@ -65,9 +126,7 @@ def find_files(pattern, path=None, root="rez"): | |
author_email="[email protected]", | ||
license="Apache-2.0", | ||
license_files=["LICENSE"], | ||
entry_points={ | ||
"console_scripts": get_specifications().values() | ||
}, | ||
scripts=list(get_specifications().keys()), | ||
include_package_data=True, | ||
zip_safe=False, | ||
package_dir={'': 'src'}, | ||
|
@@ -99,5 +158,6 @@ def find_files(pattern, path=None, root="rez"): | |
"Programming Language :: Python :: 3", | ||
"Topic :: Software Development", | ||
"Topic :: System :: Software Distribution" | ||
] | ||
], | ||
cmdclass={"build_scripts": build_scripts}, | ||
) |
Oops, something went wrong.