Skip to content

Commit 8479ad2

Browse files
committed
Revert "Revert back to b83cb96, remove all (Inline::)Python code"
This reverts commit 75de461.
1 parent 9758c85 commit 8479ad2

File tree

86 files changed

+10249
-2828
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+10249
-2828
lines changed

.gitignore

+6-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ cache/translate
1212
# all caches
1313
data/cache/
1414

15+
# Media Cloud virtualenv
16+
mc-venv/
17+
1518
# Python bytecode files
1619
*.py[cod]
1720

@@ -26,6 +29,9 @@ Session.vim
2629
# OS X
2730
.DS_Store
2831

32+
# Inline::* bytecode (there might be multiple directories that start with this prefix)
33+
_Inline*
34+
2935
# Devel::NYTProf output
3036
nytprof*
3137

@@ -48,7 +54,3 @@ script/vagrant/temp-vagrant-mediacloud
4854

4955
# atom sync config
5056
.remote-sync.json
51-
52-
# Inline:: binaries
53-
_Inline*
54-

.travis.yml

+4-9
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,14 @@ env:
5050
before_install:
5151
# Install APT packages (not PostgreSQL though)
5252
- ./install_scripts/install_mediacloud_system_package_dependencies.sh
53+
# Install Python dependencies
54+
- travis_retry ./install_scripts/install_python_dependencies.sh
5355
# Set up kernel and PostgreSQL parameters
5456
- ./install_scripts/set_kernel_parameters.sh
5557
- ./install_scripts/set_postgresql_parameters.sh
56-
# Set up local Media Cloud environment for Python
57-
- mkdir -p $HOME/mc-python
58-
- virtualenv $HOME/mc-python
59-
- source $HOME/mc-python/bin/activate
60-
# Install Python dependencies
61-
- travis_retry pip install --upgrade pip setuptools
62-
- travis_retry pip install --upgrade -r python_scripts/requirements.txt
6358
# Install Media Cloud testing variant of the Python Client
6459
- travis_retry git clone https://github.com/berkmancenter/mediacloud-api-testing-client.git MediaCloud-API-Client/
65-
- travis_retry pip install --editable MediaCloud-API-Client/
60+
- travis_retry sudo pip2 install --editable MediaCloud-API-Client/
6661
# Create + switch to the Media Cloud's Perlbrew library
6762
- perlbrew lib create mediacloud
6863
- perlbrew switch @mediacloud
@@ -80,6 +75,6 @@ before_script:
8075
- ./script/run_with_carton.sh ./script/mediawords_create_db.pl
8176
script:
8277
# Start Readability service for testing "PythonReadability" extractor method on t/test_extractor.t
83-
- "python python_scripts/extractor_python_readability_server.py &"
78+
- "python2 python_scripts/extractor_python_readability_server.py &"
8479
# Run Media Cloud's test suite, report test coverage to https://coveralls.io/r/berkmancenter/mediacloud
8580
- ./script/run_test_suite_for_devel_cover.sh coveralls --destroy-solr

api_test/api_media.t

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ sub test_media
108108
}
109109
];
110110

111-
cmp_deeply( $actual_response, $expected_response, "response format mismatch for $url" );
111+
cmp_deeply( $actual_response, $expected_response, "response format mismatch for $url; actual response: " . Dumper( $actual_response ) );
112112

113113
foreach my $medium ( @{ $expected_response } )
114114
{
@@ -135,7 +135,7 @@ sub test_media
135135

136136
my $feed_actual_response = decode_json( $response->decoded_content() );
137137

138-
cmp_deeply( $feed_actual_response, $expected_feed, 'response format mismatch for feed' );
138+
cmp_deeply( $feed_actual_response, $expected_feed, 'response format mismatch for feed; actual response: ' . Dumper( $feed_actual_response ) );
139139
}
140140
}
141141

@@ -178,7 +178,7 @@ sub test_tags
178178
}
179179
];
180180

181-
cmp_deeply( $actual_response, $expected_response, "response format mismatch for $url" );
181+
cmp_deeply( $actual_response, $expected_response, "response format mismatch for $url; actual response: " . Dumper( $actual_response ) );
182182
}
183183
}
184184

api_test/run_api_test.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ if ps aux | grep java | grep 8983 > /dev/null; then
4141
fi
4242

4343
echo "Starting Solr..."
44-
python ./solr/run_solr_standalone.py &
44+
python3 ./solr/run_solr_standalone.py &
4545
solr_pid=$!
4646

