Skip to content
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

Remove wheels with pandoc included #188

Closed
wants to merge 4 commits into from
Closed
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
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ install:
- "%CMD_IN_ENV% python -m pip install twine wheel"

build_script:
- "%CMD_IN_ENV% python setup.py download_pandoc"
- "%CMD_IN_ENV% pypandoc\\files\\pandoc --version"
- "%CMD_IN_ENV% python -c 'from pypandoc import download_pandoc as dp; dp();"
- "%CMD_IN_ENV% pandoc --version"

test_script:
# Run the project tests
Expand Down
30 changes: 3 additions & 27 deletions pypandoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import textwrap
import warnings

from .pandoc_download import DEFAULT_TARGET_FOLDER, download_pandoc
from .pandoc_download import DEFAULT_TARGET_FOLDER, download_pandoc, ensure_pandoc_installed
from .py3compat import cast_bytes, cast_unicode, string_types, url2path, urlparse

__author__ = u'Juho Vepsäläinen'
Expand Down Expand Up @@ -277,18 +277,12 @@ def _convert_input(source, format, input_type, to, extra_args=(), outputfile=Non
f = ['--filter=' + x for x in filters]
args.extend(f)

# To get access to pandoc-citeproc when we use a included copy of pandoc,
# we need to add the pypandoc/files dir to the PATH
new_env = os.environ.copy()
files_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "files")
new_env["PATH"] = new_env.get("PATH", "") + os.pathsep + files_path

p = subprocess.Popen(
args,
stdin=subprocess.PIPE if string_input else None,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=new_env)
env=os.environ)

# something else than 'None' indicates that the process already terminated
if not (p.returncode is None):
Expand Down Expand Up @@ -547,25 +541,7 @@ def _ensure_pandoc_path(quiet=False):
"""))
raise OSError("No pandoc was found: either install pandoc and add it\n"
"to your PATH or or call pypandoc.download_pandoc(...) or\n"
"install pypandoc wheels with included pandoc.")


def ensure_pandoc_installed(url=None, targetfolder=None, version="latest", quiet=False, delete_installer=False):
"""Try to install pandoc if it isn't installed.

Parameters are passed to download_pandoc()

:raises OSError: if pandoc cannot be installed
"""
try:
# Perform the test quietly if asked
_ensure_pandoc_path(quiet=quiet)

except OSError:
download_pandoc(url=url, targetfolder=targetfolder, version=version, quiet=quiet, delete_installer=delete_installer)

# Show errors in case of secondary failure
_ensure_pandoc_path(quiet=False)
"install py-pandoc which packages pandoc as wheels.")


# -----------------------------------------------------------------------------
Expand Down
20 changes: 20 additions & 0 deletions pypandoc/pandoc_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,23 @@ def download_pandoc(url=None, targetfolder=None, version="latest", quiet=False,
os.remove(filename)
if quiet:
sys.stdout = sys.__stdout__



def ensure_pandoc_installed(url=None, targetfolder=None, version="latest", quiet=False, delete_installer=False):
"""Try to install pandoc if it isn't installed.

Parameters are passed to download_pandoc()

