Skip to content

Commit 2c62da9

Browse files
committed
Setup: make pip installable
This patch makes setuptools a dependency. This is needed to make `setup.py` automatically make the `Opcodes` module available at setup time. Opcodes is made into a setup-time dependency, and if the module is installed with `python setup.py build` or `python setup.py develop` or `pip install PeachPy` or `pip install --editable PeachPy`, then the `python setup.py generate` command is run automatically. This patch depends on Maratyszcza/Opcodes#5 because of the way setuptools handles setup-time dependencies. They are not installed proper, but made available as an .egg file. Opcodes, before Maratyszcza/Opcodes#5, tries to read the XML descriptions by opening a file relative to `__file__`, which is not a thing which can be read with `open()`. Instead, it has to use `pkg_resources` to do so. With these two PRs merged, it should be possible to `pip install git+https://github.com/Maratyszcza/PeachPy`. We could also then discuss making it easy to package up and upload to PyPi. Try removing pip install -r requirements and generate step from installation Add six and enum34 to install_requires Add six to setup_requires Upgrade to Opcodes==0.3.10 Remove peachpy import from setup.py (and duplicate the version number by writing it literally) Fix setup.py for python2.7 Run tests with --no-path-adjustment Put nosetests configuration in setup.cfg Remove Opcodes from install_requires
1 parent fae77dd commit 2c62da9

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ python:
77
- "pypy"
88
- "pypy3"
99
install:
10-
- pip install -r requirements.txt
11-
- python setup.py generate
1210
- pip install .
1311
- pip install -r test/requirements.txt
1412
- export PATH="$HOME/.local/bin:$PATH"
15-
script: nosetests
13+
script:
14+
- nosetests

setup.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ verbosity = 2
33
where = ./test
44
# Color output
55
rednose = 1
6+
# --no-path-adjustment is required because we want to run the tests against
7+
# what is installed, not what is in the checked out source directory.
8+
# (Extra files are generated during installation which don't exist in the
9+
# source tree.)
10+
no-path-adjustment=1

setup.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
#!/usr/bin/env python
22

3-
from peachpy import __version__
43
import distutils.log
4+
from distutils.command.build import build
5+
from setuptools.command.develop import develop
56
from distutils.cmd import Command
6-
from distutils.core import setup
7-
7+
from setuptools import setup
88

99
def read_text_file(path):
1010
import os
1111
with open(os.path.join(os.path.dirname(__file__), path)) as f:
1212
return f.read()
1313

1414

15+
class BuildGenerateInstructions(build):
16+
def run(self):
17+
self.run_command("generate")
18+
build.run(self)
19+
20+
class DevelopGenerateInstructions(develop):
21+
def run(self):
22+
self.run_command("generate")
23+
develop.run(self)
24+
1525
class GenerateInstructions(Command):
1626
description = "Generate Peach-Py instructions from Opcodes DB"
1727
user_options = []
@@ -39,7 +49,7 @@ def run(self):
3949

4050
setup(
4151
name="PeachPy",
42-
version=__version__,
52+
version="0.2.0",
4353
description="Portable Efficient Assembly Codegen in Higher-level Python",
4454
author="Marat Dukhan",
4555
author_email="maratek@gmail.com",
@@ -77,6 +87,10 @@ def run(self):
7787
"Topic :: Software Development :: Compilers",
7888
"Topic :: Software Development :: Libraries"
7989
],
90+
setup_requires=["Opcodes==0.3.10", "six"],
91+
install_requires=["six", "enum34"],
8092
cmdclass={
81-
"generate": GenerateInstructions
93+
"build": BuildGenerateInstructions,
94+
"develop": DevelopGenerateInstructions,
95+
"generate": GenerateInstructions,
8296
})

0 commit comments

Comments
 (0)