Skip to content

Commit 5e0e3b5

Browse files
committed
Initial files
1 parent 05197f9 commit 5e0e3b5

File tree

7 files changed

+312
-0
lines changed

7 files changed

+312
-0
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
# Release branches
8+
- "[0-9]+.[0-9]+.X"
9+
10+
tags:
11+
- '*'
12+
13+
# Manual run
14+
workflow_dispatch:
15+
16+
jobs:
17+
sdist_win:
18+
name: Build ${{ matrix.arch }} SOURCE on ${{ matrix.os }} for Python ${{ matrix.python-version }}
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
python-version: [3.6, 3.7, 3.8, 3.9]
23+
include:
24+
- os: windows-2019
25+
arch: "AMD64"
26+
use_qemu: false
27+
- os: windows-2019
28+
arch: "x86"
29+
use_qemu: false
30+
steps:
31+
- name: Check out repository
32+
uses: actions/checkout@v2
33+
34+
- name: Set up Python ${{ matrix.python-version }}
35+
uses: actions/setup-python@v2
36+
with:
37+
python-version: ${{ matrix.python-version }}
38+
39+
- name: Build sdist
40+
run: python setup.py sdist
41+
42+
- name: Save sdist
43+
uses: actions/upload-artifact@v2
44+
with:
45+
path: dist/*.tar.gz
46+
47+
wheels:
48+
name: Build ${{ matrix.arch }} WHEELS on ${{ matrix.os }}
49+
runs-on: ${{ matrix.os }}
50+
needs: [sdist_win]
51+
strategy:
52+
#https://github.com/scikit-build/cmake-python-distributions/blob/master/.github/workflows/build.yml
53+
matrix:
54+
include:
55+
- os: windows-2019
56+
arch: "AMD64"
57+
- os: windows-2019
58+
arch: "x86"
59+
60+
steps:
61+
- name: "Checkout files"
62+
uses: actions/checkout@v2
63+
64+
- name: Build wheels
65+
uses: pypa/cibuildwheel@v2.1.1
66+
env:
67+
CIBW_ARCHS: "${{ matrix.arch }}"
68+
69+
- name: "Upload artifact"
70+
uses: actions/upload-artifact@v2
71+
with:
72+
name: wheels
73+
path: ./wheelhouse/*.whl
74+
if-no-files-found: error
75+
76+
upload_pypi_test:
77+
name: Upload to PyPI test
78+
needs: [wheels]
79+
runs-on: ubuntu-latest
80+
steps:
81+
- uses: actions/download-artifact@v2
82+
with:
83+
name: artifact
84+
path: dist
85+
86+
- name: Publish package to TestPyPI
87+
uses: pypa/gh-action-pypi-publish@master
88+
with:
89+
user: ${{ secrets.test_pypi_username }}
90+
password: ${{ secrets.test_pypi_password }}
91+
repository_url: https://test.pypi.org/legacy/
92+
93+
upload_pypi:
94+
name: Upload to PyPI
95+
needs: [wheels]
96+
runs-on: ubuntu-latest
97+
# upload to PyPI test on every tag starting with 'v'
98+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
99+
steps:
100+
- uses: actions/download-artifact@v2
101+
with:
102+
name: artifact
103+
path: dist
104+
105+
- name: Publish package to PyPI
106+
uses: pypa/gh-action-pypi-publish@master
107+
with:
108+
user: ${{ secrets.pypi_username }}
109+
password: ${{ secrets.pypi_password }}

delphivcl/__init__.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import imp, sys, platform, os, sys
2+
import importlib, importlib.util
3+
4+
dirbname_full = os.path.dirname(__file__)
5+
6+
print("difull", dirbname_full, "name", __name__)
7+
8+
def imp_import(dirbname):
9+
modulefullpath = os.path.join(dirbname, "DelphiFMX")
10+
organiserfind = imp.find_module(modulefullpath)
11+
package = imp.load_module("DelphiFMX", *organiserfind)
12+
return package
13+
14+
def findmodule():
15+
sdir = os.path.join(os.curdir, dirbname_full)
16+
for fname in os.listdir(sdir):
17+
if 'DelphiFMX' in fname:
18+
return os.path.basename(fname)
19+
return None
20+
21+
def new_import(dirbname):
22+
modulefullpath = os.path.join(dirbname, findmodule())
23+
loader = importlib.machinery.ExtensionFileLoader("DelphiFMX", modulefullpath)
24+
spec = importlib.util.spec_from_file_location("DelphiFMX", modulefullpath,
25+
loader=loader, submodule_search_locations=None)
26+
#print("spec", spec, spec.loader, modulefullpath, __file__)
27+
ld = loader.create_module(spec)
28+
#print("ld", ld)
29+
package = importlib.util.module_from_spec(spec)
30+
sys.modules["DelphiFMX"] = package
31+
#print("cmodelq", delphifmx)
32+
spec.loader.exec_module(package)
33+
#print("cmodli", delphifmx)
34+
return package
35+
36+
package = new_import(dirbname_full)
1.26 KB
Binary file not shown.

delphivcl/__version__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.1.1"

delphivcl/libDelphiFMX.so

25.1 MB
Binary file not shown.

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[build-system]
2+
requires = ["setuptools>=40.9.0", "wheel"]
3+
4+
[tool.cibuildwheel]
5+
build = ["cp36-win*", "cp37-win*", "cp38-win*", "cp39-win"]
6+
skip = "pp*"
7+
#archs = ["auto"]
8+
#repair-wheel-command = ""
9+
10+
[tool.cibuildwheel.windows]
11+
archs = ["x86", "AMD64"]
12+
13+
[tool.isort]
14+
profile = "black"
15+
multi_line_output = 3

setup.py

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
import setuptools, os, sys, platform, shutil
2+
3+
#Force platform wheel
4+
try:
5+
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
6+
class bdist_wheel(_bdist_wheel):
7+
def finalize_options(self):
8+
_bdist_wheel.finalize_options(self)
9+
self.root_is_pure = False
10+
except ImportError:
11+
bdist_wheel = None
12+
13+
#Find sys/machine file
14+
def buildfilepath():
15+
ossys = platform.system()
16+
platmac = platform.machine()
17+
platmacshort = ""
18+
sfilename = ""
19+
if ossys == "Windows":
20+
sfilename = "DelphiVCL.pyd"
21+
if platmac.endswith('64'):
22+
#Win x64
23+
platmacshort = "Win64"
24+
else:
25+
#Win x86
26+
platmacshort = "Win32"
27+
28+
pyversionstrshort = f"{sys.version_info.major}{sys.version_info.minor}"
29+
30+
return f"DelphiVCL_{platmacshort}_{pyversionstrshort}{os.sep}{sfilename}"
31+
32+
#Copy target file from lib to pkg folder
33+
def copylibfiletopkg(slibfile, spkgfile):
34+
spkgdirname = os.path.dirname(spkgfile)
35+
if not os.path.exists(spkgdirname):
36+
os.makedirs(spkgdirname)
37+
shutil.copy(slibfile, spkgfile)
38+
39+
#libdirname = os.path.dirname(slibfile)
40+
#shutil.rmtree(libdirname)
41+
42+
#Validate lib paths
43+
def validatelibpaths(slibdir, slibfile):
44+
print(f"Check for lib dir: {slibdir}")
45+
if not os.path.exists(f"{slibdir}"):
46+
raise ValueError(f"Invalid lib path: {slibdir}")
47+
48+
print(f"Check for lib path: {slibfile}")
49+
if not os.path.exists(slibfile):
50+
raise ValueError(f"Invalid lib path: {slibfile}")
51+
52+
#Validate pkg paths
53+
def validatepkgpaths(spkgfile):
54+
print(f"Check for pkg path: {spkgfile}")
55+
if not os.path.exists(spkgfile):
56+
raise ValueError(f"Invalid pkg path: {spkgfile}")
57+
58+
def isdistprocess():
59+
sdir = os.path.join(os.curdir, "delphivcl")
60+
for fname in os.listdir(sdir):
61+
if 'DelphiVCL' in fname:
62+
return True
63+
return False
64+
65+
def distprocess():
66+
sdir = os.path.join(os.curdir, "delphivcl")
67+
for fname in os.listdir(sdir):
68+
if 'DelphiVCL' in fname:
69+
return os.path.basename(fname)
70+
return None
71+
72+
def buildprocess():
73+
spath = buildfilepath()
74+
sfilename = os.path.basename(spath)
75+
76+
slibdir = os.path.join(os.curdir, "lib")
77+
slibfile = os.path.join(slibdir, spath)
78+
79+
spkgdir = os.path.join(os.curdir, "delphivcl")
80+
spkgfile = os.path.join(spkgdir, sfilename)
81+
82+
validatelibpaths(slibdir, slibfile)
83+
copylibfiletopkg(slibfile, spkgfile)
84+
validatepkgpaths(spkgfile)
85+
86+
return sfilename
87+
88+
sfilename = None
89+
print("Check for process type")
90+
if isdistprocess():
91+
print("Found a distribution process")
92+
sfilename = distprocess()
93+
else:
94+
print("Found a build process")
95+
sfilename = buildprocess()
96+
97+
print("Working with file: ", sfilename)
98+
99+
"""def list_files(startpath):
100+
for root, dirs, files in os.walk(startpath):
101+
level = root.replace(startpath, '').count(os.sep)
102+
indent = ' ' * 4 * (level)
103+
print('{}{}/'.format(indent, os.path.basename(root)))
104+
subindent = ' ' * 4 * (level + 1)
105+
for f in files:
106+
print('{}{}'.format(subindent, f))
107+
108+
list_files(f"{os.curdir}")"""
109+
110+
def get_release_version():
111+
"""Creates a new version incrementing by 1 the number of build specified in the
112+
DelphiVCL-0-01/__version__.py file."""
113+
lcals = locals()
114+
gbals = globals()
115+
with open(os.path.join(os.getcwd(), "delphivcl", "__version__.py"), "rt") as opf:
116+
opffilecontents = opf.read()
117+
retvalue = exec(opffilecontents, gbals, lcals)
118+
versorigstr = lcals["__version__"]
119+
return versorigstr
120+
121+
versnewstr = get_release_version()
122+
123+
with open("README.md", "r") as fh:
124+
long_description = fh.read()
125+
126+
setuptools.setup(
127+
name="delphivcl",
128+
version=versnewstr,
129+
description="Delphi VCL for Python",
130+
author="Lucas Belo, Jim McKeeth",
131+
author_email="lucas.belo@live.com",
132+
long_description=long_description,
133+
long_description_content_type="text/markdown",
134+
packages=["delphivcl"],
135+
package_data={"delphivcl": [sfilename]},
136+
classifiers=[
137+
'Development Status :: 1 - Planning',
138+
'Intended Audience :: Developers',
139+
'Topic :: Software Development',
140+
'License :: OSI Approved :: BSD License',
141+
'Programming Language :: Python',
142+
'Programming Language :: Python :: 3',
143+
'Programming Language :: Python :: 3.7',
144+
'Programming Language :: Python :: 3.6',
145+
'Programming Language :: Python :: 3.8',
146+
'Programming Language :: Python :: 3.9',
147+
'Programming Language :: Python :: 3 :: Only',
148+
'Operating System :: Microsoft :: Windows',
149+
],
150+
cmdclass={'bdist_wheel': bdist_wheel},
151+
)

0 commit comments

Comments
 (0)