:raises OSError: if pandoc cannot be installed
"""
from pypandoc import _ensure_pandoc_path
try:
# Perform the test quietly if asked
_ensure_pandoc_path(quiet=quiet)

except OSError:
download_pandoc(url=url, targetfolder=targetfolder, version=version, quiet=quiet, delete_installer=delete_installer)

# Show errors in case of secondary failure
_ensure_pandoc_path(quiet=False)
13 changes: 4 additions & 9 deletions release.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
This is the internal checklist, so that @janschulz doesn't have to do another brown paper bag force-pushing the tags...

- checkout `git fetch origin && git checkout origin/master`
- run the tests (on windows): `python tests.py` -> everything ok?
- increment the version in `pypandoc/__init__.py`, commit with `git commit -m "pypandoc vx.x.x"`
- tag the version: `git tag -a vx.x.x`, write a nice version message summarizing new features
- run the tests: `python tests.py` -> everything ok?
- increment the version in `pypandoc/__init__.py`, commit with `git commit -m "pypandoc x.x.x"`
- tag the version: `git tag -a x.x.x`, write a nice version message summarizing new features
- push directly to the repo (registered as `orig_write` in my setup): `git push orig_write HEAD:master --tags`
- build the sdist file: `python setup.py sdist`
- upload to PyPI: `twine upload dist/pypandoc-<version>.zip`
- go to the [package builder repo](https://github.com/JanSchulz/package-builder) and increment the version information in `recipes\pypandoc\meta.yml`
- commit with `git commit -m "Build pypandoc vx.x.x"`
- `git push` -> builds arrive at [PyPI](https://pypi.python.org/pypi?:action=display&name=pypandoc) and [anaconda](https://anaconda.org/janschulz/pypandoc/files)
- celebrate :-)
- celebrate :-)
61 changes: 1 addition & 60 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,63 +17,6 @@
with io.open('README.md', encoding="utf-8") as f:
long_description = f.read()



class DownloadPandocCommand(Command):

"""Download pandoc"""

description = "downloads a pandoc release and adds it to the package"
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
from pypandoc.pandoc_download import download_pandoc
targetfolder = os.path.join(os.path.dirname(os.path.realpath(__file__)), "pypandoc", "files")
download_pandoc(targetfolder=targetfolder)


cmd_classes = {'download_pandoc': DownloadPandocCommand}

# Make sure wheels end up platform specific, if they include a pandoc binary
has_pandoc = (os.path.isfile(os.path.join("pypandoc", "files", "pandoc")) or
os.path.isfile(os.path.join("pypandoc", "files", "pandoc.exe")))
is_build_wheel = ("bdist_wheel" in sys.argv)
is_download_pandoc = ("download_pandoc" in sys.argv)

if is_build_wheel:
if has_pandoc or is_download_pandoc:
# we need to make sure that bdist_wheel is after is_download_pandoc,
# otherwise we don't include pandoc in the wheel... :-(
pos_bdist_wheel = sys.argv.index("bdist_wheel")
if is_download_pandoc:
pos_download_pandoc = sys.argv.index("download_pandoc")
if pos_bdist_wheel < pos_download_pandoc:
raise RuntimeError("'download_pandoc' needs to be before 'bdist_wheel'.")
# we also need to make sure that this version of bdist_wheel supports
# the --plat-name argument
try:
import wheel
from distutils.version import StrictVersion
if not StrictVersion(wheel.__version__) >= StrictVersion("0.27"):
msg = "Including pandoc in wheel needs wheel >=0.27 but found %s.\nPlease update wheel!"
raise RuntimeError(msg % wheel.__version__)
except ImportError:
# the real error will happen further down...
print("No wheel installed, please install 'wheel'...")
print("forcing platform specific wheel name...")
from distutils.util import get_platform
sys.argv.insert(pos_bdist_wheel + 1, '--plat-name')
sys.argv.insert(pos_bdist_wheel + 2, get_platform())
else:
print("no pandoc found, building platform unspecific wheel...")
print("use 'python setup.py download_pandoc' to download pandoc.")

module = pypandoc
setup(
name = 'pypandoc',
Expand All @@ -86,8 +29,7 @@ def run(self):
author = module.__author__.encode('utf8'),
author_email = 'bebraw@gmail.com',
packages = ['pypandoc'],
package_data={'pypandoc': ['files/*']},
install_requires = ['setuptools', 'pip>=8.1.0', 'wheel>=0.25.0'],
install_requires = ['setuptools'],
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',
Expand All @@ -108,5 +50,4 @@ def run(self):
'Programming Language :: Python :: Implementation :: PyPy'
],
test_suite = 'tests',
cmdclass=cmd_classes
)
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py26, py27, py33, py34, py35, py36, pypy, pypy3, flake8
envlist = py27, py36, py37, py38, flake8

[testenv]
# pandoc does not like it when HOME is missing...
Expand All @@ -15,7 +15,7 @@ commands =
max-line-length = 120

[testenv:flake8]
basepython = python2.7
basepython = python3.7
deps =
flake8
commands =
Expand Down