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

Added pelican-gfm plugin #1224

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion pelican-gfm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/environment python -B
#!/usr/bin/environment python333 -B

Choose a reason for hiding this comment

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

Is the python333 a typo?

Copy link
Author

Choose a reason for hiding this comment

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

Yes that was a typo.


from gfm import *
2 changes: 1 addition & 1 deletion pelican-gfm/gfm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python -B
#!/usr/bin/python3 -B
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
Expand Down
122 changes: 58 additions & 64 deletions pelican-gfm/gfmSetup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/python -B
#!/usr/bin/python3 -B

import sys
import os
import subprocess
import gfmVars

from backports import tempfile

# Eventually, equivalents for
# other operating systems / package
Expand Down Expand Up @@ -45,15 +45,14 @@ def dpkg_packages_installed():

if len(need_to_be_removed) is not 0:
raise Exception("Found the following conflicting packages\
which should be removed:\
need_to_be_installed")
which should be removed:" + str(need_to_be_removed))
rem = False
else:
rem = True

if len(need_to_be_installed) is not 0:
raise Exception("Could not find the following required\
packages: need_to_be_installed")
packages: " + need_to_be_installed )
ins = False
else:
ins = True
Expand All @@ -63,82 +62,77 @@ def dpkg_packages_installed():
return True


def cleanUp():
subprocess.call(["rm", "-rf", WORKSPACE])


def setup():
dpkg_packages_installed()

if test_configuration() == 1:
print("System appears to be configured")
# Configure the environment if it's not already configured
if not os.path.isdir(WORKSPACE):
os.mkdir(WORKSPACE)

subprocess.call([
"wget",
"--quiet",
ARCHIVES + "/" + gfmVars.VERSION + ".tar.gz",
WORKSPACE,
"-P",
WORKSPACE
])
subprocess.call([
'tar',
'zxf',
WORKSPACE + "/" + gfmVars.VERSION + ".tar.gz",
"-C",
WORKSPACE
]
)

BUILDSPACE = gfmVars.WORKSPACE + "/" + "cmark-gfm-" + gfmVars.VERSION + "/build"

if not os.path.isdir(BUILDSPACE):
os.mkdir(BUILDSPACE)

thing1 = subprocess.Popen([
"cmake",
"-DCMARK_TESTS=OFF",
"-DCMARK_STATIC=OFF",
".."
], cwd=BUILDSPACE)
thing1.wait()

thing2 = subprocess.Popen(["make"], cwd=BUILDSPACE)
thing2.wait()

# Move the libcmark.so artifacts in place
print "Moving files"
subprocess.call([
"mv",
BUILDSPACE + "/src/libcmark-gfm.so." + gfmVars.VERSION,
gfmVars.LIBCMARKLOCATION + "libcmark-gfm.so"
]
)
subprocess.call([
"mv",
BUILDSPACE + "/extensions/libcmark-gfmextensions.so." + gfmVars.VERSION,
gfmVars.LIBCMARKLOCATION + "libcmark-gfmextensions.so"
]
)
else:
# Configure the environment if it's not already configured

with tempfile.TemporaryDirectory() as WORKSPACE:
subprocess.call([
"wget",
"--quiet",
gfmVars.ARCHIVES + "/" + gfmVars.VERSION + ".tar.gz",
WORKSPACE,
"-P",
WORKSPACE
])
subprocess.call([
'tar',
'zxf',
WORKSPACE + "/" + gfmVars.VERSION + ".tar.gz",
"-C",
WORKSPACE
]
)

BUILDSPACE = WORKSPACE + "/" + "cmark-gfm-" + gfmVars.VERSION + "/build"

if not os.path.isdir(BUILDSPACE):
os.mkdir(BUILDSPACE)

thing1 = subprocess.Popen([
"cmake",
"-DCMARK_TESTS=OFF",
"-DCMARK_STATIC=OFF",
".."
], cwd=BUILDSPACE)
thing1.wait()

thing2 = subprocess.Popen(["make"], cwd=BUILDSPACE)
thing2.wait()

# Move the libcmark.so artifacts in place
print("Moving files")
subprocess.call([

Choose a reason for hiding this comment

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

Is there some reason you can't use shutil.move to move the files here?

Copy link
Author

Choose a reason for hiding this comment

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

good catch! I ended up going with shutil for these moves.

"mv",
BUILDSPACE + "/src/libcmark-gfm.so." + gfmVars.VERSION,
gfmVars.LIBCMARKLOCATION + "libcmark-gfm.so"
]
)
subprocess.call([
"mv",
BUILDSPACE + "/extensions/libcmark-gfmextensions.so." + gfmVars.VERSION,
gfmVars.LIBCMARKLOCATION + "libcmark-gfmextensions.so"
]
)


def test_configuration():
""" Tests to ensure that the files that the plugin needs are in place. """
CMARKPATH = gfmVars.LIBCMARKLOCATION + "/libcmark-gfm.so." + gfmVars.VERSION
if os.path.isfile(gfmVars.LIBCMARKLOCATION + "/libcmark-gfm.so") and \
os.path.isfile(gfmVars.LIBCMARKLOCATION + "/libcmark-gfmextensions.so"):
return 0
os.path.isfile(gfmVars.LIBCMARKLOCATION + "/libcmark-gfmextensions.so"):
return True
else:
return 1
return False


def configure():
print("Checking out the configuration")
setup()
cleanUp()


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion pelican-gfm/gfmVars.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3 -B
# This gets used by the gfm plugin as well as the check_configure function

LIBCMARKLOCATION = "/usr/lib/x86_64-linux-gnu"
Expand Down