Added partial support for PyPI (python) package build on Windows
This commit is contained in:
@@ -28,6 +28,7 @@ cmake_minimum_required (VERSION 2.8)
|
|||||||
project (libzt)
|
project (libzt)
|
||||||
|
|
||||||
# --- SETUP
|
# --- SETUP
|
||||||
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
set(CMAKE_SUPPRESS_REGENERATION true)
|
set(CMAKE_SUPPRESS_REGENERATION true)
|
||||||
|
|
||||||
# Paths
|
# Paths
|
||||||
|
|||||||
7
packages/PyPI/bdist.bat
Normal file
7
packages/PyPI/bdist.bat
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
cd ../../
|
||||||
|
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=DEBUG
|
||||||
|
cmake --build build
|
||||||
|
copy bin\lib\Debug\*.lib packages\pypi
|
||||||
|
cd packages\pypi
|
||||||
|
pip3 install wheel twine
|
||||||
|
py setup.py bdist_wheel
|
||||||
@@ -8,3 +8,5 @@ recursive-include ../../include *.h
|
|||||||
#recursive-include ../../include *.hpp
|
#recursive-include ../../include *.hpp
|
||||||
include libhttp.a
|
include libhttp.a
|
||||||
include liblwip.a
|
include liblwip.a
|
||||||
|
include http.lib
|
||||||
|
include lwip.lib
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
bdist:
|
bdist:
|
||||||
cd ../../; cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=DEBUG; cmake --build build
|
cd ../../; cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=DEBUG
|
||||||
|
cmake --build build
|
||||||
cp ../../bin/lib/*.a .
|
cp ../../bin/lib/*.a .
|
||||||
python3 setup.py bdist_wheel
|
python3 setup.py bdist_wheel
|
||||||
|
|
||||||
|
|||||||
@@ -19,20 +19,43 @@ while True:
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building the Package
|
## Building
|
||||||
|
|
||||||
Package is specified in [setup.py](setup.py). *Note: A new version must be specified in `setup.py` for every new upload of a package*
|
### macOS, Linux
|
||||||
|
|
||||||
Get necessary tools
|
Binary distribution:
|
||||||
|
|
||||||
|
make bdist
|
||||||
|
|
||||||
|
Alternatively, source Distribution:
|
||||||
|
|
||||||
|
make sdist
|
||||||
|
|
||||||
|
Upload to PyPI:
|
||||||
|
|
||||||
|
make upload
|
||||||
|
|
||||||
|
Cleanup:
|
||||||
|
|
||||||
|
make clean
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
Binary distribution:
|
||||||
|
|
||||||
|
bdist.bat
|
||||||
|
|
||||||
|
Source distribution:
|
||||||
|
|
||||||
|
sdist.bat
|
||||||
|
|
||||||
|
Upload to PyPI:
|
||||||
|
|
||||||
|
upload.bat
|
||||||
|
|
||||||
|
Cleanup:
|
||||||
|
|
||||||
|
clean.bat
|
||||||
|
|
||||||
`pip3 install wheel twine`
|
|
||||||
|
|
||||||
*Note: As there appears to be no way to differentiate C and C++ code (and thus pass correct build args to each type) in a setuptools script we must separately build the `lwip` and `http_parser` libraries, copy them here, and then build the binary. See the top-level [README.md](../../README.md) for instructions on how to do that*
|
*Note: As there appears to be no way to differentiate C and C++ code (and thus pass correct build args to each type) in a setuptools script we must separately build the `lwip` and `http_parser` libraries, copy them here, and then build the binary. See the top-level [README.md](../../README.md) for instructions on how to do that*
|
||||||
|
|
||||||
Build the binary distribution wheel:
|
|
||||||
|
|
||||||
`python3 setup.py bdist_wheel`
|
|
||||||
|
|
||||||
Upload to PyPI
|
|
||||||
|
|
||||||
`twine upload dist/*`
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Move sources into top-level subdirectory so MANIFEST.in can include it in the source distribution
|
|
||||||
|
|
||||||
mkdir -p data/libzt
|
|
||||||
mkdir -p data/zto
|
|
||||||
|
|
||||||
# libzt
|
|
||||||
cp -r ../../src data/libzt/src
|
|
||||||
cp -r ../../include data/libzt/include
|
|
||||||
cp -r ../../ext data/libzt/ext
|
|
||||||
|
|
||||||
# ZeroTier
|
|
||||||
cp -r ../../zto/ data/zto
|
|
||||||
|
|
||||||
@@ -2,58 +2,74 @@
|
|||||||
|
|
||||||
from setuptools import setup, Extension, Command, Distribution
|
from setuptools import setup, Extension, Command, Distribution
|
||||||
import glob
|
import glob
|
||||||
|
import os
|
||||||
|
|
||||||
class BinaryDistribution(Distribution):
|
class BinaryDistribution(Distribution):
|
||||||
def is_pure(self):
|
def is_pure(self):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
projDir='../..'
|
# WINDOWS
|
||||||
source_list = ['libzt_wrap.cxx']
|
if os.name == 'nt':
|
||||||
source_list.extend(list(glob.glob(projDir+'/src/*.cpp')))
|
projDir='..\\..'
|
||||||
source_list.extend(list(glob.glob(projDir+'/zto/node/*.cpp')))
|
source_list = ['libzt_wrap.cxx']
|
||||||
source_list.extend(list(glob.glob(projDir+'/zto/osdep/*.cpp')))
|
source_list.extend(list(glob.glob(projDir+'\\src\\*.cpp')))
|
||||||
source_list.extend(list(glob.glob(projDir+'/zto/service/*.cpp')))
|
source_list.extend(list(glob.glob(projDir+'\\zto\\node\\*.cpp')))
|
||||||
source_list.extend(list(glob.glob(projDir+'/zto/controller/*.cpp')))
|
source_list.extend(list(glob.glob(projDir+'\\zto\\osdep\\*.cpp')))
|
||||||
|
source_list.extend(list(glob.glob(projDir+'\\zto\\service\\*.cpp')))
|
||||||
|
source_list.extend(list(glob.glob(projDir+'\\zto\\controller\\*.cpp')))
|
||||||
|
|
||||||
#http_parser_source_list = ['libzt_wrap.cxx']
|
source_list = list(set(source_list)-set(
|
||||||
#http_parser_source_list.extend(list(glob.glob('../../zto/ext/http-parser/*.c')))
|
[
|
||||||
#lwip_source_list = ['libzt_wrap.cxx']
|
projDir+'\\zto\\osdep\\LinuxEthernetTap.cpp',
|
||||||
#lwip_source_list.extend(list(glob.glob('../../ext/lwip/src/core/*.c')))
|
projDir+'\\zto\\osdep\\BSDEthernetTap.cpp',
|
||||||
#lwip_source_list.extend(list(glob.glob('../../ext/lwip/src/core/ipv4/*.c')))
|
projDir+'\\zto\\osdep\\OSXEthernetTap.cpp',
|
||||||
#lwip_source_list.extend(list(glob.glob('../../ext/lwip/src/core/ipv6/*.c')))
|
projDir+'\\zto\\osdep\\WindowsEthernetTap.cpp'
|
||||||
|
]))
|
||||||
|
|
||||||
source_list = list(set(source_list)-set(
|
libzt_module = Extension('libzt',
|
||||||
[projDir+'/zto/osdep/LinuxEthernetTap.cpp',projDir+'/zto/osdep/BSDEthernetTap.cpp',projDir+'/zto/osdep/OSXEthernetTap.cpp', projDir+'/zto/osdep/WindowsEthernetTap.cpp']))
|
extra_compile_args=['/std:c++14', '-DNOMINMAX=1', '-DZT_SDK', '-DSDK', '-DZT_SOFTWARE_UPDATE_DEFAULT=\"disable\"'],
|
||||||
|
extra_link_args=['/LIBPATH:.', 'WS2_32.Lib', 'ShLwApi.Lib', 'iphlpapi.Lib','lwip.lib','http.lib'],
|
||||||
|
sources=source_list,
|
||||||
|
include_dirs=[projDir+'\\include',
|
||||||
|
projDir+'\\ext\\lwip\\src\\include',
|
||||||
|
projDir+'\\ext\\lwip-contrib\\ports\\win32\\include',
|
||||||
|
projDir+'\\zto\\include',
|
||||||
|
projDir+'\\zto\\node',
|
||||||
|
projDir+'\\zto\\service',
|
||||||
|
projDir+'\\zto\\osdep',
|
||||||
|
projDir+'\\zto\\controller']
|
||||||
|
)
|
||||||
|
# EVERYTHING ELSE
|
||||||
|
else:
|
||||||
|
projDir='../..'
|
||||||
|
source_list = ['libzt_wrap.cxx']
|
||||||
|
source_list.extend(list(glob.glob(projDir+'/src/*.cpp')))
|
||||||
|
source_list.extend(list(glob.glob(projDir+'/zto/node/*.cpp')))
|
||||||
|
source_list.extend(list(glob.glob(projDir+'/zto/osdep/*.cpp')))
|
||||||
|
source_list.extend(list(glob.glob(projDir+'/zto/service/*.cpp')))
|
||||||
|
source_list.extend(list(glob.glob(projDir+'/zto/controller/*.cpp')))
|
||||||
|
|
||||||
#lwip_module = Extension('lwip',
|
source_list = list(set(source_list)-set(
|
||||||
# extra_compile_args=['-DZT_SDK'],
|
[
|
||||||
# extra_link_args=[],
|
projDir+'/zto/osdep/LinuxEthernetTap.cpp',
|
||||||
# sources=lwip_source_list,
|
projDir+'/zto/osdep/BSDEthernetTap.cpp',
|
||||||
# include_dirs=['../include',
|
projDir+'/zto/osdep/OSXEthernetTap.cpp',
|
||||||
# '../../include',
|
projDir+'/zto/osdep/WindowsEthernetTap.cpp'
|
||||||
# '../../ext/lwip/src/include',
|
]))
|
||||||
# '../../ext/lwip-contrib/ports/unix/include',]
|
|
||||||
# )
|
|
||||||
|
|
||||||
#http_parser_module = Extension('http_parser',
|
libzt_module = Extension('libzt',
|
||||||
# extra_compile_args=[],
|
extra_compile_args=['-std=c++11', '-DZT_SDK', '-DZT_SOFTWARE_UPDATE_DEFAULT=\"disable\"'],
|
||||||
# extra_link_args=[],
|
extra_link_args=['-L.','-llwip','-lhttp'],
|
||||||
# sources=http_parser_source_list,
|
sources=source_list,
|
||||||
# )
|
include_dirs=[projDir+'/include',
|
||||||
|
projDir+'/ext/lwip/src/include',
|
||||||
libzt_module = Extension('libzt',
|
projDir+'/ext/lwip-contrib/ports/unix/include',
|
||||||
extra_compile_args=['-std=c++11', '-DZT_SDK', '-DZT_SOFTWARE_UPDATE_DEFAULT=\"disable\"'],
|
projDir+'/zto/include',
|
||||||
extra_link_args=['-L.','-llwip','-lhttp'],
|
projDir+'/zto/node',
|
||||||
sources=source_list,
|
projDir+'/zto/service',
|
||||||
include_dirs=[projDir+'/include',
|
projDir+'/zto/osdep',
|
||||||
projDir+'/ext/lwip/src/include',
|
projDir+'/zto/controller']
|
||||||
projDir+'/ext/lwip-contrib/ports/unix/include',
|
)
|
||||||
projDir+'/zto/include',
|
|
||||||
projDir+'/zto/node',
|
|
||||||
projDir+'/zto/service',
|
|
||||||
projDir+'/zto/osdep',
|
|
||||||
projDir+'/zto/controller']
|
|
||||||
)
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
@@ -66,7 +82,7 @@ setup(
|
|||||||
description = 'ZeroTier',
|
description = 'ZeroTier',
|
||||||
long_description = 'Encrypted P2P communication between apps and services',
|
long_description = 'Encrypted P2P communication between apps and services',
|
||||||
author = 'ZeroTier, Inc.',
|
author = 'ZeroTier, Inc.',
|
||||||
author_email = 'joseph@zerotier.com',
|
author_email = 'josep@zerotier.com',
|
||||||
url = 'https://github.com/zerotier/libzt',
|
url = 'https://github.com/zerotier/libzt',
|
||||||
license='GPLv3',
|
license='GPLv3',
|
||||||
download_url = 'https://github.com/zerotier/libzt/archive/1.1.6.tar.gz',
|
download_url = 'https://github.com/zerotier/libzt/archive/1.1.6.tar.gz',
|
||||||
|
|||||||
Reference in New Issue
Block a user