Skip to content

Commit

Permalink
fix setup.py on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Dec 21, 2020
1 parent e185832 commit 632f3e6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
44 changes: 22 additions & 22 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ image: Visual Studio 2017
clone_depth: 1
environment:
matrix:
- variant: debug
compiler: msvc-14.1
model: 64
api: store
lib: 1
- variant: debug
compiler: msvc-14.1
model: 32
lib: 1
- variant: debug
compiler: gcc
model: 32
crypto: openssl
ssl_lib: /usr/local/include
ssl_include: /usr/local/lib
lib: 1
- variant: debug
compiler: msvc-14.1
model: 64
sim: 1
- cmake: 1
# - variant: debug
# compiler: msvc-14.1
# model: 64
# api: store
# lib: 1
# - variant: debug
# compiler: msvc-14.1
# model: 32
# lib: 1
# - variant: debug
# compiler: gcc
# model: 32
# crypto: openssl
# ssl_lib: /usr/local/include
# ssl_include: /usr/local/lib
# lib: 1
# - variant: debug
# compiler: msvc-14.1
# model: 64
# sim: 1
# - cmake: 1
- variant: release
compiler: msvc-14.1
model: 64
Expand Down Expand Up @@ -109,7 +109,7 @@ build_script:
b2.exe --hash openssl-lib=%ssl_lib% openssl-include=%ssl_include% warnings=all -j %NUMBER_OF_PROCESSORS% %compiler% address-model=%model% picker-debugging=on invariant-checks=full variant=%variant% link=shared crypto=%crypto% asserts=on export-extra=on windows-api=%api% windows-version=win10 libtorrent-link=shared stage_module stage_dependencies
)
- if defined python_dist (
c:\Python35-x64\python.exe setup.py bdist --format=msi
c:\Python36-x64\python.exe setup.py bdist --format=msi
)

# simulations
Expand Down
13 changes: 11 additions & 2 deletions bindings/python/setup.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
import sys
import sysconfig
import tempfile
import multiprocessing

import setuptools
import setuptools.command.build_ext as _build_ext_lib


def get_msvc_toolset():
# Reference: https://wiki.python.org/moin/WindowsCompilers
major_minor = sys.version_info()[0:2]
major_minor = sys.version_info[0:2]
if major_minor in ((2, 6), (2, 7), (3, 0), (3, 1), (3, 2)):
return "msvc-9.0"
if major_minor in ((3, 3), (3, 4)):
Expand Down Expand Up @@ -96,7 +97,8 @@ def write_b2_python_config(config):
# python.jam appends SHLIB_SUFFIX on its own.
ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
shlib_suffix = sysconfig.get_config_var("SHLIB_SUFFIX")
ext_suffix = ext_suffix[: -len(shlib_suffix)]
if shlib_suffix != None and len(shlib_suffix) < len(ext_suffix):
ext_suffix = ext_suffix[: -len(shlib_suffix)]
write(f' : "{ext_suffix}"')
write(" ;\n")

Expand Down Expand Up @@ -166,6 +168,8 @@ def build_extension_with_b2(self):

if self.parallel:
args.append(f"-j{self.parallel}")
else:
args.append(f"-j{multiprocessing.cpu_count()}")
if self.libtorrent_link:
args.append(f"libtorrent-link={self.libtorrent_link}")
if self.boost_link:
Expand Down Expand Up @@ -193,8 +197,13 @@ def build_extension_with_b2(self):
self.announce("project-config.jam contents:")
self.announce(config.read())
config.close()
args.append(f"python={sysconfig.get_python_version()}")
args.append(f"--project-config={config.name}")
self.spawn(["b2"] + args)
if os.name == "nt":
# the python module is called libtorrent.pyd on windows, rename
# it to match target
os.rename(os.path.join(target.parent, 'libtorrent.pyd'), target)
finally:
os.unlink(config.name)

Expand Down

0 comments on commit 632f3e6

Please sign in to comment.