4747
SOLR_IS_UP=0
@@ -119,7 +119,7 @@ if MEDIACLOUD_IGNORE_DB_SCHEMA_VERSION=1 MEDIAWORDS_FORCE_USING_TEST_DATABASE=1
119119
done
120120

121121
cd MediaCloud-API-Client
122-
if python test.py; then
122+
if python2 test.py; then
123123
echo "Python API test succeeded"
124124
else
125125
TEST_RETURN_STATUS=$?

cpanfile

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ requires 'Module::Install';
108108
requires 'Module::Pluggable::Object';
109109
requires 'Moo', '2.000001';
110110
requires 'Moose';
111+
requires 'Mouse', '2.4.5';
111112
requires 'namespace::autoclean';
112113
requires 'Net::Amazon::S3';
113114
requires 'Net::Calais';

cpanfile.snapshot

+8-8
Original file line numberDiff line numberDiff line change
@@ -6268,10 +6268,10 @@ DISTRIBUTIONS
62686268
MooseX::Types 0.04
62696269
Path::Class 0.16
62706270
Test::More 0.88
6271-
Mouse-2.4.1
6272-
pathname: G/GF/GFUJI/Mouse-2.4.1.tar.gz
6271+
Mouse-v2.4.5
6272+
pathname: S/SY/SYOHEX/Mouse-v2.4.5.tar.gz
62736273
provides:
6274-
Mouse v2.4.1
6274+
Mouse v2.4.5
62756275
Mouse::Exporter undef
62766276
Mouse::Meta::Attribute undef
62776277
Mouse::Meta::Class undef
@@ -6289,19 +6289,19 @@ DISTRIBUTIONS
62896289
Mouse::Meta::TypeConstraint undef
62906290
Mouse::Object undef
62916291
Mouse::PurePerl undef
6292-
Mouse::Role v2.4.1
6293-
Mouse::Spec v2.4.1
6294-
Mouse::Tiny v2.2.0
6292+
Mouse::Role v2.4.5
6293+
Mouse::Spec v2.4.5
6294+
Mouse::Tiny v2.4.5
62956295
Mouse::TypeRegistry undef
6296-
Mouse::Util v2.4.1
6296+
Mouse::Util v2.4.5
62976297
Mouse::Util::MetaRole undef
62986298
Mouse::Util::TypeConstraints undef
62996299
Squirrel undef
63006300
Squirrel::Role undef
63016301
Test::Mouse undef
63026302
ouse undef
63036303
requirements:
6304-
Devel::PPPort 3.19
6304+
Devel::PPPort 3.22
63056305
ExtUtils::ParseXS 3.22
63066306
Module::Build 0.4005
63076307
Module::Build::XSUtil 0

