8000 Build WinPython wheel via Flit instead of setup.py · Tmusvit/winpython@1da87ed · GitHub
[go: up one dir, main page]

Skip to content

Commit 1da87ed

Browse files
committed
Build WinPython wheel via Flit instead of setup.py
1 parent 4162153 commit 1da87ed

File tree

4 files changed

+111
-2
lines changed

4 files changed

+111
-2
lines changed

make.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,8 @@ def rebuild_winpython(basedir, targetdir, architecture=64, verbose=False):
20412041
for name in os.listdir(packdir):
20422042
if name.startswith("winpython-") and name.endswith((".exe", ".whl")):
20432043
os.remove(str(Path(packdir) / name))
2044-
utils.build_wininst(
2044+
# utils.build_wininst is replaced per flit 2023-02-27
2045+
utils.buildflit_wininst(
20452046
str(Path(__file__).resolve().parent),
20462047
copy_to=packdir,
20472048
architecture=architecture,

pyproject.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[build-system] # flit_core seems the step after 'setuptools','wheel','build','twine' (see https://github.com/pypa/build/issues/394)
2+
requires = ["flit_core"]
3+
build-backend = "flit_core.buildapi"
4+
5+
[project]
6+
name = "WinPython"
7+
authors = [
8+
{name = "Pierre Raybaut"},
9+
{name = "stonebig"},
10+
]
11+
dependencies = []
12+
requires-python = ">=3.6"
13+
readme = "README.rst"
14+
license = {file = "LICENSE"}
15+
classifiers=[
16+
'License :: OSI Approved :: MIT License',
17+
'Programming Language :: Python :: 3',
18+
'Development Status :: 5 - Production/Stable',
19+
'Topic :: Scientific/Engineering',
20+
'Topic :: Software Development :: Widget Sets',
21+
]
22+
dynamic = ["version",]
23+
description="WinPython distribution tools, including WPPM"
24+
25+
[project.urls]
26+
Documentation = "https://winpython.github.io/"
27+
Source = "https://github.com/winpython/winpython"
28+
29+
[project.scripts]
30+
wpcp = "winpython.controlpanel:main"
31+
wppm = "winpython.wppm:main"

winpython/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
OTHER DEALINGS IN THE SOFTWARE.
2929
"""
3030

31-
__version__ = '6.0.20230219'
31+
__version__ = '6.1.20230227'
3232
__license__ = __doc__
3333
__project_url__ = 'http://winpython.github.io/'

winpython/utils.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,83 @@ def build_wininst(
786786
return dst_fname
787787

788788

789+
def buildflit_wininst(
790+
root,
791+
python_exe=None,
792+
copy_to=None,
793+
architecture=None, # shall be unused
794+
verbose=False,
795+
installer='bdist_wininst', # unused
796+
):
797+
"""Build wininst installer from Python package located in *root*
798+
with flit"""
799+
if python_exe is None:
800+
python_exe = sys.executable
801+
assert Path(python_exe).is_file()
802+
cmd = [python_exe, '-m' ,'flit', 'build']
803+
if architecture is not None:
804+
archstr = (
805+
'win32' if architecture == 32 else 'win-amd64'
806+
)
807+
# root = a tmp dir in windows\tmp,
808+
if verbose:
809+
subprocess.call(cmd, cwd=root)
810+
else:
811+
p = subprocess.Popen(
812+
cmd,
813+
cwd=root,
814+
stdout=subprocess.PIPE,
815+
stderr=subprocess.PIPE,
816+
)
817+
p.communicate()
818+
p.stdout.close()
819+
p.stderr.close()
820+
distdir = str(Path(root) / 'dist')
821+
if not Path(distdir).is_dir():
822+
raise RuntimeError(
823+
"Build failed: see package README file for further"
824+
" details regarding installation requirements.\n\n"
825+
"For more concrete debugging infos, please try to build "
826+
"the package from the command line:\n"
827+
"1. Open a WinPython command prompt\n"
828+
"2. Change working directory to the appropriate folder\n"
829+
"3. Type `python -m filt build`"
830+
)
831+
pattern = WININST_PATTERN.replace(
832+
r'(win32|win\-amd64)', archstr
833+
)
834+
for distname in os.listdir(distdir):
835+
match = re.match(pattern, distname)
836+
if match is not None:
837+
break
838+
# for wheels (winpython here)
839+
match = re.match(SOURCE_PATTERN, distname)
840+
if match is not None:
841+
break
842+
match = re.match(WHEELBIN_PATTERN, distname)
843+
if match is not None:
844+
break
845+
else:
846+
raise RuntimeError(
847+
f"Build failed: not a pure Python package? {distdir}"
848+
)
849+
src_fname = str(Path(distdir) / distname)
850+
if copy_to is None:
851+
return src_fname
852+
else:
853+
dst_fname = str(Path(copy_to) / distname)
854+
shutil.move(src_fname, dst_fname)
855+
if verbose:
856+
print(
857+
(
858+
f"Move: {src_fname} --> {dst_fname}"
859+
)
860+
)
861+
# remove tempo dir 'root' no more needed
862+
shutil.rmtree(root, onerror=onerror)
863+
return dst_fname
864+
865+
789866
def direct_pip_install(
790867
fname,
791868
python_exe=None,

0 commit comments

Comments
 (0)
0