Skip to content

Use setuptools to locate XML to read #5

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

Closed
wants to merge 1 commit into from

Conversation

pwaller
Copy link
Contributor

@pwaller pwaller commented Dec 4, 2016

This makes the code compatible with opcodes being packaged up as an .egg
file, which is required for supporting

It also makes setuptools a requirement for installing the package. This
should probably be documented.

This is part of making PeachPy easy to install by making the code
generation happen automatically during installation time (see
Maratyszcza/PeachPy#38).

@pwaller
Copy link
Contributor Author

pwaller commented Dec 4, 2016

A bit more justification as to why this is required:

  • The goal is to make it possible to pip install PeachPy
  • This requires Opcodes installed at setup time (with the setup_requires directive to setuptools)
  • Setuptools arranges this by putting a .egg of the source code in a temporary directory
  • When the code tries to open the path by looking at __file__, it tries to open a file within an .egg (which is just a zip archive), and crashes
  • To solve this, we instead use pkg_resources, which is .egg aware.

Once merged, I will follow up with a pull request to fix PeachPy installation, making it so that the build/install/develop phases automatically do the code generation required.

This makes the code compatible with opcodes being packaged up as an .egg
file, which is required for supporting

It also makes setuptools a requirement for installing the package. This
should probably be documented.

This is part of making PeachPy easy to install by making the code
generation happen automatically during installation time (see
Maratyszcza/PeachPy#38).
pwaller added a commit to pwaller/PeachPy that referenced this pull request 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.
@Maratyszcza
Copy link
Owner

Committed manually as 653f470, with some modifications

@Maratyszcza Maratyszcza closed this Dec 5, 2016
@pwaller pwaller deleted the use-pkg-resources branch December 5, 2016 01:53
@pwaller
Copy link
Contributor Author

pwaller commented Dec 5, 2016

Slight problem with your modifications, I now get this:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-kg96j2mg-build/setup.py", line 96, in <module>
        "generate": GenerateInstructions,
      File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/home/pwaller/.local/lib/python3.5/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/lib/python3.5/distutils/command/install.py", line 583, in run
        self.run_command('build')
      File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/tmp/pip-kg96j2mg-build/setup.py", line 18, in run
        self.run_command("generate")
      File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/tmp/pip-kg96j2mg-build/setup.py", line 47, in run
        import codegen.x86_64
      File "/tmp/pip-kg96j2mg-build/codegen/x86_64.py", line 38, in <module>
        instruction_groups = json.load(open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "x86_64.json")))
    NameError: name 'os' is not defined

@pwaller
Copy link
Contributor Author

pwaller commented Dec 5, 2016

Sorry, this is probably an unrelated problem. Investigating.

@Maratyszcza
Copy link
Owner

Maratyszcza commented Dec 5, 2016

Should be fixed with fae77dd2078731127c0c7c8807fc41e024451dcd

pwaller added a commit to pwaller/PeachPy that referenced this pull request Dec 5, 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

I had concluded the same change which I've since rebased on top of.

pwaller added a commit to pwaller/PeachPy that referenced this pull request Dec 5, 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.

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
Maratyszcza pushed a commit to Maratyszcza/PeachPy that referenced this pull request Dec 5, 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.

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
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