doc/temporarycrawler.markdown

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Following are instructions for setting up and running a temporary crawler (backu
6262

6363
6. Import media and feeds from the production server by running:
6464

65-
python python_scripts/media_import.py --api-key API-KEY
65+
python2 python_scripts/media_import.py --api-key API-KEY
6666

6767
where `API-KEY` is an API key for mediacloud.org.
6868

@@ -102,7 +102,7 @@ When you're ready to export:
102102

103103
4. Export `feed_downloads` to the production system by running:
104104

105-
python python_scripts/export_feed_downloads_through_api.py \
105+
python2 python_scripts/export_feed_downloads_through_api.py \
106106
--source-api-key SOURCE_API_KEY \
107107
--dest-api-key DEST_API_KEY \
108108
--source-media-cloud-api_url SOURCE_MEDIA_CLOUD_API_URL \
@@ -117,7 +117,7 @@ When you're ready to export:
117117

118118
E.g.:
119119

120-
python python_scripts/export_feed_downloads_through_api.py \
120+
python2 python_scripts/export_feed_downloads_through_api.py \
121121
--source-api-key 'e07cf98dd0d457351354ee520635c226acd238ecf15ec9e853346e185343bf7b' \
122122
--dest-api-key '1161251f5de4f381a198eea4dc20350fd992f5eef7cb2fdc284c245ff3d4f3ca' \
123123
--source-media-cloud-api_url 'http://localhost:3000/' \

install.sh

+1-8
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,11 @@ if [ ! -f mediawords.yml ]; then
1919
fi
2020

2121
./install_scripts/install_mediacloud_package_dependencies.sh
22+
./install_scripts/install_python_dependencies.sh
2223
./install_scripts/set_kernel_parameters.sh
2324
./install_scripts/set_postgresql_parameters.sh
2425
./install_scripts/install_mc_perlbrew_and_modules.sh
2526

26-
# Install Python dependencies
27-
sudo pip install --upgrade pip # make sure pip is latest version to avoid errors
28-
sudo pip install --upgrade -r python_scripts/requirements.txt || {
29-
# Sometimes fails with some sort of Setuptools error
30-
echo "'pip install' failed the first time, retrying..."
31-
sudo pip install --upgrade -r python_scripts/requirements.txt
32-
}
33-
3427
echo "install complete"
3528
echo "running compile test"
3629

install_scripts/install_mediacloud_system_package_dependencies.sh

+27-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -u
44
set -o errexit
55

66

7-
VAGRANT_URL_DEBIAN="https://releases.hashicorp.com/vagrant/1.8.5/vagrant_1.8.5_x86_64.deb"
7+
VAGRANT_URL_DEBIAN="https://releases.hashicorp.com/vagrant/1.8.6/vagrant_1.8.6_x86_64.deb"
88
ERLANG_APT_GPG_KEY_URL="http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc"
99
ERLANG_APT_REPOSITORY_URL="http://packages.erlang-solutions.com/ubuntu"
1010
RABBITMQ_PACKAGECLOUD_SCRIPT="https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.deb.sh"
@@ -59,7 +59,7 @@ function verlt() {
5959
}
6060

6161

62-
echo "installing media cloud system dependencies"
62+
echo "Installing Media Cloud system dependencies..."
6363
echo
6464

6565
if [ `uname` == 'Darwin' ]; then
@@ -87,6 +87,7 @@ EOF
8787
exit 1
8888
fi
8989

90+
echo "Installing Media Cloud dependencies with Homebrew..."
9091
brew install \
9192
coreutils \
9293
cpanminus \
@@ -96,12 +97,13 @@ EOF
9697
homebrew/dupes/tidy \
9798
hunspell \
9899
libyaml \
99-
libyaml \
100100
netcat \
101101
openssl \
102+
python3 \
102103
rabbitmq \
103104
#
104105

106+
echo "Installing Media Cloud dependencies with cpanm..."
105107
sudo cpanm \
106108
DBD::Pg \
107109
Graph \
@@ -138,6 +140,8 @@ else
138140

139141
# assume Ubuntu
140142
source /etc/lsb-release
143+
144+
echo "Installing curl..."
141145
sudo apt-get -y install curl
142146

143147
# Apt's versions of Supervisor, Vagrant, RabbitMQ are too old
@@ -154,7 +158,11 @@ else
154158

155159
if verlt "$DISTRIB_RELEASE" "14.04"; then
156160
# Ubuntu < 14.04 APT's version of Erlang is too old (needed by RabbitMQ)
161+
echo "Removing system package Erlang on Ubuntu 12.04 because it's too old..."
157162
sudo apt-get -y remove erlang*
163+
164+
# Install and hold specific version of Erlang
165+
echo "Installing Erlang from Erlang Solutions..."
158166
curl "$ERLANG_APT_GPG_KEY_URL" | sudo apt-key add -
159167
echo "deb $ERLANG_APT_REPOSITORY_URL precise contrib" | \
160168
sudo tee -a /etc/apt/sources.list.d/erlang-solutions.list
@@ -169,6 +177,7 @@ else
169177

170178
# Ubuntu (all versions) APT's version of RabbitMQ is too old
171179
# (we need 3.6.0+ to support priorities and lazy queues)
180+
echo "Adding RabbitMQ GPG key for Apt..."
172181
curl -s "$RABBITMQ_PACKAGECLOUD_SCRIPT" | sudo bash
173182

174183
if verlt "$DISTRIB_RELEASE" "14.04"; then
@@ -184,12 +193,23 @@ else
184193

185194
if verlt "$DISTRIB_RELEASE" "16.04"; then
186195
# Solr 6+ requires Java 8 which is unavailable before 16.04
196+
echo "Adding Java 8 PPA repository to Ubuntu 12.04..."
187197
sudo apt-get -y install python-software-properties
188198
sudo add-apt-repository -y ppa:openjdk-r/ppa
189199
sudo apt-get update
190200
fi
191201

202+
# Python version to install
203+
if verlt "$DISTRIB_RELEASE" "16.04"; then
204+
# We require at least Python 3.5 (12.04 only has 3.2 which doesn't work with newest Pip)
205+
echo "Adding Python 3.5 PPA repository to Ubuntu 12.04..."
206+
sudo apt-get -y install python-software-properties
207+
sudo add-apt-repository -y ppa:fkrull/deadsnakes
208+
sudo apt-get update
209+
fi
210+
192211
# Install the rest of the packages
212+
echo "Installing Media Cloud dependencies with APT..."
193213
sudo apt-get --assume-yes install \
194214
build-essential \
195215
cpanminus \
@@ -231,17 +251,21 @@ else
231251
python-pip \
232252
python2.7 \
233253
python2.7-dev \
254+
python3.5 \
255+
python3.5-dev \
234256
unzip \
235257
#
236258

237259
# Choose to use OpenJDK 8 by default
238260
PATH="$PATH:/usr/sbin"
261+
echo "Selecting Java 8..."
239262
sudo update-java-alternatives -s `update-java-alternatives --list | grep java-1.8 | awk '{ print $3 }'`
240263

241264
# Install / upgrade Setuptools before installing Python dependencies
242265
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python2.7 -
243266

244267
# Disable system-wide RabbitMQ server (we will start and use our very own instance)
268+
echo "Stopping and disabling system's RabbitMQ instance..."
245269
sudo update-rc.d rabbitmq-server disable
246270
sudo service rabbitmq-server stop
247271

@@ -284,12 +308,3 @@ else
284308
fi
285309

286310
fi
287-
288-
# Install (upgrade) Supervisor
289-
# (change dir, otherwise the installer might think we're trying to install
290-
# from the supervisor/ directory)
291-
if [ `uname` == 'Darwin' ]; then
292-
( cd /tmp; pip install --upgrade supervisor )
293-
else
294-
( cd /tmp; sudo pip install --upgrade supervisor )
295-
fi

install_scripts/install_modules_with_carton.sh

+5
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,17 @@ if [ `uname` == 'Darwin' ]; then
3535
Net::AMQP::RabbitMQ~2.100001
3636
fi
3737

38+
# Inline::Python needs to use virtualenv's Python 3 instead of the default Python2
39+
set +u; source mc-venv/bin/activate; set -u
40+
INLINE_PYTHON_EXECUTABLE=`which python3`
41+
3842
# Install dependency modules; run the command twice because the first
3943
# attempt might fail
4044
ATTEMPT=1
4145
CARTON_INSTALL_SUCCEEDED=0
4246
until [ $ATTEMPT -ge 3 ]; do
4347
OPENSSL_PREFIX=$OPENSSL_PREFIX \
48+
INLINE_PYTHON_EXECUTABLE=$INLINE_PYTHON_EXECUTABLE \
4449
./script/run_carton.sh install && {
4550
echo "Successfully installed Carton modules"
4651
CARTON_INSTALL_SUCCEEDED=1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
set -e
4+
# no "set -u" because installation scripts address various undefined variables
5+
6+
# Version comparison functions
7+
function verlte() {
8+
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
9+
}
10+
11+
function verlt() {
12+
[ "$1" = "$2" ] && return 1 || verlte "$1" "$2"
13+
}
14+
15+
# Install / upgrade Setuptools (easy_install) to both Python versions before installing dependencies
16+
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python2.7 -
17+
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python3.5 -
18+
19+
# Install / upgrade Pip to both Python versions before installing dependencies
20+
sudo easy_install-2.7 pip
21+
sudo easy_install-3.5 pip
22+
23+
# Install (upgrade) Supervisor:
24+
# * change dir, otherwise the installer might think we're trying to install from the supervisor/ directory
25+
# * also, Supervisor only supports Python 2.7 at the moment
26+
( cd /tmp; sudo pip2.7 install --upgrade supervisor )
27+
28+
# Install (upgrade Virtualenv)
29+
sudo pip2.7 install --upgrade virtualenv
30+
sudo pip3.5 install --upgrade virtualenv
31+
32+
# Install Python 2 dependencies
33+
sudo pip2.7 install --upgrade -r python_scripts/requirements.txt || {
34+
# Sometimes fails with some sort of Setuptools error
35+
echo "'pip2.7 install' failed the first time, retrying..."
36+
sudo pip2.7 install --upgrade -r python_scripts/requirements.txt
37+
}
38+
39+
# Create virtualenv and activate it
40+
virtualenv --python=python3.5 mc-venv
41+
source mc-venv/bin/activate
42+
43+
# Install Python 3 dependencies (no sudo because we're in virtualenv)
44+
pip3.5 install --upgrade -r mediacloud/requirements.txt || {
45+
# Sometimes fails with some sort of Setuptools error
46+
echo "'pip3.5 install' failed the first time, retrying..."
47+
pip3.5 install --upgrade -r mediacloud/requirements.txt
48+
}

0 commit comments

Comments
 (0)