我想在安装时生成一个python文件。在
我希望这项工作同时使用python setup.py develop
、python setup.py install
和pip install
。到现在为止,一直都还不错。在
不过,我也希望它能与tox一起工作。这就是我遇到问题的地方。在
我使用的方法是调整develop
和install
命令以在中生成源代码设置.py是这样的:
# make code as python 3 compatible as possible
from __future__ import absolute_import, division, print_function, unicode_literals
import subprocess
import setuptools
import os.path
import distutils.core
from setuptools.command.develop import develop
from setuptools.command.install import install
# Build anltr files on installation
# this is such a mess... it looks like there are
# no common steps to develop and install
class AntlrDevelopCommand(develop):
def run(self):
compile_grammar()
develop.run(self)
class AntlrInstallCommand(install):
def run(self):
compile_grammar()
install.run(self)
def compile_grammar():
here = os.path.dirname(__file__) or '.'
package_dir = os.path.join(here, 'latex2sympy')
subprocess.check_output(['antlr4', 'PS.g4', '-o', 'gen'], cwd=package_dir)
setuptools.setup(
name='latex2sympy',
version=0.1,
author='august.codes',
author_email='augustt198@gmail.com',
description='Parse latex markup into sympy: suitable for programmatic modifcation',
license='GPLv3',
keywords='MIT',
url='',
packages=['latex2sympy'],
classifiers=[
],
install_requires=['antlr-ast', 'sympy'],
cmdclass=dict(
install=AntlrInstallCommand,
develop=AntlrDevelopCommand),
test_suite='nose.collector'
)
然而tox
的安装方法似乎以某种方式运行在setup.py
之外,tox
所代表的魔法黑匣子让人有点恼火地去弄清楚到底发生了什么。在
问题似乎归结于这个巫术,它通过一个exec
运行它。。。。因为某种原因。在
我尝试过的事情:
pdb.set_trace
(命令挂起,我看不到输出)strace -F
这表明setup.py
确实位于相对于源代码的预期位置我考虑过尝试的事情:
在毒性试验-项目的文件,您可以添加要在测试环境中运行的commands。一个简单的例子如下所示:
你可以添加一个命令让tox做你想做的吗?(该命令将针对每个环境运行)。在
相关问题 更多 >
编程相关推荐