import os
import subprocess
import sys
from setuptools import setup
from setuptools.command.install import install
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 = False
except ImportError:
bdist_wheel = None
class PostInstallCommand(install):
def run(self):
source_dir = os.path.dirname(os.path.abspath(__file__))
executable_name = "maturin.exe" if sys.platform.startswith("win") else "maturin"
existing_binary = os.path.join(source_dir, "target", "debug", executable_name)
if os.path.isfile(existing_binary):
source = existing_binary
else:
subprocess.check_call(
["cargo", "rustc", "--bin", "maturin", "--", "-C", "link-arg=-s"]
)
source = os.path.join(source_dir, "target", "debug", executable_name)
install.run(self)
target = os.path.join(self.install_scripts, executable_name)
os.makedirs(self.install_scripts, exist_ok=True)
self.copy_file(source, target)
self.copy_tree(
os.path.join(source_dir, "maturin"),
os.path.join(self.root or self.install_lib, "maturin"),
)
with open("Readme.md") as fp:
long_description = fp.read()
setup(
name="maturin",
author="konstin",
author_email="konstin@mailbox.org",
url="https://github.com/pyo3/maturin",
description="Build and publish crates with pyo3, rust-cpython and cffi bindings as well as rust binaries as "
"python packages",
long_description=long_description,
long_description_content_type="text/markdown",
version="0.7.2",
license="MIT OR Apache-2.0",
cmdclass={"install": PostInstallCommand, "bdist_wheel": bdist_wheel},
classifiers=[
"Software Development :: Build Tools",
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
],
install_requires=["toml~=0.10.0"],
zip_safe=False,
)