Skip to content

Make PeachPy pip installable #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
  • Loading branch information
pwaller committed Dec 5, 2016
commit 2c62da9ccce61a028f00b7471711b074827c25fd
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ python:
- "pypy"
- "pypy3"
install:
- pip install -r requirements.txt
- python setup.py generate
- pip install .
- pip install -r test/requirements.txt
- export PATH="$HOME/.local/bin:$PATH"
script: nosetests
script:
- nosetests
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ verbosity = 2
where = ./test
# Color output
rednose = 1
# --no-path-adjustment is required because we want to run the tests against
# what is installed, not what is in the checked out source directory.
# (Extra files are generated during installation which don't exist in the
# source tree.)
no-path-adjustment=1
24 changes: 19 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
#!/usr/bin/env python

from peachpy import __version__
import distutils.log
from distutils.command.build import build
from setuptools.command.develop import develop
from distutils.cmd import Command
from distutils.core import setup

from setuptools import setup

def read_text_file(path):
import os
with open(os.path.join(os.path.dirname(__file__), path)) as f:
return f.read()


class BuildGenerateInstructions(build):
def run(self):
self.run_command("generate")
build.run(self)

class DevelopGenerateInstructions(develop):
def run(self):
self.run_command("generate")
develop.run(self)

class GenerateInstructions(Command):
description = "Generate Peach-Py instructions from Opcodes DB"
user_options = []
Expand Down Expand Up @@ -39,7 +49,7 @@ def run(self):

setup(
name="PeachPy",
version=__version__,
version="0.2.0",
description="Portable Efficient Assembly Codegen in Higher-level Python",
author="Marat Dukhan",
author_email="maratek@gmail.com",
Expand Down Expand Up @@ -77,6 +87,10 @@ def run(self):
"Topic :: Software Development :: Compilers",
"Topic :: Software Development :: Libraries"
],
setup_requires=["Opcodes==0.3.10", "six"],
install_requires=["six", "enum34"],
cmdclass={
"generate": GenerateInstructions
"build": BuildGenerateInstructions,
"develop": DevelopGenerateInstructions,
"generate": GenerateInstructions,
})