jtpereyda
jtpereyda

Reputation: 7385

Travis CI - Run deploy step (PyPI) as sudo?

I have a Python project that uses tox. Some unit tests require sudo, so .travis.yml has

script:
- sudo tox

However, this leaves the egg-info file and others owned by root. So when Travis runs the deploy step (as user), it gives the following output:

Deploying application
running sdist
running egg_info
writing requirements to myproject.egg-info/requires.txt
error: [Errno 13] Permission denied: 'myproject.egg-info/requires.txt'
ValueError: Cannot find file (or expand pattern): 'dist/*'

How can I run the deploy step as root, or otherwise get around this issue?

Upvotes: 0

Views: 113

Answers (1)

joepd
joepd

Reputation: 4841

Not sure of whether some smartness can be applied with tox itself, but you could start your deploy stage with a script along the following lines:

- sudo chown --changes --recursive $(whoami):$(id --group $(whoami)) .

This sets all the files in the current directory to the current user, and the main group of the current user.

Upvotes: 1

Related Questions