diff --git a/MANIFEST.in b/MANIFEST.in index d2450be8..793b6582 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,4 +2,4 @@ include LICENSE include DESCRIPTION.md global-exclude *.py[cdo] include versioneer.py -include ptvsd/_version.py +include src/ptvsd/_version.py diff --git a/linux/build_plat.sh b/linux/build_plat.sh new file mode 100644 index 00000000..6fa5fa38 --- /dev/null +++ b/linux/build_plat.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -ex + +SOURCE_ROOT=$1 +DEST=$2 +PYABI=$3 + +# Compile +for PYBIN in /opt/python/${PYABI}*/bin; do + "${PYBIN}/pip" install -U cython + "${PYBIN}/python" "${SOURCE_ROOT}/setup.py" build bdist_wheel -d "${DEST}" --abi +done diff --git a/linux/readme.md b/linux/readme.md new file mode 100644 index 00000000..982d8926 --- /dev/null +++ b/linux/readme.md @@ -0,0 +1,16 @@ +Building manylinux1 wheels + +1. Clone ptvsd to base dir (say `C:\git`), so ptvsd source must be at `C:\git\ptvsd`. +2. Create dir `dist` under `C:\git\dist`. +3. Run following command: +* x86_64: `docker run --rm -v C:\git:/io -w /io quay.io/pypa/manylinux1_x86_64:latest /io/ptvsd/linux/build_plat.sh /io/ptvsd /io/dist cp37-cp37m` +* i686: `docker run --rm -v C:\git:/io -w /io quay.io/pypa/manylinux1_i686:latest /io/ptvsd/linux/build_plat.sh /io/ptvsd /io/dist cp37-cp37m` +4. After the run the built wheel should be in `C:\git\dist`. + +Other python ABI options: +* cp27-cp27m +* cp27-cp27mu +* cp34-cp34m +* cp35-cp35m +* cp36-cp36m +* cp37-cp37m \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 5c41e7ca..5ae13329 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,3 @@ -[wheel] -python-tag = py3 - [metadata] license_file = LICENSE diff --git a/setup.py b/setup.py index 0b0bfa5d..e22d24a9 100644 --- a/setup.py +++ b/setup.py @@ -9,13 +9,23 @@ import os.path import subprocess import sys -from setuptools import setup +pure = None +if '--pure' in sys.argv: + pure = True + sys.argv.remove('--pure') +elif '--universal' in sys.argv: + pure = True +elif '--abi' in sys.argv: + pure = False + sys.argv.remove('--abi') -import versioneer + +from setuptools import setup # noqa +import versioneer # noqa sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), 'src')) -import ptvsd -import ptvsd._vendored +import ptvsd # noqa +import ptvsd._vendored # noqa del sys.path[0] @@ -23,6 +33,11 @@ PYDEVD_ROOT = ptvsd._vendored.project_root('pydevd') PTVSD_ROOT = os.path.dirname(os.path.abspath(ptvsd.__file__)) +def get_buildplatform(): + if '-p' in sys.argv: + return sys.argv[sys.argv.index('-p') + 1] + return None + def cython_build(): print('Compiling extension modules (set SKIP_CYTHON_BUILD=1 to omit)') subprocess.call([ @@ -46,10 +61,29 @@ with open('DESCRIPTION.md', 'r') as fh: long_description = fh.read() +try: + from wheel.bdist_wheel import bdist_wheel as _bdist_wheel + + class bdist_wheel(_bdist_wheel): + def finalize_options(self): + _bdist_wheel.finalize_options(self) + self.root_is_pure = pure + +except ImportError: + bdist_wheel = None + if __name__ == '__main__': if not os.getenv('SKIP_CYTHON_BUILD'): cython_build() + cmds = versioneer.get_cmdclass() + cmds['bdist_wheel'] = bdist_wheel + + extras = {} + platforms = get_buildplatform() + if platforms is not None: + extras['platforms'] = platforms + setup( name='ptvsd', version=versioneer.get_version(), @@ -82,5 +116,6 @@ if __name__ == '__main__': 'ptvsd': ['ThirdPartyNotices.txt'], 'ptvsd._vendored': list(iter_vendored_files()), }, - cmdclass=versioneer.get_cmdclass(), + cmdclass=cmds, + **extras ) diff --git a/win/build_all.ps1 b/win/build_all.ps1 index d2683225..f5805be9 100644 --- a/win/build_all.ps1 +++ b/win/build_all.ps1 @@ -1,4 +1,4 @@ -param($packages, [switch]$pack) +param($packages, [switch]$pack, [string]$wheeltype) $root = $script:MyInvocation.MyCommand.Path | Split-Path -parent; if ($env:BUILD_BINARIESDIRECTORY) { @@ -13,31 +13,30 @@ if ($env:BUILD_BINARIESDIRECTORY) { $env:SKIP_CYTHON_BUILD = "1" -if (-not $pack) { - (gci $packages\python* -Directory) | %{ gi $_\tools\python.exe } | ?{ Test-Path $_ } | %{ - Write-Host "Building with $_" - & $_ -m pip install -U pyfindvs setuptools wheel cython - pushd "$root\..\src\ptvsd\_vendored\pydevd" - & $_ setup_cython.py enable_msbuildcompiler build_ext -b "$bin" -t "$obj" - popd - } +Get-ChildItem $dist\*.whl, $dist\*.zip | Remove-Item -Force -} else { - gci $dist\*.whl, $dist\*.zip | Remove-Item -Force +(Get-ChildItem $packages\python* -Directory -Filter '*python.3.7*') | ForEach-Object{ Get-Item $_\tools\python.exe } | Where-Object{ Test-Path $_ } | Select-Object -last 1 | ForEach-Object{ + Write-Host "Building with $_" + & $_ -m pip install -U pip + & $_ -m pip install -U pyfindvs setuptools wheel cython - (gci $packages\python* -Directory) | %{ gi $_\tools\python.exe } | ?{ Test-Path $_ } | select -last 1 | %{ + if ($wheeltype -eq 'sdist') { Write-Host "Building sdist with $_" & $_ setup.py sdist -d "$dist" --formats zip - - Write-Host "Building wheel with $_" - & $_ setup.py build -b "$bin" -t "$obj" bdist_wheel -d "$dist" - gci $dist\ptvsd-*.whl | %{ - Write-Host "Built wheel found at $_" - Copy-Item $_ (Join-Path $_.Directory ($_.Name -replace '(ptvsd-.+?)-any\.whl', '$1-win_amd64.whl')) - Copy-Item $_ (Join-Path $_.Directory ($_.Name -replace '(ptvsd-.+?)-any\.whl', '$1-win32.whl')) - Remove-Item $_ - } } + if ($wheeltype -eq 'pure') { + Write-Host "Building wheel with $_ pure python wheel" + & $_ setup.py bdist_wheel -d "$dist" --pure + } + + if ($wheeltype -eq 'universal') { + Write-Host "Building wheel with $_ universal wheel" + & $_ setup.py bdist_wheel -d "$dist" --universal + } + + Get-ChildItem $dist\ptvsd-*.whl, $dist\*.zip | ForEach-Object{ + Write-Host "Built wheel found at $_" + } } diff --git a/win/build_plat.ps1 b/win/build_plat.ps1 new file mode 100644 index 00000000..c67ef1b8 --- /dev/null +++ b/win/build_plat.ps1 @@ -0,0 +1,42 @@ +param($packages, [switch]$pack, [string]$platform, [string]$pyver) + +$root = $script:MyInvocation.MyCommand.Path | Split-Path -parent; +if ($env:BUILD_BINARIESDIRECTORY) { + $bin = mkdir -Force $env:BUILD_BINARIESDIRECTORY\bin + $obj = mkdir -Force $env:BUILD_BINARIESDIRECTORY\obj + $dist = mkdir -Force $env:BUILD_BINARIESDIRECTORY\dist +} else { + $bin = mkdir -Force $root\bin + $obj = mkdir -Force $root\obj + $dist = mkdir -Force $root\dist +} + +$env:SKIP_CYTHON_BUILD = "1" + +$filter = "*python.$pyver*" +if ($platform -eq 'win32'){ + $filter = "*pythonx86.$pyver*" +} +Write-Host "Filter: $filter" + +if (-not $pack) { + (Get-ChildItem $packages\python* -Directory -Filter $filter) | ForEach-Object{ Get-Item $_\tools\python.exe } | Where-Object{ Test-Path $_ } | Select-Object -last 1 | ForEach-Object{ + Write-Host "Building with $_" + & $_ -m pip install -U pip + & $_ -m pip install -U pyfindvs setuptools wheel cython + + Push-Location "$root\..\src\ptvsd\_vendored\pydevd" + & $_ setup_cython.py enable_msbuildcompiler build_ext -b "$bin" -t "$obj" + Pop-Location + } +} else { + Get-ChildItem $dist\*.whl, $dist\*.zip | Remove-Item -Force + + (Get-ChildItem $packages\python* -Directory -Filter $filter) | ForEach-Object{ Get-Item $_\tools\python.exe } | Where-Object{ Test-Path $_ } | Select-Object -last 1 | ForEach-Object{ + Write-Host "Building wheel with $_ for platform." + & $_ setup.py build -b "$bin" -t "$obj" bdist_wheel -d "$dist" -p "$platform" --abi + Get-ChildItem $dist\ptvsd-*.whl | ForEach-Object{ + Write-Host "Built wheel found at $_" + } + } +} diff --git a/win/packages.config b/win/packages.config index 8239a37c..13ff0f5c 100644 --- a/win/packages.config +++ b/win/packages.config @@ -1,8 +1,12 @@ - - - + + + + + + + diff --git a/win/sign.proj b/win/sign.proj index b0fa023a..01780030 100644 --- a/win/sign.proj +++ b/win/sign.proj @@ -1,6 +1,6 @@ - $(MSBuildThisFileDirectory)\..\ptvsd\ + $(MSBuildThisFileDirectory)\..\src\ptvsd\