Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

Commit

Permalink
Test pypi upload (#357)
Browse files Browse the repository at this point in the history
* Implement test script to see if generated distributions can be installed
* Add deployment script
* Make sure old build artifacts are deleted before deploying
  • Loading branch information
seppeljordan authored Oct 26, 2019
1 parent 255b575 commit 0430a0a
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 46 deletions.
43 changes: 1 addition & 42 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,6 @@
/.coverage
/build
/deploy_rsa
/examples/*.txt
/examples/aiohttp
/examples/aiohttp.nix
/examples/aiohttp_override.nix
/examples/awscli_and_requests
/examples/awscli_and_requests.nix
/examples/connexion
/examples/connexion.nix
/examples/empy
/examples/empy.nix
/examples/empy_override.nix
/examples/flake8
/examples/flake8-includes
/examples/flake8-includes.nix
/examples/flake8-includes_override.nix
/examples/flake8.nix
/examples/flake8_override.nix
/examples/ldap
/examples/ldap.nix
/examples/lektor
/examples/lektor
/examples/lektor.nix
/examples/lektor.nix
/examples/mercurial
/examples/mercurial.nix
/examples/mercurial_override.nix
/examples/pillow
/examples/pillow
/examples/pillow.nix
/examples/pillow.nix
/examples/pillow_override.nix
/examples/pillow_override.nix
/examples/pypi2nix
/examples/rss2email
/examples/rss2email.nix
/examples/rss2email_override.nix
/examples/scipy
/examples/scipy.nix
/examples/tornado
/examples/tornado.nix
/examples/tornado_override.nix
/out/
/result*
/src/pypi2nix.egg-info/
Expand All @@ -62,4 +21,4 @@
/dist/
*.egg-info
**/.eggs/**
.mypy_cache
.mypy_cache
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,11 @@ jobs:
- nix build
- result/bin/pypi2nix --version
- nix-shell --command 'pytest unittests/'
- stage: package tests
name: package installation
os: linux
env:
- NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz

script:
- nix-shell --command 'install_test.py'
4 changes: 2 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ in python.mkDerivation {
dontUseSetuptoolsShellHook = true;
checkPhase = if doCheck then ''
echo "Running black ..."
black --check --diff -v setup.py src/ unittests/ mypy/ ${maybeIntegrationTestsDir}
black --check --diff -v setup.py src/ unittests/ mypy/ ${maybeIntegrationTestsDir} scripts/
echo "Running flake8 ..."
flake8 -v setup.py src/ ${maybeIntegrationTestsDir} unittests/
flake8 -v setup.py src/ ${maybeIntegrationTestsDir} unittests/ scripts/
mypy --config-file setup.cfg src/
mypy \
--config-file setup.cfg \
Expand Down
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ attrs
# develop
pdbpp

# packaging
twine

# setup requires
pytest-runner
setuptools-scm
Expand Down
129 changes: 129 additions & 0 deletions requirements.nix
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,25 @@ let
};
};

"bleach" = python.mkDerivation {
name = "bleach-3.1.0";
src = pkgs.fetchurl {
url = "https://files.pythonhosted.org/packages/78/5a/0df03e8735cd9c75167528299c738702437589b9c71a849489d00ffa82e8/bleach-3.1.0.tar.gz";
sha256 = "3fdf7f77adcf649c9911387df51254b813185e32b2c6619f690b593a617e19fa";
};
doCheck = commonDoCheck;
buildInputs = commonBuildInputs ++ [ ];
propagatedBuildInputs = [
self."six"
self."webencodings"
];
meta = with pkgs.stdenv.lib; {
homepage = "https://github.com/mozilla/bleach";
license = licenses.asl20;
description = "An easy safelist-based HTML-sanitizing tool.";
};
};

"certifi" = python.mkDerivation {
name = "certifi-2019.9.11";
src = pkgs.fetchurl {
Expand Down Expand Up @@ -614,6 +633,22 @@ let
};
};

"pkginfo" = python.mkDerivation {
name = "pkginfo-1.5.0.1";
src = pkgs.fetchurl {
url = "https://files.pythonhosted.org/packages/6c/04/fd6683d24581894be8b25bc8c68ac7a0a73bf0c4d74b888ac5fe9a28e77f/pkginfo-1.5.0.1.tar.gz";
sha256 = "7424f2c8511c186cd5424bbf31045b77435b37a8d604990b79d4e70d741148bb";
};
doCheck = commonDoCheck;
buildInputs = commonBuildInputs ++ [ ];
propagatedBuildInputs = [ ];
meta = with pkgs.stdenv.lib; {
homepage = "https://code.launchpad.net/~tseaver/pkginfo/trunk";
license = licenses.mit;
description = "Query metadatdata from sdists / bdists / installed packages.";
};
};

"pluggy" = python.mkDerivation {
name = "pluggy-0.13.0";
src = pkgs.fetchurl {
Expand Down Expand Up @@ -800,6 +835,27 @@ let
};
};

"readme-renderer" = python.mkDerivation {
name = "readme-renderer-24.0";
src = pkgs.fetchurl {
url = "https://files.pythonhosted.org/packages/44/de/a567140b13a0fc8d3b04d85a510b5a7d9869b44b2939fa8ac07c5e421485/readme_renderer-24.0.tar.gz";
sha256 = "bb16f55b259f27f75f640acf5e00cf897845a8b3e4731b5c1a436e4b8529202f";
};
doCheck = commonDoCheck;
buildInputs = commonBuildInputs ++ [ ];
propagatedBuildInputs = [
self."bleach"
self."docutils"
self."pygments"
self."six"
];
meta = with pkgs.stdenv.lib; {
homepage = "https://github.com/pypa/readme_renderer";
license = licenses.asl20;
description = "readme_renderer is a library for rendering \"readme\" descriptions for Warehouse";
};
};

"requests" = python.mkDerivation {
name = "requests-2.22.0";
src = pkgs.fetchurl {
Expand All @@ -821,6 +877,24 @@ let
};
};

"requests-toolbelt" = python.mkDerivation {
name = "requests-toolbelt-0.9.1";
src = pkgs.fetchurl {
url = "https://files.pythonhosted.org/packages/28/30/7bf7e5071081f761766d46820e52f4b16c8a08fef02d2eb4682ca7534310/requests-toolbelt-0.9.1.tar.gz";
sha256 = "968089d4584ad4ad7c171454f0a5c6dac23971e9472521ea3b6d49d610aa6fc0";
};
doCheck = commonDoCheck;
buildInputs = commonBuildInputs ++ [ ];
propagatedBuildInputs = [
self."requests"
];
meta = with pkgs.stdenv.lib; {
homepage = "https://toolbelt.readthedocs.org";
license = licenses.asl20;
description = "A utility belt for advanced users of python-requests";
};
};

"setuptools" = python.mkDerivation {
name = "setuptools-41.4.0";
src = pkgs.fetchurl {
Expand Down Expand Up @@ -885,6 +959,45 @@ let
};
};

"tqdm" = python.mkDerivation {
name = "tqdm-4.36.1";
src = pkgs.fetchurl {
url = "https://files.pythonhosted.org/packages/80/b3/6ca4806441b730782fc4613c6aa2070412295c5521f33ae151988e448929/tqdm-4.36.1.tar.gz";
sha256 = "abc25d0ce2397d070ef07d8c7e706aede7920da163c64997585d42d3537ece3d";
};
doCheck = commonDoCheck;
buildInputs = commonBuildInputs ++ [ ];
propagatedBuildInputs = [ ];
meta = with pkgs.stdenv.lib; {
homepage = "https://github.com/tqdm/tqdm";
license = licenses.mit;
description = "Fast, Extensible Progress Meter";
};
};

"twine" = python.mkDerivation {
name = "twine-2.0.0";
src = pkgs.fetchurl {
url = "https://files.pythonhosted.org/packages/91/82/32c68749d10ae30dd126699ee471b8885d9a9ae326a0f25dac42bb6a3f28/twine-2.0.0.tar.gz";
sha256 = "9fe7091715c7576df166df8ef6654e61bada39571783f2fd415bdcba867c6993";
};
doCheck = commonDoCheck;
buildInputs = commonBuildInputs ++ [ ];
propagatedBuildInputs = [
self."pkginfo"
self."readme-renderer"
self."requests"
self."requests-toolbelt"
self."setuptools"
self."tqdm"
];
meta = with pkgs.stdenv.lib; {
homepage = "https://twine.readthedocs.io/";
license = licenses.asl20;
description = "Collection of utilities for publishing packages on PyPI";
};
};

"typed-ast" = python.mkDerivation {
name = "typed-ast-1.4.0";
src = pkgs.fetchurl {
Expand Down Expand Up @@ -949,6 +1062,22 @@ let
};
};

"webencodings" = python.mkDerivation {
name = "webencodings-0.5.1";
src = pkgs.fetchurl {
url = "https://files.pythonhosted.org/packages/0b/02/ae6ceac1baeda530866a85075641cec12989bd8d31af6d5ab4a3e8c92f47/webencodings-0.5.1.tar.gz";
sha256 = "b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923";
};
doCheck = commonDoCheck;
buildInputs = commonBuildInputs ++ [ ];
propagatedBuildInputs = [ ];
meta = with pkgs.stdenv.lib; {
homepage = "https://github.com/SimonSapin/python-webencodings";
license = licenses.bsdOriginal;
description = "Character encoding aliases for legacy web content";
};
};

"wheel" = python.mkDerivation {
name = "wheel-0.33.6";
src = pkgs.fetchurl {
Expand Down
7 changes: 7 additions & 0 deletions requirements_frozen.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ appdirs==1.4.3
atomicwrites==1.3.0
attrs==19.3.0
black==19.3b0
bleach==3.1.0
certifi==2019.9.11
chardet==3.0.4
Click==7.0
Expand All @@ -28,6 +29,7 @@ nix-prefetch-github==2.3.1
packaging==19.2
Parsley==1.3
pdbpp==0.10.2
pkginfo==1.5.0.1
pluggy==0.13.0
py==1.8.0
pycodestyle==2.5.0
Expand All @@ -38,13 +40,18 @@ pytest==5.2.2
pytest-cov==2.8.1
pytest-runner==5.1
pytoml==0.1.21
readme-renderer==24.0
requests==2.22.0
requests-toolbelt==0.9.1
setuptools-scm==3.3.3
six==1.12.0
toml==0.10.0
tqdm==4.36.1
twine==2.0.0
typed-ast==1.4.0
typing-extensions==3.7.4
urllib3==1.25.6
wcwidth==0.1.7
webencodings==0.5.1
wmctrl==0.3
zipp==0.6.0
48 changes: 48 additions & 0 deletions scripts/deploy_to_pypi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python
import argparse
import os
import shutil
import subprocess

from pypi2nix.version import pypi2nix_version


def main():
set_up_environment()
args = parse_args()
pypi_name = get_pypi_name_from_args(args)
remove_old_build_artifacts()
deploy_to(pypi_name)


def set_up_environment():
os.putenv("SOURCE_DATE_EPOCH", "315532800")


def parse_args():
parser = argparse.ArgumentParser(description="Deploy pypi2nix to pypi")
parser.add_argument("--production", action="store_true", default=False)
return parser.parse_args()


def get_pypi_name_from_args(args):
return "pypi" if args.production else "test-pypi"


def remove_old_build_artifacts():
shutil.rmtree("src/pypi2nix.egg-info", ignore_errors=True)


def deploy_to(pypi_name):
subprocess.run(["python", "setup.py", "sdist", "bdist_wheel"], check=True)
distribution_paths = [
f"dist/pypi2nix-{pypi2nix_version}.tar.gz",
f"dist/pypi2nix-{pypi2nix_version}-py3-none-any.whl",
]
subprocess.run(
["twine", "upload", "-r", pypi_name] + distribution_paths, check=True
)


if __name__ == "__main__":
main()
Loading

0 comments on commit 0430a0a

Please sign in to comment.