インストール時にpythonファイルを生成したいと思います。Pythonパッケージ:インストール時にPythonファイルを生成し、毒でこの作業を行います
python setup.py develop
、python setup.py install
、pip install
の両方でこの作品を欲しいです。ここまでは順調ですね。
しかし、これも毒素で動作します。これは私が問題を抱えているところです。
私が使用してのアプローチは非常に似setup.pyでソースコードを生成するためにdevelop
とinstall
コマンドを微調整することです:
# 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='[email protected]',
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
を介してsetup.py
を実行するこのブードゥー教の魔法に問題があるようです。何らかの理由で。私が試した
Command "/home/tom/active/latex2sympy/.tox/py35/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-e698cucb-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-lu2idbzz-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/tom/active/latex2sympy/.tox/py35/include/site/python3.5/latex2sympy" failed with error code 1 in /tmp/pip-e698cucb-build/
もの:-v -v -v -v
pdb.set_trace
(コマンドがハングし、Iを追加する- 手動ピップコマンドをReruning出力が表示されない)
- ipythonシェルを追加する(install_requiredの場合でもipythonはインストールされていません)
- が、これは
setup.py
は、ソースコードに予想される場所に相対確かに私がしようとして考えられてきた
物事であることを示しているstrace -F
の実行:
- 実行時にネットワークのバックドアシェルを作成します(プロジェクトのtox.ini -fileで怠惰)
PEP 263を処理するためのtox legacyインタープリタサポート( 'tokenize.open'は暗黙的に' detect_encoding')を定義し、MS改行を* nix改行に変更するように見えます。私はこれがpip間の問題であると言います(私はそれが 'pip - * - build' dirsのmktempingであると仮定します)。 – cowbert
私はあなたがテストのためにtoxを使いたいと思うので、tox.iniファイルに 'usedevelop = True'を指定するのは問題でしょうか?これは回避策ですが、ユースケースでは十分かもしれません。 – bow