Skip to content

Commit 7a92598

Browse files
authored
Merge pull request winpython#1489 from stonebig/master
remove step 2.8 post-build patches reduce Package() class complexity (still more to do)
2 parents 20552f8 + da39546 commit 7a92598

File tree

2 files changed

+16
-42
lines changed

2 files changed

+16
-42
lines changed

generate_a_winpython_distro.bat

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ rem 2021-04-22 : path PyPy3 (as we don't try to copy PyPy3.exe to Python.exe)
99
rem 2023-08-21a: add a pre_step with my_requirements_pre.txt + my_find_links_pre
1010
rem 2024-05-12a: use python -m pip instead of pip , and remove --upgrade %new_resolver%
1111
rem 2024-09-15a: compactify for lisiblity
12+
rem 2025-03-02 : remove step 2.3 (pre-build), and 2.8 (post-patch) as we simplify to only wheels
1213
rem *****************************
1314

1415
rem algorithm:
@@ -18,10 +19,8 @@ rem 2 a Pre-clear of previous build infrastructure
1819
rem 2.0 Create a new build
1920
rem 2.1 Create basic build infrastructure
2021
rem 2.2 check infrastructure is in place
21-
rem 2.3 add mandatory packages for build
2222
rem 2.4 add packages pre_requirements (if any)
2323
rem 2.5 add requirement packages
24-
rem 2.8 post-build (if specific workarounds)
2524
rem 2.9 archive success
2625
rem 3.0 Generate Changelog and binaries
2726

@@ -274,17 +273,6 @@ echo if pip doesn't work, check the path of %my_WINPYDIRBASE%
274273
python -m pip install -r %my_requirements% -c %my_constraints% --pre --no-index --trusted-host=None --find-links=%my_find_links% >>%my_archive_log%
275274

276275

277-
echo ----------------------------------------
278-
echo 2.8 (%date% %time%) post-build (if specific workarounds)
279-
echo ----------------------------------------
280-
echo ---------------------------------------- >>%my_archive_log%
281-
echo 2.8 (%date% %time%) post-build (if specific workarounds)>>%my_archive_log%
282-
echo ---------------------------------------- >>%my_archive_log%
283-
284-
@echo on
285-
call %my_basedir%\run_complement_newbuild.bat %my_WINPYDIRBASE%
286-
287-
288276
echo ----------------------------------------
289277
echo 2.9 (%date% %time%) archive success
290278
echo ----------------------------------------

winpython/wppm.py

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,40 +26,27 @@
2626
# Workaround for installing PyVISA on Windows from source:
2727
os.environ["HOME"] = os.environ["USERPROFILE"]
2828

29-
class BasePackage:
30-
def __init__(self, fname):
29+
class Package:
30+
"standardize a Package from filename or pip list"
31+
def __init__(self, fname, suggested_summary=None):
3132
self.fname = fname
33+
self.description = piptree.sum_up(suggested_summary) if suggested_summary else ""
3234
self.name = None
3335
self.version = None
34-
self.description = ""
36+
if fname.endswith((".zip", ".tar.gz", ".whl")):
37+
bname = Path(self.fname).name #wheel style name like "sqlite_bro-1.0.0..."
38+
infos = utils.get_source_package_infos(bname) # get name, version
39+
if infos is not None:
40+
self.name, self.version = infos
41+
self.name = utils.normalize(self.name)
3542
self.url = None
43+
self.files = []
44+
45+
setattr(self,'url',"https://pypi.org/project/" + self.name)
3646

3747
def __str__(self):
3848
return f"{self.name} {self.version}\r\n{self.description}\r\nWebsite: {self.url}"
39-
40-
41-
class Package(BasePackage):
42-
def __init__(self, fname, update=False, suggested_summary=None):
43-
BasePackage.__init__(self, fname)
44-
self.files = []
45-
self.extract_infos()
46-
if suggested_summary:
47-
setattr(self, 'description',
48-
piptree.sum_up(suggested_summary ))
49-
bname = fname.split("-")[0]
50-
setattr(self,'url',"https://pypi.org/project/" + bname)
51-
52-
def extract_infos(self):
53-
"Extract package (name, version) from filename (installer basename)"
54-
bname = Path(self.fname).name
55-
if bname.endswith((".zip", ".tar.gz", ".whl")):
56-
# distutils sdist
57-
infos = utils.get_source_package_infos(bname)
58-
if infos is not None:
59-
self.name, self.version = infos
60-
return
61-
raise NotImplementedError(f"Not supported package type {bname}")
62-
49+
6350

6451
class Distribution:
6552
def __init__(self, target=None, verbose=False, indent=False):
@@ -156,8 +143,7 @@ def get_installed_packages(self, update=False):
156143
# create pip package list
157144
wppm = [
158145
Package(
159-
f"{i[0].replace('-', '_').lower()}-{i[1]}-py3-none-any.whl",
160-
update=update,
146+
f"{i[0].replace('-', '_').lower()}-{i[1]}-py3-none-any.whl", #faking wheel
161147
suggested_summary=self.pip.summary(i[0]) if self.pip else None
162148
)
163149
for i in pip_list

0 commit comments

Comments
 (0)