Update word-count to support PEP 517 sdists
This commit is contained in:
parent
789c0b842b
commit
b9a2d2c89f
|
@ -0,0 +1,2 @@
|
||||||
|
include pyproject.toml Cargo.toml
|
||||||
|
recursive-include src *
|
|
@ -1,2 +1,3 @@
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["setuptools", "wheel", "setuptools-rust"]
|
requires = ["setuptools", "wheel", "setuptools-rust", "toml"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from setuptools.command.test import test as TestCommand
|
from setuptools.command.test import test as TestCommand
|
||||||
|
from setuptools.command.sdist import sdist as SdistCommand
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from setuptools_rust import RustExtension
|
from setuptools_rust import RustExtension
|
||||||
|
@ -16,6 +18,41 @@ except ImportError:
|
||||||
from setuptools_rust import RustExtension
|
from setuptools_rust import RustExtension
|
||||||
|
|
||||||
|
|
||||||
|
class CargoModifiedSdist(SdistCommand):
|
||||||
|
"""Modifies Cargo.toml to use an absolute rather than a relative path
|
||||||
|
|
||||||
|
The current implementation of PEP 517 in pip always does builds in an
|
||||||
|
isolated temporary directory. This causes problems with the build, because
|
||||||
|
Cargo.toml necessarily refers to the current version of pyo3 by a relative
|
||||||
|
path.
|
||||||
|
|
||||||
|
Since these sdists are never meant to be used for anything other than
|
||||||
|
tox / pip installs, at sdist build time, we will modify the Cargo.toml
|
||||||
|
in the sdist archive to include an *absolute* path to pyo3.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def make_release_tree(self, base_dir, files):
|
||||||
|
"""Stages the files to be included in archives"""
|
||||||
|
super().make_release_tree(base_dir, files)
|
||||||
|
|
||||||
|
import toml
|
||||||
|
# Cargo.toml is now staged and ready to be modified
|
||||||
|
cargo_loc = os.path.join(base_dir, 'Cargo.toml')
|
||||||
|
assert os.path.exists(cargo_loc)
|
||||||
|
|
||||||
|
with open(cargo_loc, 'r') as f:
|
||||||
|
cargo_toml = toml.load(f)
|
||||||
|
|
||||||
|
rel_pyo3_path = cargo_toml['dependencies']['pyo3']['path']
|
||||||
|
base_path = os.path.dirname(__file__)
|
||||||
|
abs_pyo3_path = os.path.abspath(os.path.join(base_path, rel_pyo3_path))
|
||||||
|
|
||||||
|
cargo_toml['dependencies']['pyo3']['path'] = abs_pyo3_path
|
||||||
|
|
||||||
|
with open(cargo_loc, 'w') as f:
|
||||||
|
toml.dump(cargo_toml, f)
|
||||||
|
|
||||||
|
|
||||||
class PyTest(TestCommand):
|
class PyTest(TestCommand):
|
||||||
user_options = []
|
user_options = []
|
||||||
|
|
||||||
|
@ -50,5 +87,8 @@ setup(
|
||||||
setup_requires=setup_requires,
|
setup_requires=setup_requires,
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
cmdclass=dict(test=PyTest),
|
cmdclass={
|
||||||
|
'test': PyTest,
|
||||||
|
'sdist': CargoModifiedSdist,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,9 +5,9 @@ envlist = py35,
|
||||||
pypy35
|
pypy35
|
||||||
minversion = 3.4.0
|
minversion = 3.4.0
|
||||||
skip_missing_interpreters = true
|
skip_missing_interpreters = true
|
||||||
|
isolated_build = true
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
description = Run the unit tests under {basepython}
|
description = Run the unit tests under {basepython}
|
||||||
deps = -rrequirements-dev.txt
|
deps = -rrequirements-dev.txt
|
||||||
usedevelop = True
|
|
||||||
commands = pytest {posargs}
|
commands = pytest {posargs}
|
||||||
|
|
Loading…
Reference in New Issue