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

Conversation

pwaller
Copy link
Contributor

@pwaller pwaller commented Dec 4, 2016

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.

@pwaller
Copy link
Contributor Author

pwaller commented Dec 5, 2016

Great, I saw you just released Opcodes 0.3.10. I will test and update this, unless you interject.

@pwaller pwaller force-pushed the make-pip-installable branch 2 times, most recently from 5beb972 to 20f1353 Compare December 5, 2016 02:07
@Maratyszcza
Copy link
Owner

@pwaller
Copy link
Contributor Author

pwaller commented Dec 5, 2016

Yes, afaik it fails everywhere at the moment. I'm still working on it. I currently have to work around a slight problem that __version__ is determined by importing peachpy, which it's not possible to do before installation before dependencies have been installed. The simplest thing to do would be to simply duplicate the version number and write it literally in setup.py. If you want to deduplicate it then the next best thing would be to put it in a file of its own, which doesn't require importing peachpy/__init__.py, which gets tricky fast (e.g, peachpy/version.py would cause peachpy to be imported and therefore the imports that we can't have because we haven't installed dependencies yet).

I'm going to proceed with duplicating the version number and getting rid of the peachpy import from the setup.py for now for sake of seeing if I can make everything else work.

@pwaller
Copy link
Contributor Author

pwaller commented Dec 5, 2016

This now builds for me locally, let's see what travis and appveyor make of it.

@pwaller pwaller force-pushed the make-pip-installable branch 2 times, most recently from 042b8a9 to c78f709 Compare December 5, 2016 02:27
@pwaller
Copy link
Contributor Author

pwaller commented Dec 5, 2016

OK! I think I'm there.

So now, the generated files don't get put in the source directory during installation, they are only directly installed, it seems, through the magic of pip. Therefore, the tests run with import peachpy being the peachpy which was installed, rather than the ./peachpy directory of the source checkout.

With that, I think pip install no works as I would hope for it to. I have not done any documentation updates or anything like this yet.

@pwaller
Copy link
Contributor Author

pwaller commented Dec 5, 2016

Appveyor now passed.

@@ -88,7 +88,7 @@ def run(self):
"Topic :: Software Development :: Compilers",
"Topic :: Software Development :: Libraries"
],
setup_requires=["Opcodes==0.3.9"],
setup_requires=["Opcodes==0.3.9", "six"],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it needed? setup.py doesn't import six

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find! I put it in when before I understood that the peachpy import needed to be removed. Unfortunately, determining the version comes before setup_requires can be evaluated and install six, so it's not helpful. Removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take that back. You can see from the test failures that it turns out this is needed in order to run the codegen itself at setup time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the commit removing six from setup_requires.

@pwaller pwaller force-pushed the make-pip-installable branch from 66c7ecd to c78f709 Compare December 5, 2016 02:43
# 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.)
- nosetests --no-path-adjustment
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to put no-path-adjustment=1 in setup.cfg instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -77,6 +87,10 @@ def run(self):
"Topic :: Software Development :: Compilers",
"Topic :: Software Development :: Libraries"
],
setup_requires=["Opcodes==0.3.10", "six"],
install_requires=["Opcodes==0.3.10", "six", "enum34"],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opcodes is redundant here. It is needed to generate instruction in PeachPy, but after PeachPy is installed, opcodes is no longer needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@pwaller
Copy link
Contributor Author

pwaller commented Dec 5, 2016

I have selected "Allow edits from maintainers" for this pull request, and I have to sign out very shortly. If you have any other small fixes in the next few minutes, I will make them rapidly. But if I don't respond within 5 minutes you can assume I have signed out for the night. Thanks for looking at this quickly. I would also appreciate a quick look at #60 if you can spare a moment. All the best! 👍

@Maratyszcza
Copy link
Owner

LGTM. Please squash commits into one and rename to "Setup: make PIP installable", and I will merge

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
@pwaller pwaller force-pushed the make-pip-installable branch from 172dfeb to 2c62da9 Compare December 5, 2016 02:53
@pwaller
Copy link
Contributor Author

pwaller commented Dec 5, 2016

Done. Please do any further required edits.

@Maratyszcza Maratyszcza merged commit affbf0b into Maratyszcza:master Dec 5, 2016
@pwaller pwaller deleted the make-pip-installable branch December 5, 2016 03:12
@pwaller
Copy link
Contributor Author

pwaller commented Dec 5, 2016

Note: tests failed because the PR was merged before tests had run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants