Skip to content

Commit da0dc43

Browse files
committed
Optimizing installation process
1 parent 298964a commit da0dc43

File tree

2 files changed

+43
-46
lines changed

2 files changed

+43
-46
lines changed

.github/workflows/deploy-wheels.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,20 @@ jobs:
6969
- name: "Upload artifact"
7070
uses: actions/upload-artifact@v2
7171
with:
72-
name: wheels
7372
path: ./wheelhouse/*.whl
7473
if-no-files-found: error
74+
75+
#check_dist:
76+
# name: Check dist
77+
# needs: [sdist_win, wheels]
78+
# runs-on: ubuntu-20.04
79+
# steps:
80+
# - uses: actions/download-artifact@v2
81+
# with:
82+
# name: artifact
83+
# path: dist
84+
#
85+
# - run: pipx run twine check --strict dist/*
7586

7687
upload_pypi_test:
7788
name: Upload to PyPI test

setup.py

Lines changed: 31 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ def finalize_options(self):
88
_bdist_wheel.finalize_options(self)
99
self.root_is_pure = False
1010
except ImportError:
11-
bdist_wheel = None
12-
11+
bdist_wheel = None
12+
1313
#Find sys/machine file
1414
def buildfilepath():
1515
ossys = platform.system()
@@ -25,7 +25,10 @@ def buildfilepath():
2525
else:
2626
#Win x86
2727
platmacshort = "Win32"
28-
28+
29+
#sfilename = "DelphiVCL.pyd"
30+
#platmacshort = "Win64"
31+
2932
if not platmacshort:
3033
raise ValueError("Undetermined platform.")
3134

@@ -39,10 +42,7 @@ def copylibfiletopkg(slibfile, spkgfile):
3942
if not os.path.exists(spkgdirname):
4043
os.makedirs(spkgdirname)
4144
shutil.copy(slibfile, spkgfile)
42-
43-
#libdirname = os.path.dirname(slibfile)
44-
#shutil.rmtree(libdirname)
45-
45+
4646
#Validate lib paths
4747
def validatelibpaths(slibdir, slibfile):
4848
print(f"Check for lib dir: {slibdir}")
@@ -51,13 +51,13 @@ def validatelibpaths(slibdir, slibfile):
5151

5252
print(f"Check for lib path: {slibfile}")
5353
if not os.path.exists(slibfile):
54-
raise ValueError(f"Invalid lib path: {slibfile}")
54+
raise ValueError(f"File not found: {slibfile}")
5555

5656
#Validate pkg paths
5757
def validatepkgpaths(spkgfile):
5858
print(f"Check for pkg path: {spkgfile}")
5959
if not os.path.exists(spkgfile):
60-
raise ValueError(f"Invalid pkg path: {spkgfile}")
60+
raise ValueError(f"File not found {spkgfile}")
6161

6262
#Clear pkg files (trash)
6363
def clearpkgtrashfiles():
@@ -68,27 +68,21 @@ def clearpkgtrashfiles():
6868
fpath = os.path.join(sdir, file)
6969
print("Removing trash file:", fpath)
7070
os.remove(fpath)
71-
72-
def isdistprocess():
73-
sdistdir = os.path.join(os.curdir, "dist")
74-
slibdir = os.path.join(os.curdir, "lib")
75-
76-
return os.path.exists(sdistdir) and not os.path.exists(slibdir)
77-
78-
def distprocess():
71+
72+
def finddistfile():
7973
sdir = os.path.join(os.curdir, "delphivcl")
8074
for fname in os.listdir(sdir):
8175
if 'DelphiVCL' in fname:
8276
return os.path.basename(fname)
8377
return None
8478

85-
def buildprocess():
79+
def copylibfile():
8680
spath = buildfilepath()
8781
sfilename = os.path.basename(spath)
88-
82+
8983
slibdir = os.path.join(os.curdir, "lib")
9084
slibfile = os.path.join(slibdir, spath)
91-
85+
9286
spkgdir = os.path.join(os.curdir, "delphivcl")
9387
spkgfile = os.path.join(spkgdir, sfilename)
9488

@@ -97,30 +91,8 @@ def buildprocess():
9791
copylibfiletopkg(slibfile, spkgfile)
9892
validatepkgpaths(spkgfile)
9993

100-
return sfilename
101-
102-
sfilename = None
103-
print("Check for process type")
104-
if isdistprocess():
105-
print("Found a distribution process")
106-
sfilename = distprocess()
107-
else:
108-
print("Found a build process")
109-
sfilename = buildprocess()
110-
111-
print("Working with file: ", sfilename)
94+
return sfilename
11295

113-
"""def list_files(startpath):
114-
for root, dirs, files in os.walk(startpath):
115-
level = root.replace(startpath, '').count(os.sep)
116-
indent = ' ' * 4 * (level)
117-
print('{}{}/'.format(indent, os.path.basename(root)))
118-
subindent = ' ' * 4 * (level + 1)
119-
for f in files:
120-
print('{}{}'.format(subindent, f))
121-
122-
list_files(f"{os.curdir}")"""
123-
12496
def get_release_version():
12597
"""Creates a new version incrementing by 1 the number of build specified in the
12698
DelphiVCL-0-01/__version__.py file."""
@@ -131,6 +103,20 @@ def get_release_version():
131103
retvalue = exec(opffilecontents, gbals, lcals)
132104
versorigstr = lcals["__version__"]
133105
return versorigstr
106+
107+
extra_args = {}
108+
#We don't want to share the compiled files via sdist (we don't have them)
109+
if not ("sdist" in sys.argv):
110+
slibdir = os.path.join(os.curdir, "lib")
111+
#Binary distribution
112+
if ("bdist_wheel" in sys.argv) and os.path.exists(slibdir):
113+
bdata = copylibfile()
114+
extra_args = {'package_data': {"delphivcl": [bdata]}}
115+
else:
116+
#Final user installation
117+
bdata = finddistfile()
118+
if bdata:
119+
extra_args = {'package_data': {"delphivcl": [bdata]}}
134120

135121
versnewstr = get_release_version()
136122

@@ -145,8 +131,7 @@ def get_release_version():
145131
author_email="lucas.belo@live.com",
146132
long_description=long_description,
147133
long_description_content_type="text/markdown",
148-
packages=["delphivcl"],
149-
package_data={"delphivcl": [sfilename]},
134+
packages=["delphivcl"],
150135
classifiers=[
151136
'Development Status :: 1 - Planning',
152137
'Intended Audience :: Developers',
@@ -162,4 +147,5 @@ def get_release_version():
162147
'Operating System :: Microsoft :: Windows',
163148
],
164149
cmdclass={'bdist_wheel': bdist_wheel},
150+
**extra_args
165151
)

0 commit comments

Comments
 (0)