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

Migrate all scripts to Python 3 #144

Merged
merged 5 commits into from
Sep 12, 2018
Merged

Migrate all scripts to Python 3 #144

merged 5 commits into from
Sep 12, 2018

Conversation

joshuathayer
Copy link
Contributor

@joshuathayer joshuathayer commented Sep 11, 2018

This contains the minor changes necessary to our existing scripts for them to run using Python 3 rather than Python 2. Mostly that involves using the new print syntax and changing the hashbang lines.

Closes #128

@joshuathayer
Copy link
Contributor Author

Eh, this isn't quite right yet! Going to [WIP] it...

@joshuathayer
Copy link
Contributor Author

circleci is failing because it's running flake8 in a python2 environment, so we have a chicken/egg problem: if we update our circleci configuration to run under python3, other PRs will fail CI. But until we do that update, this PR will fail CI. 🤔

@conorsch
Copy link
Contributor

Should have seen that one coming, @joshuathayer. Let's update the CI in this branch to switch the flake8 logic to python3, then all other active PRs remain passing. We have work elsewhere that we can port here, will share a patch...

Hacky implementation, I admit. As part of the migration from Python2 to
Python3, we must update the flake8 logic to use Python3, as well. The
most straightforward way to do so is in a container. In order to support
volume mounting in the container, we must update CircleCI to use the
"machine" type for builds.

The wrapper script logic is a bit convoluted here, would prefer to fold
in the 'file' package requirement in the underlying container
(freedomofpress/ci-python), but deferring that work for now to unblock
development on the workstation.

As for why the file package is necessary, flake8 autodiscovery will only
lint .py files, not the various scripts we have here.
@conorsch
Copy link
Contributor

conorsch commented Sep 12, 2018

@joshuathayer Fixed the CircleCI config here. It now runs python3 flake8, and it's failing:

./sd-journalist/sd-process-display:38:1: E305 expected 2 blank lines after class or function definition, found 1
make: *** [flake8] Error 123

The setup should work for you locally, as well, so you can make flake8 and get feedback on what still needs to be fixed. Apologies that the new target is slow; I cut corners and installed the requisite packages via the entrypoint script, so there's no caching to take advantage of on repeated runs. Still, hopefully you're unblocked now!

@joshuathayer joshuathayer removed the WIP label Sep 12, 2018
Copy link
Contributor

@redshiftzero redshiftzero left a comment

Choose a reason for hiding this comment

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

Just looked at this diff, python 2-> 3 changes are uncontroversial so approving

re: flake8 in CI I think we could just use the circleci/python:3.x docker container like we do in a couple other SecureDrop repos, e.g. https://github.com/freedomofpress/securedrop-client/blob/master/.circleci/config.yml#L16 which might be simpler, but approving nevertheless

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.

3 participants